export const detailsPanelActions = unionize({
TOGGLE_DETAILS_PANEL: ofType<{}>(),
OPEN_DETAILS_PANEL: ofType<number>(),
- LOAD_DETAILS_PANEL: ofType<string>()
+ LOAD_DETAILS_PANEL: ofType<string>(),
+ START_TRANSITION: ofType<{}>(),
+ END_TRANSITION: ofType<{}>(),
});
export type DetailsPanelAction = UnionOf<typeof detailsPanelActions>;
export const openDetailsPanel = (uuid?: string, tabNr: number = 0) =>
(dispatch: Dispatch) => {
+ startDetailsPanelTransition(dispatch)
dispatch(detailsPanelActions.OPEN_DETAILS_PANEL(tabNr));
if (uuid !== undefined) {
dispatch<any>(loadDetailsPanel(uuid));
);
};
-export const toggleDetailsPanel = () => (dispatch: Dispatch, getState: () => RootState) => {
+export const toggleDetailsPanel = (uuid: string = '') => (dispatch: Dispatch, getState: () => RootState) => {
+ const { detailsPanel, router }= getState()
// because of material-ui issue resizing details panel breaks tabs.
// triggering window resize event fixes that.
+ if(uuid !== detailsPanel.resourceUuid && detailsPanel.isOpened){
+ dispatch<any>(loadDetailsPanel(uuid));
+ } else {
+ setTimeout(() => {
+ window.dispatchEvent(new Event('resize'));
+ }, SLIDE_TIMEOUT);
+ startDetailsPanelTransition(dispatch)
+ dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
+ if (getState().detailsPanel.isOpened) {
+ dispatch<any>(loadDetailsPanel(getState().detailsPanel.resourceUuid));
+ }
+ }
+ };
+
+ const startDetailsPanelTransition = (dispatch) => {
+ dispatch(detailsPanelActions.START_TRANSITION())
setTimeout(() => {
- window.dispatchEvent(new Event('resize'));
+ dispatch(detailsPanelActions.END_TRANSITION())
}, SLIDE_TIMEOUT);
- dispatch(detailsPanelActions.TOGGLE_DETAILS_PANEL());
- if (getState().detailsPanel.isOpened) {
- dispatch<any>(loadDetailsPanel(getState().detailsPanel.resourceUuid));
- }
-};
+}
\ No newline at end of file