Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 14433_properties_i... 14433_properties_inside_projects
authorJanicki Artur <artur.janicki@contractors.roche.com>
Mon, 19 Nov 2018 09:52:47 +0000 (10:52 +0100)
committerJanicki Artur <artur.janicki@contractors.roche.com>
Mon, 19 Nov 2018 09:52:47 +0000 (10:52 +0100)
refs #2
14433

Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki@contractors.roche.com>

1  2 
src/store/details-panel/details-panel-action.ts
src/views/workbench/workbench.tsx

index 6aebc050b806951d2a388a4eaae7e8ba664afc91,0f13286535630a46b479d5a31e2423908513d249..2c742a1f38a3f4e63698019c092dec34935f1079
@@@ -3,17 -3,10 +3,19 @@@
  // SPDX-License-Identifier: AGPL-3.0
  
  import { unionize, ofType, UnionOf } from '~/common/unionize';
 +import { RootState } from '~/store/store';
  import { Dispatch } from 'redux';
 +import { dialogActions } from '~/store/dialog/dialog-actions';
 +import { getResource } from '~/store/resources/resources';
 +import { ProjectResource } from "~/models/project";
 +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';
  
+ export const SLIDE_TIMEOUT = 500;
  export const detailsPanelActions = unionize({
      TOGGLE_DETAILS_PANEL: ofType<{}>(),
      LOAD_DETAILS_PANEL: ofType<string>()
  
  export type DetailsPanelAction = UnionOf<typeof detailsPanelActions>;
  
 +export const PROJECT_PROPERTIES_FORM_NAME = 'projectPropertiesFormName';
 +export const PROJECT_PROPERTIES_DIALOG_NAME = 'projectPropertiesDialogName';
 +
  export const loadDetailsPanel = (uuid: string) => detailsPanelActions.LOAD_DETAILS_PANEL(uuid);
  
-     };
 +export const openProjectPropertiesDialog = () =>
 +    (dispatch: Dispatch) => {
 +        dispatch<any>(dialogActions.OPEN_DIALOG({ id: PROJECT_PROPERTIES_DIALOG_NAME, data: { } }));
 +    };
 +
 +export const deleteProjectProperty = (key: string) =>
 +    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
 +        const { detailsPanel, resources } = getState();
 +        const project = getResource(detailsPanel.resourceUuid)(resources) as ProjectResource;
 +        try {
 +            if (project) {
 +                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 }));
 +            }
 +        } catch (e) {
 +            dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_PROPERTIES_FORM_NAME }));
 +            throw new Error('Could not remove property from the project.');
 +        }
 +    };
 +
 +export const createProjectProperty = (data: TagProperty) =>
 +    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
 +        const { detailsPanel, resources } = getState();
 +        const project = getResource(detailsPanel.resourceUuid)(resources) as ProjectResource;
 +        dispatch(startSubmit(PROJECT_PROPERTIES_FORM_NAME));
 +        try {
 +            if (project) {
 +                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(stopSubmit(PROJECT_PROPERTIES_FORM_NAME));
 +            }
 +            return;
 +        } catch (e) {
 +            dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_PROPERTIES_FORM_NAME }));
 +            throw new Error('Could not add property to the project.');
 +        }
++    };
+ 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());
+ };
index 19a2ef4922d6ca7792e756b973e571cf91d16803,744526b1910117a2771a49ba24b6091dc2ea599e..8d1fb6700dc308c6709d2374299706f51e75adda
@@@ -141,7 -141,7 +142,8 @@@ export const WorkbenchPanel 
              <PartialCopyCollectionDialog />
              <ProcessCommandDialog />
              <ProcessInputDialog />
 +            <ProjectPropertiesDialog />
+             <RemoveProcessDialog />
              <RenameFileDialog />
              <RichTextEditorDialog />
              <SharingDialog />