From 3e9de575501fd1945b8341f7a4e3a89b73e3cb03 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 3 Jun 2020 16:47:51 +0200 Subject: getting to the page editor with add tile form --- frontend/views/page/page.actions.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'frontend/views/page/page.actions.js') 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 -- cgit v1.2.3-70-g09d2