1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

fetching and saving nodes

This commit is contained in:
muerwre 2019-08-25 11:10:04 +07:00
parent 4c49ed000a
commit 209ab25ab0
6 changed files with 18020 additions and 6 deletions

18010
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -52,6 +52,7 @@
"@types/node": "^11.9.0",
"@types/ramda": "^0.26.19",
"@types/react": "16.8.23",
"@types/redux-saga": "^0.10.5",
"@typescript-eslint/eslint-plugin": "^1.13.0",
"@typescript-eslint/parser": "^1.13.0",
"axios": "^0.18.0",

View file

@ -1,6 +1,6 @@
const prefix = 'FLOW.';
export const FLOW_ACTIONS = {
GET_FLOW: `${prefix}.GET_FLOW`,
SET_NODES: `${prefix}.SET_NODES`,
GET_FLOW: `${prefix}GET_FLOW`,
SET_NODES: `${prefix}SET_NODES`,
};

View file

@ -2,3 +2,4 @@ import { IState } from '../store';
import { IFlowState } from './reducer';
export const selectFlow = (state: IState): IFlowState => state.flow;
export const selectFlowNodes = (state: IState) => state.flow.nodes;

View file

@ -9,7 +9,7 @@ export interface IModalState {
}
const INITIAL_STATE: IModalState = {
is_shown: true,
is_shown: false,
dialog: DIALOGS.EDITOR,
};

View file

@ -1,4 +1,4 @@
import { takeLatest, call, put } from 'redux-saga/effects';
import { takeLatest, call, put, select } from 'redux-saga/effects';
import { NODE_ACTIONS } from './constants';
import { nodeSave, nodeSetSaveErrors } from './actions';
import { postNode } from './api';
@ -6,6 +6,7 @@ import { reqWrapper } from '../auth/sagas';
import { flowSetNodes } from '../flow/actions';
import { ERRORS } from '~/constants/errors';
import { modalSetShown } from '../modal/actions';
import { selectFlowNodes } from '../flow/selectors';
function* onNodeSave({ node }: ReturnType<typeof nodeSave>) {
yield put(nodeSetSaveErrors({}));
@ -22,8 +23,9 @@ function* onNodeSave({ node }: ReturnType<typeof nodeSave>) {
return yield put(nodeSetSaveErrors({ error: ERRORS.EMPTY_RESPONSE }));
}
yield put(flowSetNodes({ [result.id]: result }));
yield put(modalSetShown(false));
const nodes = yield select(selectFlowNodes);
yield put(flowSetNodes([result, ...nodes]));
return yield put(modalSetShown(false));
}
export default function* nodeSaga() {