X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/9438812a13875c06996ed7190f8faf21011910bd..abf8502a9a1f061f58586b966a4012674d9cb71e:/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 c4acf5aa9b..0f13286535 100644 --- a/src/store/details-panel/details-panel-action.ts +++ b/src/store/details-panel/details-panel-action.ts @@ -2,37 +2,25 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { unionize, ofType, UnionOf } from "unionize"; -import { Dispatch } from "redux"; -import { Resource, ResourceKind } from "../../models/resource"; -import { RootState } from "../store"; -import { ServiceRepository } from "../../services/services"; +import { unionize, ofType, UnionOf } from '~/common/unionize'; +import { Dispatch } from 'redux'; + +export const SLIDE_TIMEOUT = 500; export const detailsPanelActions = unionize({ TOGGLE_DETAILS_PANEL: ofType<{}>(), - LOAD_DETAILS: ofType<{ uuid: string, kind: ResourceKind }>(), - LOAD_DETAILS_SUCCESS: ofType<{ item: Resource }>(), -}, { tag: 'type', value: 'payload' }); + LOAD_DETAILS_PANEL: ofType() +}); export type DetailsPanelAction = UnionOf; -export const loadDetails = (uuid: string, kind: ResourceKind) => - async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - dispatch(detailsPanelActions.LOAD_DETAILS({ uuid, kind })); - const item = await getService(services, kind).get(uuid); - dispatch(detailsPanelActions.LOAD_DETAILS_SUCCESS({ item })); - }; +export const loadDetailsPanel = (uuid: string) => detailsPanelActions.LOAD_DETAILS_PANEL(uuid); -const getService = (services: ServiceRepository, kind: ResourceKind) => { - switch (kind) { - case ResourceKind.PROJECT: - return services.projectService; - case ResourceKind.COLLECTION: - return services.collectionService; - default: - return services.projectService; - } +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()); }; - - -