Skip to content

Commit

Permalink
fix #8913 commit link in projects. (#9324)
Browse files Browse the repository at this point in the history
* #8913 fix commit link in projects.

* now a property githubUrl is mandatory to show it as url

* fix config

* fix test

* fix tests

* add migration guidelines

* fix doc
  • Loading branch information
MV88 authored Aug 3, 2023
1 parent 9937217 commit 7ebdbef
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 18 deletions.
36 changes: 34 additions & 2 deletions docs/developer-guide/mapstore-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,43 @@ This is a list of things to check if you want to update from a previous version

## Migration from 2023.01.xx to 2023.02.00

### About plugin cfg changes

Starting this release **2023.02.00** we have included a new *cfg* option the About plugin called **githubUrl**

We suggest you to edit About plugin cfg of **localConfig.json** adding the following

```diff
{
- "name": "About"
+ "name": "About",
+ "cfg": {
+ "githubUrl": "https:/GITHUB_USER/REPO_NAME/tree/"
+ }
```

inside `configs/pluginsConfig.json` you can add this to the About plugin definition

```diff
"name": "About",
"glyph": "info-sign",
"title": "plugins.About.title",
"description": "plugins.About.description",
"dependencies": [
"SidebarMenu"
- ]
+ ],
+ "defaultConfig": {
+ "githubUrl": "https:/GITHUB_USER/REPO_NAME/tree/"
+ }
},
```

### NodeJS/NPM upgrade

In this release we updated all our systems to use node 16/NPM 8. This because Node 12 is actually out of maintainance.
In this release we updated all our systems to use node 16/NPM 8. This because Node 12 is actually out of maintenance.
We are going to support soon more recent versions of NodeJS solving the related issues.
So make you sure to use the correct verison of NodeJS/NPM to build things correctly. See the [requirements](../requirements/#debug-build) section of the document for the details.
So make you sure to use the correct version of NodeJS/NPM to build things correctly. See the [requirements](../requirements/#debug-build) section of the document for the details.

### Visualization mode in map configuration

Expand Down
5 changes: 4 additions & 1 deletion project/standard/templates/configs/pluginsConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,10 @@
"description": "plugins.About.description",
"dependencies": [
"SidebarMenu"
]
],
"defaultConfig": {
"githubUrl": "https:/geosolutions-it/MapStore2/tree/"
}
},
{
"name": "MousePosition",
Expand Down
20 changes: 16 additions & 4 deletions web/client/configs/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@
}
}
}, {
"name": "About"
"name": "About",
"cfg": {
"githubUrl": "https:/geosolutions-it/MapStore2/tree/"
}
}, "DrawerMenu",
{
"name": "BackgroundSelector",
Expand Down Expand Up @@ -407,7 +410,10 @@
"wrap": true
}
}, {
"name": "About"
"name": "About",
"cfg": {
"githubUrl": "https:/geosolutions-it/MapStore2/tree/"
}
},
{
"name": "MousePosition",
Expand Down Expand Up @@ -670,7 +676,10 @@
"Notifications",
"Login",
{
"name": "About"
"name": "About",
"cfg": {
"githubUrl": "https:/geosolutions-it/MapStore2/tree/"
}
},
"Language",
"NavMenu",
Expand Down Expand Up @@ -796,7 +805,10 @@
"Login",
"BurgerMenu",
{
"name": "About"
"name": "About",
"cfg": {
"githubUrl": "https:/geosolutions-it/MapStore2/tree/"
}
},
"Language",
"NavMenu",
Expand Down
5 changes: 4 additions & 1 deletion web/client/configs/pluginsConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@
"description": "plugins.About.description",
"dependencies": [
"SidebarMenu"
]
],
"defaultConfig": {
"githubUrl": "https:/geosolutions-it/MapStore2/tree/"
}
},
{
"name": "MousePosition",
Expand Down
10 changes: 7 additions & 3 deletions web/client/product/components/viewer/about/VersionInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ class VersionInfo extends React.Component {
<Message msgId="version.commit"/>
</div>
<div className="v_commit">
<a href={this.props.githubUrl} target="_blank" className="v_githubUrl">
{this.props.commit}
</a>
{
this.props.githubUrl ?
<a href={this.props.githubUrl + this.props.commit} target="_blank" className="v_githubUrl">
{this.props.commit}
</a> :
this.props.commit
}
</div>
</div>
<div className="version-info">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("The VersionInfo component", () => {
const message = "#7934 refactor code and resolve eslint error";
const commit = "01046133761de880aebce08a7bf11dd858117837";
const date = "Thu, 23 Jun 2022 20:00:02 +0300";
const githubUrl = "https:/geosolutions-it/MapStore/tree/sha_commit";
const githubUrl = "https:/geosolutions-it/MapStore/tree/";

const vd = ReactDOM.render(
<VersionInfo
Expand Down Expand Up @@ -63,7 +63,7 @@ describe("The VersionInfo component", () => {
expect(versionValue.textContent.trim()).toBe(version);
expect(messageValue.textContent.trim()).toBe(message);
expect(commitValue.textContent.trim()).toBe(commit);
expect(commitValue.innerHTML.trim()).toBe('<a href="https:/geosolutions-it/MapStore/tree/sha_commit" target="_blank" class="v_githubUrl">01046133761de880aebce08a7bf11dd858117837</a>');
expect(commitValue.innerHTML.trim()).toBe(`<a href="https:/geosolutions-it/MapStore/tree/${commit}" target="_blank" class="v_githubUrl">${commit}</a>`);
expect(dateValue.textContent.trim()).toBe(date);
expect(githubUrlValue.textContent.trim()).toBe(commit);
});
Expand Down
10 changes: 8 additions & 2 deletions web/client/product/plugins/About.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ import version from '../../reducers/version';
import { aboutSelector } from '../../selectors/controls';
import {
versionSelector,
githubUrlSelector,
commitSelector,
messageSelector,
dateSelector
} from '../../selectors/version';

const About = connect((state) => ({
version: versionSelector(state),
githubUrl: githubUrlSelector(state),
commit: commitSelector(state),
message: messageSelector(state),
date: dateSelector(state),
Expand All @@ -42,6 +40,14 @@ const About = connect((state) => ({
* @name About
* @class
* @memberof plugins
* @prop {string} cfg.githubUrl base url to the github tree project, default is "". It will generate a url like "https:/GITHUB_USER/REPO_NAME/tree/COMMIT_SHA"
*
* @example
* {
* "cfg" : {
* githubUrl: "https:/GITHUB_USER/REPO_NAME/tree/"
* }
* }
*/
export default {
AboutPlugin: assign(About,
Expand Down
3 changes: 1 addition & 2 deletions web/client/reducers/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ function version(state = {
splitData,
message: splitData.find((x)=> x.includes('Message:')).split('Message: ')[1],
commit: splitData.find((x)=> x.includes('Commit:')).split('Commit: ')[1],
date: splitData.find((x)=> x.includes('Date:')).split('Date: ')[1],
githubUrl: "https:/geosolutions-it/MapStore2/tree/" + __COMMITHASH__
date: splitData.find((x)=> x.includes('Date:')).split('Date: ')[1]
}, action) {
switch (action.type) {
case CHANGE_VERSION: {
Expand Down
1 change: 0 additions & 1 deletion web/client/selectors/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

export const versionSelector = (state) => state.version && state.version.current || '';
export const githubUrlSelector = (state) => state.version && state.version.githubUrl || '';
export const commitSelector = (state) => state.version && state.version.commit || '';
export const messageSelector = (state) => state.version && state.version.message || '';
export const dateSelector = (state) => state.version && state.version.date || '';
Expand Down

0 comments on commit 7ebdbef

Please sign in to comment.