-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #1302: current version in the UI #1816
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright 2015, GeoSolutions Sas. | ||
* All rights reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. double * and copyright There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add test |
||
* | ||
* 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}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2016, GeoSolutions Sas. | ||
* All rights reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. copyright 2017 |
||
* | ||
* 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') | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright 2017, GeoSolutions Sas. | ||
* All rights reserved. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove double * |
||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add test |
||
* 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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1024,3 +1024,7 @@ select.form-control option { | |
.tooltip { | ||
z-index: 10000; | ||
} | ||
|
||
.application-version-label { | ||
font-weight: bold; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
${mapstore2.version} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll use "1", as the warning will not stop the build and we can improve this later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need this warning, this is why I removed it. Opinions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, we can ignore this warning