diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-06-03 16:47:51 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-06-03 16:47:51 +0200 |
| commit | 3e9de575501fd1945b8341f7a4e3a89b73e3cb03 (patch) | |
| tree | f3adbe4177b2287e9dd2380a19e3260f82aaf3bb /frontend/views/page/page.actions.js | |
| parent | abd277bc02d36570038de4c0646a672f5585fa84 (diff) | |
getting to the page editor with add tile form
Diffstat (limited to 'frontend/views/page/page.actions.js')
| -rw-r--r-- | frontend/views/page/page.actions.js | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/frontend/views/page/page.actions.js b/frontend/views/page/page.actions.js index cfd0f98..941bd9b 100644 --- a/frontend/views/page/page.actions.js +++ b/frontend/views/page/page.actions.js @@ -1,13 +1,39 @@ import * as types from '../../types' +import { store } from '../../store' +import actions from '../../actions' export const showAddTileForm = () => dispatch => { - dispatch({ type: types.graph.show_add_tile_form }) + dispatch({ type: types.page.show_add_tile_form }) } export const hideAddTileForm = () => dispatch => { - dispatch({ type: types.graph.hide_add_tile_form }) + dispatch({ type: types.page.hide_add_tile_form }) } export const updatePageTile = tile => dispatch => { - dispatch({ type: types.graph.update_graph_tile, tile }) + dispatch({ type: types.page.update_graph_tile, tile }) } + +export const showGraphAndPageIfUnloaded = ({ graph_name, page_name }) => dispatch => ( + new Promise((resolve, reject) => { + showGraphIfUnloaded({ graph_name })(dispatch) + .then(graph => ( + actions.page.show('name/' + graph_name + '/' + page_name) + .then(resolve) + .catch(reject) + )) + .catch(reject) + }) +) + +export const showGraphIfUnloaded = ({ graph_name }) => dispatch => ( + new Promise((resolve, reject) => { + const { res: graph } = store.getState().graph.show + if (graph && graph.path === graph_name) { + return resolve(graph) + } + actions.graph.show('name/' + graph_name) + .then(resolve) + .catch(reject) + }) +)
\ No newline at end of file |
