15106: Changes full text search to use trigram indexing
[arvados.git] / src / store / details-panel / details-panel-action.ts
index 6aebc050b806951d2a388a4eaae7e8ba664afc91..52ea0e785ebb1c15b32ff404fdf19dcb3aaa9f76 100644 (file)
@@ -12,10 +12,13 @@ import { ServiceRepository } from '~/services/services';
 import { TagProperty } from '~/models/tag';
 import { startSubmit, stopSubmit } from 'redux-form';
 import { resourcesActions } from '~/store/resources/resources-actions';
-import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import {snackbarActions, SnackbarKind} from '~/store/snackbar/snackbar-actions';
+
+export const SLIDE_TIMEOUT = 500;
 
 export const detailsPanelActions = unionize({
     TOGGLE_DETAILS_PANEL: ofType<{}>(),
+    OPEN_DETAILS_PANEL: ofType<string>(),
     LOAD_DETAILS_PANEL: ofType<string>()
 });
 
@@ -26,6 +29,8 @@ export const PROJECT_PROPERTIES_DIALOG_NAME = 'projectPropertiesDialogName';
 
 export const loadDetailsPanel = (uuid: string) => detailsPanelActions.LOAD_DETAILS_PANEL(uuid);
 
+export const openDetailsPanel = (uuid: string) => detailsPanelActions.OPEN_DETAILS_PANEL(uuid);
+
 export const openProjectPropertiesDialog = () =>
     (dispatch: Dispatch) => {
         dispatch<any>(dialogActions.OPEN_DIALOG({ id: PROJECT_PROPERTIES_DIALOG_NAME, data: { } }));
@@ -40,7 +45,7 @@ export const deleteProjectProperty = (key: string) =>
                 delete project.properties[key];
                 const updatedProject = await services.projectService.update(project.uuid, project);
                 dispatch(resourcesActions.SET_RESOURCES([updatedProject]));
-                dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully deleted.", hideDuration: 2000 }));
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully deleted.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
             }
         } catch (e) {
             dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_PROPERTIES_FORM_NAME }));
@@ -58,7 +63,7 @@ export const createProjectProperty = (data: TagProperty) =>
                 project.properties[data.key] = data.value;
                 const updatedProject = await services.projectService.update(project.uuid, project);
                 dispatch(resourcesActions.SET_RESOURCES([updatedProject]));
-                dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully added.", hideDuration: 2000 }));
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully added.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
                 dispatch(stopSubmit(PROJECT_PROPERTIES_FORM_NAME));
             }
             return;
@@ -66,4 +71,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());
+};