X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0a0db4ca8433ae210df5cf1475dd2b77e4aabec9..6ead1b122e52a587963383f6a15edf6dfc166ef6:/src/store/details-panel/details-panel-action.ts diff --git a/src/store/details-panel/details-panel-action.ts b/src/store/details-panel/details-panel-action.ts index 6aebc050b8..52ea0e785e 100644 --- a/src/store/details-panel/details-panel-action.ts +++ b/src/store/details-panel/details-panel-action.ts @@ -12,10 +12,13 @@ import { ServiceRepository } from '~/services/services'; import { TagProperty } from '~/models/tag'; import { startSubmit, stopSubmit } from 'redux-form'; import { resourcesActions } from '~/store/resources/resources-actions'; -import { snackbarActions } from '~/store/snackbar/snackbar-actions'; +import {snackbarActions, SnackbarKind} from '~/store/snackbar/snackbar-actions'; + +export const SLIDE_TIMEOUT = 500; export const detailsPanelActions = unionize({ TOGGLE_DETAILS_PANEL: ofType<{}>(), + OPEN_DETAILS_PANEL: ofType(), LOAD_DETAILS_PANEL: ofType() }); @@ -26,6 +29,8 @@ export const PROJECT_PROPERTIES_DIALOG_NAME = 'projectPropertiesDialogName'; export const loadDetailsPanel = (uuid: string) => detailsPanelActions.LOAD_DETAILS_PANEL(uuid); +export const openDetailsPanel = (uuid: string) => detailsPanelActions.OPEN_DETAILS_PANEL(uuid); + export const openProjectPropertiesDialog = () => (dispatch: Dispatch) => { dispatch(dialogActions.OPEN_DIALOG({ id: PROJECT_PROPERTIES_DIALOG_NAME, data: { } })); @@ -40,7 +45,7 @@ export const deleteProjectProperty = (key: string) => delete project.properties[key]; const updatedProject = await services.projectService.update(project.uuid, project); dispatch(resourcesActions.SET_RESOURCES([updatedProject])); - dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully deleted.", hideDuration: 2000 })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully deleted.", hideDuration: 2000, kind: SnackbarKind.SUCCESS })); } } catch (e) { dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_PROPERTIES_FORM_NAME })); @@ -58,7 +63,7 @@ export const createProjectProperty = (data: TagProperty) => project.properties[data.key] = data.value; const updatedProject = await services.projectService.update(project.uuid, project); dispatch(resourcesActions.SET_RESOURCES([updatedProject])); - dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully added.", hideDuration: 2000 })); + dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully added.", hideDuration: 2000, kind: SnackbarKind.SUCCESS })); dispatch(stopSubmit(PROJECT_PROPERTIES_FORM_NAME)); } return; @@ -66,4 +71,12 @@ export const createProjectProperty = (data: TagProperty) => dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_PROPERTIES_FORM_NAME })); throw new Error('Could not add property to the project.'); } - }; \ No newline at end of file + }; +export const toggleDetailsPanel = () => (dispatch: Dispatch) => { + // because of material-ui issue resizing details panel breaks tabs. + // triggering window resize event fixes that. + setTimeout(() => { + window.dispatchEvent(new Event('resize')); + }, SLIDE_TIMEOUT); + dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL()); +};