-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into background-selector
- Loading branch information
Showing
27 changed files
with
348 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
var expect = require('expect'); | ||
var { | ||
CHANGE_VERSION, | ||
changeVersion, | ||
loadVersion | ||
} = require('../version'); | ||
|
||
describe('Test correctness of the version actions', () => { | ||
|
||
it('change version', () => { | ||
const action = changeVersion('version'); | ||
expect(action.type).toBe(CHANGE_VERSION); | ||
expect(action.version).toBe('version'); | ||
}); | ||
|
||
it('load version', (done) => { | ||
loadVersion('base/web/client/test-resources/testVersion.txt')((a) => { | ||
try { | ||
expect(a).toExist(); | ||
expect(a.type).toBe(CHANGE_VERSION); | ||
expect(a.version.indexOf('myVersion')).toBe(0); | ||
done(); | ||
} catch(ex) { | ||
done(ex); | ||
} | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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 axios = require('../libs/ajax'); | ||
|
||
const CHANGE_VERSION = 'CHANGE_VERSION'; | ||
const LOAD_VERSION_ERROR = 'LOAD_VERSION_ERROR'; | ||
|
||
/** | ||
* updates the version identifier of the application | ||
* @memberof actions.version | ||
* @param {string} version new version to be set | ||
*/ | ||
function changeVersion(version) { | ||
return { | ||
type: CHANGE_VERSION, | ||
version | ||
}; | ||
} | ||
|
||
/** | ||
* error in loading version file | ||
* @memberof actions.version | ||
* @param {object} e error description | ||
*/ | ||
function loadVersionError(e) { | ||
return { | ||
type: LOAD_VERSION_ERROR, | ||
error: e | ||
}; | ||
} | ||
/** | ||
* loads a version identifier from the given url | ||
* @memberof actions.version | ||
* @param {string} config ['version.txt'] url of the (text) file to load the version identifier from | ||
*/ | ||
function loadVersion(config = 'version.txt') { | ||
return (dispatch) => { | ||
return axios.get(config).then((response) => { | ||
dispatch(changeVersion(response.data)); | ||
}).catch((e) => { | ||
dispatch(loadVersionError(e)); | ||
}); | ||
}; | ||
} | ||
|
||
/** | ||
* Actions for version | ||
* @name actions.version | ||
*/ | ||
module.exports = {CHANGE_VERSION, LOAD_VERSION_ERROR, | ||
loadVersion, loadVersionError, changeVersion}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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 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') | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* 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. | ||
*/ | ||
var expect = require('expect'); | ||
|
||
var version = require('../version'); | ||
|
||
|
||
describe('Test the version reducer', () => { | ||
it('changes the current version', () => { | ||
var state = version({}, {type: 'CHANGE_VERSION', version: 'myVersion'}); | ||
expect(state.current).toBe('myVersion'); | ||
}); | ||
}); |
Oops, something went wrong.