Skip to content
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

Fixed #1126 : click on import data reloads the imports list #1127

Merged
merged 4 commits into from
Oct 11, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions web/client/actions/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 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 ON_STARTUP = 'ON_STARTUP';
Copy link
Member

@offtherailz offtherailz Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too generic string, call it MANAGER_ITEM_SELECTED


function onStartUp(toolId) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function should be called something like itemSelected

return {
type: ON_STARTUP,
toolId
};
}

module.exports = {
ON_STARTUP, onStartUp
};
17 changes: 13 additions & 4 deletions web/client/plugins/manager/Manager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
const React = require('react');

const { onStartUp } = require('../../actions/manager');
const {Nav, NavItem, Glyphicon} = require('react-bootstrap');
const {connect} = require('react-redux');
const {Message} = require('../../components/I18N/I18N');
Expand All @@ -17,6 +17,7 @@ const Manager = React.createClass({
navStyle: React.PropTypes.object,
items: React.PropTypes.array,
onItemSelected: React.PropTypes.func,
onStartUp: React.PropTypes.func,
selectedTool: React.PropTypes.string
},
contextTypes: {
Expand All @@ -26,7 +27,8 @@ const Manager = React.createClass({
return {
items: [],
mapType: "openlayers",
selectedTool: "importer"
selectedTool: "importer",
onStartUp: () => {}
};
},
renderToolIcon(tool) {
Expand All @@ -40,7 +42,11 @@ const Manager = React.createClass({
eventKey={tool.id}
key={tool.id}
href="#"
onClick={(event) => {event.preventDefault(); this.context.router.push("/manager/" + tool.id); }}>
onClick={(event) => {
event.preventDefault();
this.props.onStartUp(tool.id);
this.context.router.push("/manager/" + tool.id);
}}>
{this.renderToolIcon(tool)}
<span className="nav-msg">{tool.msgId ? <Message msgId={tool.msgId} /> : tool.title || tool.id}</span>
</NavItem>));
Expand Down Expand Up @@ -70,5 +76,8 @@ const Manager = React.createClass({
module.exports = {
ManagerPlugin: connect((state, ownProps) => ({
selectedTool: ownProps.tool
}))(Manager)
}),
{
onStartUp
})(Manager)
};
9 changes: 7 additions & 2 deletions web/client/plugins/manager/ManagerMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const React = require('react');
const {connect} = require('react-redux');

const { onStartUp } = require('../../actions/manager');
const assign = require('object-assign');

const {DropdownButton, Glyphicon, MenuItem} = require('react-bootstrap');
Expand All @@ -32,6 +33,7 @@ const ManagerMenu = React.createClass({
entries: React.PropTypes.array,
title: React.PropTypes.node,
onItemClick: React.PropTypes.func,
onStartUp: React.PropTypes.func,
controls: React.PropTypes.object,
mapType: React.PropTypes.string,
panelStyle: React.PropTypes.object,
Expand All @@ -47,6 +49,7 @@ const ManagerMenu = React.createClass({
entries: [],
role: "",
onItemClick: () => {},
onStartUp: () => {},
title: <MenuItem header>Manager</MenuItem>,
controls: [],
mapType: "leaflet",
Expand All @@ -63,7 +66,7 @@ const ManagerMenu = React.createClass({
getTools() {
return [{element: <span key="burger-menu-title">{this.props.title}</span>}, ...this.props.entries.sort((a, b) => a.position - b.position).map((entry) => {
return {
action: (context) => {context.router.push(entry.path); return {type: "MANAGER_MENU::SELECT_TOOL"}; },
action: (context) => {context.router.push(entry.path); return this.props.onStartUp(entry.id); },
text: entry.msgId ? <Message msgId={entry.msgId} /> : entry.text,
cfg: {...entry}
};
Expand Down Expand Up @@ -93,7 +96,9 @@ module.exports = {
ManagerMenuPlugin: assign(connect((state) => ({
controls: state.controls,
role: state.security && state.security.user && state.security.user.role
}))(ManagerMenu), {
}), {
onStartUp
})(ManagerMenu), {
OmniBar: {
name: "managermenu",
position: 1,
Expand Down
23 changes: 22 additions & 1 deletion web/client/reducers/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const {
IMPORTER_WORKSPACE_CREATION_ERROR,
IMPORTER_WORKSPACE_STATUS_CHANGE
} = require('../actions/importer');

const {
ON_STARTUP
} = require('../actions/manager');

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

/******************************************************************************/
Expand Down Expand Up @@ -125,7 +130,11 @@ function updateImportTaskLoadingStatus(state, action, loading = true) {
/* REDUCER ********************************************************************/
/******************************************************************************/

function importer(state = {}, action) {
const initialState = {
importerTool: "importer"
};

function importer(state = initialState, action) {
switch (action.type) {
case IMPORTS_LOADING: {
if (!action.details) {
Expand All @@ -140,6 +149,18 @@ function importer(state = {}, action) {
}
}
return state;
case ON_STARTUP: {
const toolId = action.toolId;
if (toolId === state.importerTool) {
return assign({}, state, {
loadingError: null,
imports: state.imports,
selectedImport: null,
selectedTask: null,
selectedTransform: null
});
}
}
case IMPORTS_LIST_LOADED:
return assign({}, state, {
loadingError: null,
Expand Down