Merge branch '14470-replace-tree-picker-in-copy-dialogs' into 14470-replace-tree...
[arvados-workbench2.git] / src / store / details-panel / details-panel-action.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { unionize, ofType, UnionOf } from '~/common/unionize';
6 import { Dispatch } from 'redux';
7
8 export const SLIDE_TIMEOUT = 500;
9
10 export const detailsPanelActions = unionize({
11     TOGGLE_DETAILS_PANEL: ofType<{}>(),
12     LOAD_DETAILS_PANEL: ofType<string>()
13 });
14
15 export type DetailsPanelAction = UnionOf<typeof detailsPanelActions>;
16
17 export const loadDetailsPanel = (uuid: string) => detailsPanelActions.LOAD_DETAILS_PANEL(uuid);
18
19 export const toggleDetailsPanel = () => (dispatch: Dispatch) => {
20     // because of material-ui issue resizing details panel breaks tabs.
21     // triggering window resize event fixes that.
22     setTimeout(() => {
23         window.dispatchEvent(new Event('resize'));
24     }, SLIDE_TIMEOUT);
25     dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
26 };