-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #79: Migration to the redux library to implement Flux architecture
- Loading branch information
Showing
37 changed files
with
747 additions
and
497 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 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. | ||
*/ | ||
|
||
var expect = require('expect'); | ||
var loadMapConfig = require('../config').loadMapConfig; | ||
|
||
describe('Test configuration related actions', () => { | ||
it('does not load a missing configuration file', (done) => { | ||
loadMapConfig('missingConfig.json')((e) => { | ||
try { | ||
expect(e).toExist(); | ||
expect(e.type).toBe('MAP_CONFIG_LOAD_ERROR'); | ||
done(); | ||
} catch(ex) { | ||
done(ex); | ||
} | ||
}); | ||
}); | ||
|
||
it('loads an existing configuration file', (done) => { | ||
loadMapConfig('base/web/client/test-resources/testConfig.json')((e) => { | ||
try { | ||
expect(e).toExist(); | ||
expect(e.type).toBe('MAP_CONFIG_LOADED'); | ||
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,36 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
var expect = require('expect'); | ||
var loadLocale = require('../locale').loadLocale; | ||
|
||
describe('Test locale related actions', () => { | ||
it('does not load a missing translation file', (done) => { | ||
loadLocale('', 'unknown')((e) => { | ||
try { | ||
expect(e).toExist(); | ||
expect(e.type).toBe('LOCALE_LOAD_ERROR'); | ||
done(); | ||
} catch(ex) { | ||
done(ex); | ||
} | ||
}); | ||
}); | ||
|
||
it('loads an existing translation file', (done) => { | ||
loadLocale('base/web/client/test-resources', 'it-IT')((e) => { | ||
try { | ||
expect(e).toExist(); | ||
expect(e.type).toBe('CHANGE_LOCALE'); | ||
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,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. | ||
*/ | ||
|
||
var axios = require('axios'); | ||
|
||
const MAP_CONFIG_LOADED = 'MAP_CONFIG_LOADED'; | ||
const MAP_CONFIG_LOAD_ERROR = 'MAP_CONFIG_LOAD_ERROR'; | ||
|
||
function configureMap(conf, legacy) { | ||
return { | ||
type: MAP_CONFIG_LOADED, | ||
config: conf, | ||
legacy: legacy || false | ||
}; | ||
} | ||
|
||
function configureError(e) { | ||
return { | ||
type: MAP_CONFIG_LOAD_ERROR, | ||
error: e | ||
}; | ||
} | ||
|
||
function loadMapConfig(configName, legacy) { | ||
return (dispatch) => { | ||
return axios.get(configName).then((response) => { | ||
dispatch(configureMap(response.data, legacy)); | ||
}).catch((e) => { | ||
dispatch(configureError(e)); | ||
}); | ||
}; | ||
} | ||
|
||
module.exports = {MAP_CONFIG_LOADED, MAP_CONFIG_LOAD_ERROR, loadMapConfig}; |
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,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. | ||
*/ | ||
|
||
var axios = require('axios'); | ||
|
||
const CHANGE_LOCALE = 'CHANGE_LOCALE'; | ||
const LOCALE_LOAD_ERROR = 'LOCALE_LOAD_ERROR'; | ||
|
||
function changeLocale(data) { | ||
return { | ||
type: CHANGE_LOCALE, | ||
messages: data.messages, | ||
locale: data.locale | ||
}; | ||
} | ||
|
||
function localeError(e) { | ||
return { | ||
type: LOCALE_LOAD_ERROR, | ||
error: e | ||
}; | ||
} | ||
|
||
function loadLocale(translationFolder, language) { | ||
return (dispatch) => { | ||
return axios.get(translationFolder + '/data.' + language).then((response) => { | ||
dispatch(changeLocale(response.data)); | ||
}).catch((e) => { | ||
dispatch(localeError(e)); | ||
}); | ||
}; | ||
} | ||
|
||
module.exports = {CHANGE_LOCALE, LOCALE_LOAD_ERROR, loadLocale}; |
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 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. | ||
*/ | ||
var React = require('react'); | ||
|
||
var Localized = React.createClass({ | ||
propTypes: { | ||
locale: React.PropTypes.string, | ||
messages: React.PropTypes.object | ||
}, | ||
childContextTypes: { | ||
locale: React.PropTypes.string, | ||
messages: React.PropTypes.object | ||
}, | ||
getChildContext() { | ||
return { | ||
locale: this.props.locale, | ||
messages: this.props.messages | ||
}; | ||
}, | ||
render() { | ||
let { children } = this.props; | ||
|
||
if (typeof children === 'function') { | ||
children = children(); | ||
} | ||
|
||
return React.Children.only(children); | ||
} | ||
}); | ||
|
||
module.exports = Localized; |
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
Oops, something went wrong.