Skip to content

Commit 05a60a5

Browse files
committed
#142 Small general improvements
1 parent 2515b1e commit 05a60a5

4 files changed

Lines changed: 27 additions & 19 deletions

File tree

webapp/components/layout/LayoutManager.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class LayoutManager {
147147
middleware = (store) => (next) => (action) => {
148148
const model = this.model;
149149
console.debug(action);
150+
next(action);
150151
switch (action.type) {
151152
case ADD_WIDGET: {
152153

webapp/components/topbar/dialogs/NewModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default class NewModel extends React.Component {
1010
return (
1111
<ActionDialog
1212
command ={"netpyne_geppetto.deleteModel"}
13-
message = {"CREATING NEW MODEL"}
13+
message = {"Creating new model..."}
1414
style={{ textAlign: "center" }}
1515
args = {{ tab: 'define', action: 'deleteModel' }}
1616
buttonLabel={"CREATE"}

webapp/redux/middleware/middleware.js

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {
2-
UPDATE_CARDS, CREATE_NETWORK, CREATE_SIMULATE_NETWORK, PYTHON_CALL, SIMULATE_NETWORK, SHOW_NETWORK,
3-
showNetwork, createNetwork, createAndSimulateNetwork, editModel, EDIT_MODEL
2+
UPDATE_CARDS, CREATE_NETWORK, CREATE_SIMULATE_NETWORK, PYTHON_CALL, SIMULATE_NETWORK, SHOW_NETWORK,
3+
editModel, EDIT_MODEL
44
} from '../actions/general';
55

66
import { openBackendErrorDialog } from '../actions/errors';
@@ -18,16 +18,19 @@ let previousLayout = { edit: undefined, network: undefined };
1818
export default store => next => action => {
1919
const errorCallback = errorPayload => next(openBackendErrorDialog(errorPayload));
2020

21-
const switchLayoutAction = (edit = true) => {
21+
const switchLayoutAction = (edit = true, reset = true) => {
2222
previousLayout[store.getState().general.editMode ? 'edit' : 'network'] = store.layout;
23+
if (reset) {
24+
previousLayout = { edit: undefined, network: undefined };
25+
}
2326
return next(edit
24-
? previousLayout.edit ? setLayout(previousLayout.edit) : setWidgets(Constants.EDIT_WIDGETS)
25-
: previousLayout.network ? setLayout(previousLayout.network) : setWidgets(Constants.DEFAULT_NETWORK_WIDGETS));
27+
? previousLayout.edit ? setLayout(previousLayout.edit) : setWidgets({ ...Constants.EDIT_WIDGETS })
28+
: previousLayout.network ? setLayout(previousLayout.network) : setWidgets({ ...Constants.DEFAULT_NETWORK_WIDGETS }));
2629
}
27-
const toNetworkCallback = () => {
30+
const toNetworkCallback = reset => () => {
2831

2932
if (store.getState().general.editMode) {
30-
switchLayoutAction(false);
33+
switchLayoutAction(false, reset);
3134
}
3235
next(action);
3336
};
@@ -38,25 +41,25 @@ export default store => next => action => {
3841
next(action);
3942
break;
4043
case SHOW_NETWORK:
41-
switchLayoutAction(false);
44+
switchLayoutAction(false, false);
4245
break;
4346
case EDIT_MODEL:{
4447
next(action);
45-
next(setWidgets(Constants.EDIT_WIDGETS));
48+
switchLayoutAction(true);
4649
break
4750
}
4851
case CREATE_NETWORK:{
4952

50-
instantiateNetwork({}).then(toNetworkCallback, errorCallback);
53+
instantiateNetwork({}).then(toNetworkCallback(true), errorCallback);
5154
break;
5255
}
5356
case CREATE_SIMULATE_NETWORK:{
54-
simulateNetwork({ parallelSimulation: false }).then(toNetworkCallback, errorCallback);
57+
simulateNetwork({ parallelSimulation: false }).then(toNetworkCallback(true), errorCallback);
5558
break;
5659
}
5760

5861
case SIMULATE_NETWORK:
59-
simulateNetwork({ parallelSimulation: false, usePrevInst: true }).then(toNetworkCallback, errorCallback);
62+
simulateNetwork({ parallelSimulation: false, usePrevInst: true }).then(toNetworkCallback(true), errorCallback);
6063
break
6164
case PYTHON_CALL: {
6265
const callback = response => {
@@ -69,8 +72,8 @@ export default store => next => action => {
6972
break;
7073
case NETPYNE_COMMANDS.deleteModel:
7174
next(editModel);
72-
next(setWidgets(Constants.EDIT_WIDGETS));
73-
previousLayout = { edit: undefined, network: undefined };
75+
switchLayoutAction(true, true);
76+
7477
break;
7578
default:
7679
break;

webapp/redux/reducers/topbar.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// import action types
22
import { OPEN_TOPBAR_DIALOG, CLOSE_TOPBAR_DIALOG, CHANGE_PAGE_TRANSITION_MODE } from '../actions/topbar';
33
import { TOPBAR_CONSTANTS } from '../../constants'
4+
import { CLOSE_BACKEND_ERROR_DIALOG } from '../actions/errors';
5+
import { CLOSE_DRAWER_DIALOG_BOX } from '../actions/drawer';
46

57
// Default state for general
68
export const TOPBAR_DEFAULT_STATE = {
@@ -10,19 +12,21 @@ export const TOPBAR_DEFAULT_STATE = {
1012
};
1113

1214
// reducer
13-
export default ( state = TOPBAR_DEFAULT_STATE, action ) => ({
15+
export default ( state = { ...TOPBAR_DEFAULT_STATE }, action ) => ({
1416
...state,
15-
...reduceError(state, action)
17+
...reduceTopbar(state, action)
1618
});
1719

1820

1921
// reducer function
20-
function reduceError (state, action) {
22+
function reduceTopbar (state, action) {
2123
switch (action.type) {
2224
case OPEN_TOPBAR_DIALOG:
2325
return { dialogOpen: true, dialogName: action.payload }
2426
case CLOSE_TOPBAR_DIALOG:
25-
return TOPBAR_DEFAULT_STATE
27+
case CLOSE_BACKEND_ERROR_DIALOG:
28+
case CLOSE_DRAWER_DIALOG_BOX:
29+
return { ...TOPBAR_DEFAULT_STATE }
2630
case CHANGE_PAGE_TRANSITION_MODE:
2731
return { pageTransitionMode: action.payload }
2832
default: {

0 commit comments

Comments
 (0)