import { extractUuidKind, ResourceKind } from 'models/resource';
export const SLIDE_TIMEOUT = 500;
+export const CLOSE_DRAWER = 'CLOSE_DRAWER'
export const detailsPanelActions = unionize({
TOGGLE_DETAILS_PANEL: ofType<{}>(),
};
export const toggleDetailsPanel = (uuid: string = '') => (dispatch: Dispatch, getState: () => RootState) => {
- const { detailsPanel, router }= getState()
- const currentRoute = router.location?.pathname.split('/') || [];
- const currentItemUuid = currentRoute[currentRoute.length - 1];
- // because of material-ui issue resizing details panel breaks tabs.
- // triggering window resize event fixes that.
- if(uuid !== detailsPanel.resourceUuid && (detailsPanel.isOpened || uuid === currentItemUuid)){
+ const { detailsPanel }= getState()
+ const isTargetUuidNew = uuid !== detailsPanel.resourceUuid
+ if(isTargetUuidNew && uuid !== CLOSE_DRAWER && detailsPanel.isOpened){
dispatch<any>(loadDetailsPanel(uuid));
} else {
+ // because of material-ui issue resizing details panel breaks tabs.
+ // triggering window resize event fixes that.
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));
+ dispatch<any>(loadDetailsPanel(isTargetUuidNew ? uuid : detailsPanel.resourceUuid));
}
}
};