Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 14503_keep_service...
[arvados-workbench2.git] / src / store / details-panel / details-panel-action.ts
index cd9ab4b17a657a3d77db1da736edde5f317721e8..2c742a1f38a3f4e63698019c092dec34935f1079 100644 (file)
@@ -14,6 +14,8 @@ import { startSubmit, stopSubmit } from 'redux-form';
 import { resourcesActions } from '~/store/resources/resources-actions';
 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 
+export const SLIDE_TIMEOUT = 500;
+
 export const detailsPanelActions = unionize({
     TOGGLE_DETAILS_PANEL: ofType<{}>(),
     LOAD_DETAILS_PANEL: ofType<string>()
@@ -42,7 +44,6 @@ export const deleteProjectProperty = (key: string) =>
                 dispatch(resourcesActions.SET_RESOURCES([updatedProject]));
                 dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully deleted.", hideDuration: 2000 }));
             }
-            return;
         } catch (e) {
             dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_PROPERTIES_FORM_NAME }));
             throw new Error('Could not remove property from the project.');
@@ -67,4 +68,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());
+};