Skip to content

Commit

Permalink
Fixes geosolutions-it#1302: current version in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarto committed May 12, 2017
1 parent a99bac6 commit 1dd3ac6
Show file tree
Hide file tree
Showing 15 changed files with 172 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"react/jsx-uses-vars": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
"react/no-did-mount-set-state": [2, "allow-in-func"], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
"react/no-did-update-set-state": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
"react/no-multi-comp": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
"react/no-multi-comp": 0, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
"react/no-unknown-property": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md
"react/prop-types": [2, { ignore: ["children"]}], // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
"react/react-in-jsx-scope": 2, // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ npm run cleandoc
npm run lint
npm test
npm run doc
mvn clean install
if [ $# -eq 0 ]
then
mvn clean install
else
mvn clean install -Dmapstore2.version=$1
fi

npm run cleandoc
39 changes: 39 additions & 0 deletions web/client/actions/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright 2015, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const axios = require('../libs/ajax');

const CHANGE_VERSION = 'CHANGE_VERSION';
const LOAD_VERSION_ERROR = 'LOAD_VERSION_ERROR';

function changeVersion(version) {
return {
type: CHANGE_VERSION,
version
};
}

function loadVersionError(e) {
return {
type: LOAD_VERSION_ERROR,
error: e
};
}

function loadVersion(config = 'version.txt') {
return (dispatch) => {
return axios.get(config).then((response) => {
dispatch(changeVersion(response.data));
}).catch((e) => {
dispatch(loadVersionError(e));
});
};
}

module.exports = {CHANGE_VERSION, LOAD_VERSION_ERROR,
loadVersion, loadVersionError, changeVersion};
4 changes: 2 additions & 2 deletions web/client/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"cfg": {
"tools": ["locate"]
}
}, "DrawerMenu", {
}, "Version", "DrawerMenu", {
"name": "Identify",
"showIn": ["Settings"],
"cfg": {
Expand Down Expand Up @@ -111,7 +111,7 @@
}, "Login",
"OmniBar", "BurgerMenu", "Expander", "GlobeViewSwitcher"
],
"desktop": ["Map", "HelpLink", "Share", "DrawerMenu", {
"desktop": ["Map", "HelpLink", "Share", "DrawerMenu", "Version", {
"name": "Identify",
"showIn": ["IdentifyBar", "Settings"],
"cfg": {
Expand Down
55 changes: 55 additions & 0 deletions web/client/plugins/Version.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');
const {connect} = require('react-redux');

const Message = require('../components/I18N/Message');

/**
* Version Plugin. Shows current MapStore2 version
* @class Version
* @memberof plugins
* @static
*
*/
const Version = connect((state) => ({
version: state.version && state.version.current
}))(React.createClass({
propTypes: {
version: React.PropTypes.string
},
getDefaultProps() {
return {
version: 'DEV'
};
},
render() {
return <span className="application-version"><span className="application-version-label"><Message msgId="version.label"/></span>: {this.props.version}</span>;
}
}));

const assign = require('object-assign');

const Empty = React.createClass({
render() {
return null;
}
});

module.exports = {
VersionPlugin: assign(Empty, {
Settings: {
tool: <Version/>,
position: 4
}
}),
reducers: {
version: require('../reducers/version')
}
};
4 changes: 3 additions & 1 deletion web/client/product/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const startApp = () => {
const ConfigUtils = require('../utils/ConfigUtils');

const {loadMaps} = require('../actions/maps');
const {loadVersion} = require('../actions/version');

const StandardApp = require('../components/app/StandardApp');

Expand All @@ -30,7 +31,8 @@ const startApp = () => {
}, {});

const initialActions = [
() => loadMaps(ConfigUtils.getDefaults().geoStoreUrl, ConfigUtils.getDefaults().initialMapFilter || "*")
() => loadMaps(ConfigUtils.getDefaults().geoStoreUrl, ConfigUtils.getDefaults().initialMapFilter || "*"),
loadVersion
];

const appConfig = {
Expand Down
3 changes: 2 additions & 1 deletion web/client/product/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ module.exports = {
ThemeSwitcherPlugin: require('../plugins/ThemeSwitcher'),
ScrollTopPlugin: require('../plugins/ScrollTop'),
GoFull: require('../plugins/GoFull'),
GlobeViewSwitcherPlugin: require('../plugins/GlobeViewSwitcher')
GlobeViewSwitcherPlugin: require('../plugins/GlobeViewSwitcher'),
VersionPlugin: require('../plugins/Version')
},
requires: {
ReactSwipe: require('react-swipeable-views').default,
Expand Down
26 changes: 26 additions & 0 deletions web/client/reducers/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright 2017, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const { CHANGE_VERSION } = require('../actions/version');
const assign = require('object-assign');

function version(state = null, action) {
switch (action.type) {
case CHANGE_VERSION: {
return assign({}, state,
{
current: action.version
}
);
}
default:
return state;
}
}

module.exports = version;
4 changes: 4 additions & 0 deletions web/client/themes/default/ms2-theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -1024,3 +1024,7 @@ select.form-control option {
.tooltip {
z-index: 10000;
}

.application-version-label {
font-weight: bold;
}
3 changes: 3 additions & 0 deletions web/client/translations/data.de-DE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"enable": "Aktiviere",
"layers": "Ebenen",
"warning": "Warnung",
"version": {
"label": "Version"
},
"layerProperties": {
"windowTitle": "Ebenen Eigenschaften",
"title": "Titel",
Expand Down
3 changes: 3 additions & 0 deletions web/client/translations/data.en-US
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"enable": "Enable",
"layers": "Layers",
"warning": "Warning",
"version": {
"label": "Version"
},
"layerProperties": {
"windowTitle": "Layer Properties",
"title": "Title",
Expand Down
3 changes: 3 additions & 0 deletions web/client/translations/data.fr-FR
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"enable": "Activer",
"layers": "Couches",
"warning": "Attention",
"version": {
"label": "Version"
},
"layerProperties": {
"windowTitle": "Propriétés de la couche",
"title": "Titre",
Expand Down
3 changes: 3 additions & 0 deletions web/client/translations/data.it-IT
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"enable": "Abilita",
"layers": "Livelli",
"warning": "Attenzione",
"version": {
"label": "Versione"
},
"layerProperties": {
"windowTitle": "Proprietà del livello",
"title": "Titolo",
Expand Down
1 change: 1 addition & 0 deletions web/client/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${mapstore2.version}
22 changes: 20 additions & 2 deletions web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,30 @@
</execution>
</executions>
</plugin>


<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>version</id>
<phase>process-classes</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/mapstore</outputDirectory>
<encoding>UTF-8</encoding>
<resources>
<resource>
<directory>${basedir}/client</directory>
<filtering>true</filtering>
<includes>
<include>**/version.txt</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>html, configuration files and images</id>
<phase>process-classes</phase>
Expand Down

0 comments on commit 1dd3ac6

Please sign in to comment.