[ARVADOS-WORKBENCH2] updated: 1.1.4-697-gb002d61

Git user git at public.curoverse.com
Tue Aug 21 04:25:21 EDT 2018


Summary of changes:
 src/common/api/common-resource-service.ts          |  7 +-
 src/services/services.ts                           |  5 +-
 .../action-sets/collection-action-set.ts           |  9 +--
 .../action-sets/collection-resource-action-set.ts  |  9 +--
 .../context-menu/action-sets/project-action-set.ts |  9 +--
 .../move-collection-dialog.ts                      | 52 +++++++++++++++
 .../move-project-dialog/move-project-dialog.ts     | 58 ++++++++++++++++
 .../move-to-dialog/move-to-dialog.tsx              | 77 +++++-----------------
 src/views/workbench/workbench.tsx                  |  6 +-
 9 files changed, 144 insertions(+), 88 deletions(-)
 create mode 100644 src/views-components/move-collection-dialog/move-collection-dialog.ts
 create mode 100644 src/views-components/move-project-dialog/move-project-dialog.ts

       via  b002d610f3e0e7a181e8119a3604c7577e0348f4 (commit)
       via  f135906f33ad05916bcc72cfd379217071484a09 (commit)
       via  5e11adf6c0acffbd9e78f6a0a1fe39bcecf75047 (commit)
       via  9c2399fe7eb9bffabb6c2316cc4bfb4068330efa (commit)
      from  15987424ea63c887e3ec5f8a1c42cc985301b884 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit b002d610f3e0e7a181e8119a3604c7577e0348f4
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Tue Aug 21 10:23:59 2018 +0200

    Refresh lists after moving a resource
    
    Feature #13831
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/views-components/move-collection-dialog/move-collection-dialog.ts b/src/views-components/move-collection-dialog/move-collection-dialog.ts
index bb75bd6..7409151 100644
--- a/src/views-components/move-collection-dialog/move-collection-dialog.ts
+++ b/src/views-components/move-collection-dialog/move-collection-dialog.ts
@@ -11,6 +11,7 @@ import { RootState } from '~/store/store';
 import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 import { MoveToFormDialogData, MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
+import { projectPanelActions } from '../../store/project-panel/project-panel-action';
 
 export const MOVE_COLLECTION_DIALOG = 'moveCollectionDialog';
 
@@ -26,6 +27,7 @@ export const moveCollection = (resource: MoveToFormDialogData) =>
         try {
             const collection = await services.collectionService.get(resource.uuid);
             await services.collectionService.update(resource.uuid, { ...collection, ownerUuid: resource.ownerUuid });
+            dispatch(projectPanelActions.REQUEST_ITEMS());
             dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_COLLECTION_DIALOG }));
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved', hideDuration: 2000 }));
         } catch (e) {
diff --git a/src/views-components/move-project-dialog/move-project-dialog.ts b/src/views-components/move-project-dialog/move-project-dialog.ts
index 9cae51f..4fce540 100644
--- a/src/views-components/move-project-dialog/move-project-dialog.ts
+++ b/src/views-components/move-project-dialog/move-project-dialog.ts
@@ -11,6 +11,8 @@ import { RootState } from '~/store/store';
 import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
 import { MoveToFormDialogData, MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
+import { projectPanelActions } from '~/store/project-panel/project-panel-action';
+import { getProjectList } from '~/store/project/project-action';
 
 export const MOVE_PROJECT_DIALOG = 'moveProjectDialog';
 
@@ -26,6 +28,9 @@ export const moveProject = (resource: MoveToFormDialogData) =>
         try {
             const project = await services.projectService.get(resource.uuid);
             await services.projectService.update(resource.uuid, { ...project, ownerUuid: resource.ownerUuid });
+            dispatch(projectPanelActions.REQUEST_ITEMS());
+            dispatch<any>(getProjectList(project.ownerUuid));
+            dispatch<any>(getProjectList(resource.ownerUuid));
             dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_PROJECT_DIALOG }));
             dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000 }));
         } catch (e) {

commit f135906f33ad05916bcc72cfd379217071484a09
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Tue Aug 21 10:03:43 2018 +0200

    Split move to dialog into two separate dialogs
    
    Feature #13831
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/views-components/context-menu/action-sets/collection-action-set.ts b/src/views-components/context-menu/action-sets/collection-action-set.ts
index bbe6f5f..d807fea 100644
--- a/src/views-components/context-menu/action-sets/collection-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-action-set.ts
@@ -8,8 +8,7 @@ import { toggleFavorite } from "~/store/favorites/favorites-actions";
 import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, ProvenanceGraphIcon, AdvancedIcon, RemoveIcon } from "~/components/icon/icon";
 import { openUpdater } from "~/store/collections/updater/collection-updater-action";
 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
-import { openMoveToDialog } from "../../move-to-dialog/move-to-dialog";
-import { ResourceKind } from "~/models/resource";
+import { openMoveCollectionDialog } from '../../move-collection-dialog/move-collection-dialog';
 
 export const collectionActionSet: ContextMenuActionSet = [[
     {
@@ -29,11 +28,7 @@ export const collectionActionSet: ContextMenuActionSet = [[
     {
         icon: MoveToIcon,
         name: "Move to",
-        execute: (dispatch, resource) => dispatch<any>(openMoveToDialog({
-            name: resource.name,
-            uuid: resource.uuid,
-            kind: ResourceKind.COLLECTION
-        }))
+        execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
     },
     {
         component: ToggleFavoriteAction,
diff --git a/src/views-components/context-menu/action-sets/collection-resource-action-set.ts b/src/views-components/context-menu/action-sets/collection-resource-action-set.ts
index 24c1bf1..b41176f 100644
--- a/src/views-components/context-menu/action-sets/collection-resource-action-set.ts
+++ b/src/views-components/context-menu/action-sets/collection-resource-action-set.ts
@@ -8,8 +8,7 @@ import { toggleFavorite } from "~/store/favorites/favorites-actions";
 import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, RemoveIcon } from "~/components/icon/icon";
 import { openUpdater } from "~/store/collections/updater/collection-updater-action";
 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
-import { openMoveToDialog } from "../../move-to-dialog/move-to-dialog";
-import { ResourceKind } from '~/models/resource';
+import { openMoveCollectionDialog } from '../../move-collection-dialog/move-collection-dialog';
 
 export const collectionResourceActionSet: ContextMenuActionSet = [[
     {
@@ -29,11 +28,7 @@ export const collectionResourceActionSet: ContextMenuActionSet = [[
     {
         icon: MoveToIcon,
         name: "Move to",
-        execute: (dispatch, resource) => dispatch<any>(openMoveToDialog({
-            name: resource.name,
-            uuid: resource.uuid,
-            kind: ResourceKind.COLLECTION
-        }))
+        execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
     },
     {
         component: ToggleFavoriteAction,
diff --git a/src/views-components/context-menu/action-sets/project-action-set.ts b/src/views-components/context-menu/action-sets/project-action-set.ts
index e5c401a..b8121c3 100644
--- a/src/views-components/context-menu/action-sets/project-action-set.ts
+++ b/src/views-components/context-menu/action-sets/project-action-set.ts
@@ -10,9 +10,8 @@ import { NewProjectIcon, MoveToIcon, RenameIcon } from "~/components/icon/icon";
 import { ToggleFavoriteAction } from "../actions/favorite-action";
 import { toggleFavorite } from "~/store/favorites/favorites-actions";
 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
-import { openMoveToDialog } from "../../move-to-dialog/move-to-dialog";
 import { PROJECT_CREATE_DIALOG } from "../../dialog-create/dialog-project-create";
-import { ResourceKind } from '~/models/resource';
+import { openMoveProjectDialog } from '../../move-project-dialog/move-project-dialog';
 
 export const projectActionSet: ContextMenuActionSet = [[
     {
@@ -42,10 +41,6 @@ export const projectActionSet: ContextMenuActionSet = [[
     {
         icon: MoveToIcon,
         name: "Move to",
-        execute: (dispatch, resource) => dispatch<any>(openMoveToDialog({
-            name: resource.name,
-            uuid: resource.uuid,
-            kind: ResourceKind.PROJECT
-        }))
+        execute: (dispatch, resource) => dispatch<any>(openMoveProjectDialog(resource))
     },
 ]];
diff --git a/src/views-components/move-collection-dialog/move-collection-dialog.ts b/src/views-components/move-collection-dialog/move-collection-dialog.ts
new file mode 100644
index 0000000..bb75bd6
--- /dev/null
+++ b/src/views-components/move-collection-dialog/move-collection-dialog.ts
@@ -0,0 +1,50 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch, compose } from "redux";
+import { withDialog } from "~/store/dialog/with-dialog";
+import { dialogActions } from "~/store/dialog/dialog-actions";
+import { reduxForm, startSubmit, stopSubmit, initialize } from 'redux-form';
+import { ServiceRepository } from '~/services/services';
+import { RootState } from '~/store/store';
+import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { MoveToFormDialogData, MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
+
+export const MOVE_COLLECTION_DIALOG = 'moveCollectionDialog';
+
+export const openMoveCollectionDialog = (resource: { name: string, uuid: string }) =>
+    (dispatch: Dispatch) => {
+        dispatch(initialize(MOVE_COLLECTION_DIALOG, resource));
+        dispatch(dialogActions.OPEN_DIALOG({ id: MOVE_COLLECTION_DIALOG, data: {} }));
+    };
+
+export const moveCollection = (resource: MoveToFormDialogData) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        dispatch(startSubmit(MOVE_COLLECTION_DIALOG));
+        try {
+            const collection = await services.collectionService.get(resource.uuid);
+            await services.collectionService.update(resource.uuid, { ...collection, ownerUuid: resource.ownerUuid });
+            dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_COLLECTION_DIALOG }));
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Collection has been moved', hideDuration: 2000 }));
+        } catch (e) {
+            const error = getCommonResourceServiceError(e);
+            if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
+                dispatch(stopSubmit(MOVE_COLLECTION_DIALOG, { ownerUuid: 'A collection with the same name already exists in the target project.' }));
+            } else {
+                dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_COLLECTION_DIALOG }));
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the collection.', hideDuration: 2000 }));
+            }
+        }
+    };
+
+export const MoveCollectionDialog = compose(
+    withDialog(MOVE_COLLECTION_DIALOG),
+    reduxForm<MoveToFormDialogData>({
+        form: MOVE_COLLECTION_DIALOG,
+        onSubmit: (data, dispatch) => {
+            dispatch(moveCollection(data));
+        }
+    })
+)(MoveToFormDialog);
diff --git a/src/views-components/move-project-dialog/move-project-dialog.ts b/src/views-components/move-project-dialog/move-project-dialog.ts
new file mode 100644
index 0000000..9cae51f
--- /dev/null
+++ b/src/views-components/move-project-dialog/move-project-dialog.ts
@@ -0,0 +1,53 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch, compose } from "redux";
+import { withDialog } from "~/store/dialog/with-dialog";
+import { dialogActions } from "~/store/dialog/dialog-actions";
+import { reduxForm, startSubmit, stopSubmit, initialize } from 'redux-form';
+import { ServiceRepository } from '~/services/services';
+import { RootState } from '~/store/store';
+import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
+import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { MoveToFormDialogData, MoveToFormDialog } from '../move-to-dialog/move-to-dialog';
+
+export const MOVE_PROJECT_DIALOG = 'moveProjectDialog';
+
+export const openMoveProjectDialog = (resource: { name: string, uuid: string }) =>
+    (dispatch: Dispatch) => {
+        dispatch(initialize(MOVE_PROJECT_DIALOG, resource));
+        dispatch(dialogActions.OPEN_DIALOG({ id: MOVE_PROJECT_DIALOG, data: {} }));
+    };
+
+export const moveProject = (resource: MoveToFormDialogData) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        dispatch(startSubmit(MOVE_PROJECT_DIALOG));
+        try {
+            const project = await services.projectService.get(resource.uuid);
+            await services.projectService.update(resource.uuid, { ...project, ownerUuid: resource.ownerUuid });
+            dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_PROJECT_DIALOG }));
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Project has been moved', hideDuration: 2000 }));
+        } catch (e) {
+            const error = getCommonResourceServiceError(e);
+            if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
+                dispatch(stopSubmit(MOVE_PROJECT_DIALOG, { ownerUuid: 'A project with the same name already exists in the target project.' }));
+            } else if (error === CommonResourceServiceError.OWNERSHIP_CYCLE) {
+                dispatch(stopSubmit(MOVE_PROJECT_DIALOG, { ownerUuid: 'Cannot move a project into itself.' }));
+            } else {
+                dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_PROJECT_DIALOG }));
+                dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the project.', hideDuration: 2000 }));
+            }
+        }
+    };
+
+export const MoveProjectDialog = compose(
+    withDialog(MOVE_PROJECT_DIALOG),
+    reduxForm<MoveToFormDialogData>({
+        form: MOVE_PROJECT_DIALOG,
+        onSubmit: (data, dispatch) => {
+            dispatch(moveProject(data));
+        }
+    })
+)(MoveToFormDialog);
+
diff --git a/src/views-components/move-to-dialog/move-to-dialog.tsx b/src/views-components/move-to-dialog/move-to-dialog.tsx
index ad3db48..9b5d06a 100644
--- a/src/views-components/move-to-dialog/move-to-dialog.tsx
+++ b/src/views-components/move-to-dialog/move-to-dialog.tsx
@@ -3,85 +3,36 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
-import { Dispatch, compose } from "redux";
-import { withDialog } from "~/store/dialog/with-dialog";
-import { dialogActions } from "~/store/dialog/dialog-actions";
-import { reduxForm, startSubmit, stopSubmit, InjectedFormProps, initialize, Field, WrappedFieldProps } from 'redux-form';
+import { InjectedFormProps, Field, WrappedFieldProps } from 'redux-form';
 import { WithDialogProps } from '~/store/dialog/with-dialog';
 import { FormDialog } from '~/components/form-dialog/form-dialog';
 import { ProjectTreePicker } from '~/views-components/project-tree-picker/project-tree-picker';
 import { Typography } from "@material-ui/core";
 import { ResourceKind } from '~/models/resource';
-import { ServiceRepository, getResourceService } from '~/services/services';
-import { RootState } from '~/store/store';
-import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
-import { snackbarActions } from '../../store/snackbar/snackbar-actions';
-import { require } from '~/validators/require';
+import { MOVE_TO_VALIDATION } from '../../validators/validators';
 
-export const MOVE_TO_DIALOG = 'moveToDialog';
-
-export interface MoveToDialogResource {
+export interface MoveToFormDialogData {
     name: string;
     uuid: string;
     ownerUuid: string;
     kind: ResourceKind;
 }
 
-export const openMoveToDialog = (resource: { name: string, uuid: string, kind: ResourceKind }) =>
-    (dispatch: Dispatch) => {
-        dispatch(initialize(MOVE_TO_DIALOG, resource));
-        dispatch(dialogActions.OPEN_DIALOG({ id: MOVE_TO_DIALOG, data: {} }));
-    };
-
-export const moveResource = (resource: MoveToDialogResource) =>
-    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const service = getResourceService(resource.kind, services);
-        dispatch(startSubmit(MOVE_TO_DIALOG));
-        if (service) {
-            try {
-                const originalResource = await service.get(resource.uuid);
-                await service.update(resource.uuid, { ...originalResource, ownerUuid: resource.ownerUuid });
-                dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_TO_DIALOG }));
-                dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Resource has been moved', hideDuration: 2000 }));
-            } catch (e) {
-                const error = getCommonResourceServiceError(e);
-                if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
-                    dispatch(stopSubmit(MOVE_TO_DIALOG, { ownerUuid: 'A resource with the same name already exists in the target project.' }));
-                } else if (error === CommonResourceServiceError.OWNERSHIP_CYCLE) {
-                    dispatch(stopSubmit(MOVE_TO_DIALOG, { ownerUuid: 'Cannot move a project into itself.' }));
-                } else {
-                    dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_TO_DIALOG }));
-                    dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the resource.', hideDuration: 2000 }));
-                }
-            }
-        }
-    };
-
-export const MoveToProjectDialog = compose(
-    withDialog(MOVE_TO_DIALOG),
-    reduxForm<MoveToDialogResource>({
-        form: MOVE_TO_DIALOG,
-        onSubmit: (data, dispatch) => {
-            dispatch(moveResource(data));
-        }
-    })
-)((props: WithDialogProps<string> & InjectedFormProps<MoveToDialogResource>) =>
+export const MoveToFormDialog = (props: WithDialogProps<string> & InjectedFormProps<MoveToFormDialogData>) =>
     <FormDialog
         dialogTitle='Move to'
         formFields={MoveToDialogFields}
         submitLabel='Move'
         {...props}
-    />);
+    />;
 
-const MoveToDialogFields = (props: InjectedFormProps<MoveToDialogResource>) =>
+const MoveToDialogFields = () =>
     <Field
         name="ownerUuid"
-        component={Picker}
-        validate={validation} />;
-
-const validation = [require];
+        component={ProjectPicker}
+        validate={MOVE_TO_VALIDATION} />;
 
-const Picker = (props: WrappedFieldProps) =>
+const ProjectPicker = (props: WrappedFieldProps) =>
     <div style={{ height: '200px', display: 'flex', flexDirection: 'column' }}>
         <ProjectTreePicker onChange={handleChange(props)} />
         {props.meta.dirty && props.meta.error &&
@@ -93,4 +44,4 @@ const Picker = (props: WrappedFieldProps) =>
 const handleChange = (props: WrappedFieldProps) => (value: string) =>
     props.input.value === value
         ? props.input.onChange('')
-        : props.input.onChange(value);
\ No newline at end of file
+        : props.input.onChange(value);
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 4d0adf1..eba11d2 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -47,11 +47,12 @@ import { RenameFileDialog } from '~/views-components/rename-file-dialog/rename-f
 import { FileRemoveDialog } from '~/views-components/file-remove-dialog/file-remove-dialog';
 import { MultipleFilesRemoveDialog } from '~/views-components/file-remove-dialog/multiple-files-remove-dialog';
 import { DialogCollectionCreateWithSelectedFile } from '~/views-components/create-collection-dialog-with-selected/create-collection-dialog-with-selected';
-import { MoveToProjectDialog } from '../../views-components/move-to-dialog/move-to-dialog';
 import { COLLECTION_CREATE_DIALOG } from '~/views-components/dialog-create/dialog-collection-create';
 import { PROJECT_CREATE_DIALOG } from '~/views-components/dialog-create/dialog-project-create';
 import { UploadCollectionFilesDialog } from '~/views-components/upload-collection-files-dialog/upload-collection-files-dialog';
 import { CollectionPartialCopyDialog } from '../../views-components/collection-partial-copy-dialog/collection-partial-copy-dialog';
+import { MoveProjectDialog } from '~/views-components/move-project-dialog/move-project-dialog';
+import { MoveCollectionDialog } from '~/views-components/move-collection-dialog/move-collection-dialog';
 
 const DRAWER_WITDH = 240;
 const APP_BAR_HEIGHT = 100;
@@ -246,13 +247,14 @@ export const Workbench = withStyles(styles)(
                         <CreateCollectionDialog />
                         <RenameFileDialog />
                         <CollectionPartialCopyDialog />
-                        <MoveToProjectDialog />
                         <DialogCollectionCreateWithSelectedFile />
                         <FileRemoveDialog />
                         <MultipleFilesRemoveDialog />
                         <UpdateCollectionDialog />
                         <UploadCollectionFilesDialog />
                         <UpdateProjectDialog />
+                        <MoveCollectionDialog />
+                        <MoveProjectDialog />
                         <CurrentTokenDialog
                             currentToken={this.props.currentToken}
                             open={this.state.isCurrentTokenDialogOpen}

commit 5e11adf6c0acffbd9e78f6a0a1fe39bcecf75047
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Tue Aug 21 10:03:02 2018 +0200

    Update ownership error check
    
    Feature #13831
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/common/api/common-resource-service.ts b/src/common/api/common-resource-service.ts
index 53084b4..2c9bfb5 100644
--- a/src/common/api/common-resource-service.ts
+++ b/src/common/api/common-resource-service.ts
@@ -119,7 +119,7 @@ export const getCommonResourceServiceError = (errorResponse: any) => {
         switch (true) {
             case /UniqueViolation/.test(error):
                 return CommonResourceServiceError.UNIQUE_VIOLATION;
-            case /Owner uuid has an ownership cycle/.test(error):
+            case /ownership cycle/.test(error):
                 return CommonResourceServiceError.OWNERSHIP_CYCLE;
             default:
                 return CommonResourceServiceError.UNKNOWN;

commit 9c2399fe7eb9bffabb6c2316cc4bfb4068330efa
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Tue Aug 21 09:30:15 2018 +0200

    Add more error handlers
    
    Feature #13831
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/common/api/common-resource-service.ts b/src/common/api/common-resource-service.ts
index da5bc33..53084b4 100644
--- a/src/common/api/common-resource-service.ts
+++ b/src/common/api/common-resource-service.ts
@@ -31,6 +31,7 @@ export interface Errors {
 
 export enum CommonResourceServiceError {
     UNIQUE_VIOLATION = 'UniqueViolation',
+    OWNERSHIP_CYCLE = 'OwnershipCycle',
     UNKNOWN = 'Unknown',
     NONE = 'None'
 }
@@ -104,10 +105,10 @@ export class CommonResourceService<T extends Resource> {
                 }));
     }
 
-    update(uuid: string, data: any) {
+    update(uuid: string, data: Partial<T>) {
         return CommonResourceService.defaultResponse(
             this.serverApi
-                .put<T>(this.resourceType + uuid, data));
+                .put<T>(this.resourceType + uuid, data && CommonResourceService.mapKeys(_.snakeCase)(data)));
 
     }
 }
@@ -118,6 +119,8 @@ export const getCommonResourceServiceError = (errorResponse: any) => {
         switch (true) {
             case /UniqueViolation/.test(error):
                 return CommonResourceServiceError.UNIQUE_VIOLATION;
+            case /Owner uuid has an ownership cycle/.test(error):
+                return CommonResourceServiceError.OWNERSHIP_CYCLE;
             default:
                 return CommonResourceServiceError.UNKNOWN;
         }
diff --git a/src/services/services.ts b/src/services/services.ts
index c2615a3..d3e82f9 100644
--- a/src/services/services.ts
+++ b/src/services/services.ts
@@ -14,7 +14,8 @@ import { CollectionFilesService } from "./collection-files-service/collection-fi
 import { KeepService } from "./keep-service/keep-service";
 import { WebDAV } from "../common/webdav";
 import { Config } from "../common/config";
-import { ResourceKind } from '~/models/resource';
+import { ResourceKind, Resource } from '~/models/resource';
+import { CommonResourceService } from '../common/api/common-resource-service';
 
 export type ServiceRepository = ReturnType<typeof createServices>;
 
@@ -50,7 +51,7 @@ export const createServices = (config: Config) => {
     };
 };
 
-export const getResourceService = (resourceKind: ResourceKind, serviceRepository: ServiceRepository) => {
+export const getResourceService = (resourceKind: ResourceKind, serviceRepository: ServiceRepository): undefined | CommonResourceService<Resource> => {
     switch (resourceKind) {
         case ResourceKind.PROJECT:
             return serviceRepository.projectService;
diff --git a/src/views-components/move-to-dialog/move-to-dialog.tsx b/src/views-components/move-to-dialog/move-to-dialog.tsx
index e45bc22..ad3db48 100644
--- a/src/views-components/move-to-dialog/move-to-dialog.tsx
+++ b/src/views-components/move-to-dialog/move-to-dialog.tsx
@@ -40,13 +40,15 @@ export const moveResource = (resource: MoveToDialogResource) =>
         if (service) {
             try {
                 const originalResource = await service.get(resource.uuid);
-                await service.update(resource.uuid, { ...originalResource, owner_uuid: resource.ownerUuid });
+                await service.update(resource.uuid, { ...originalResource, ownerUuid: resource.ownerUuid });
                 dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_TO_DIALOG }));
                 dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Resource has been moved', hideDuration: 2000 }));
             } catch (e) {
                 const error = getCommonResourceServiceError(e);
                 if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
-                    dispatch(stopSubmit(MOVE_TO_DIALOG, { ownerUuid: 'A resource with the same name already exists in the target project' }));
+                    dispatch(stopSubmit(MOVE_TO_DIALOG, { ownerUuid: 'A resource with the same name already exists in the target project.' }));
+                } else if (error === CommonResourceServiceError.OWNERSHIP_CYCLE) {
+                    dispatch(stopSubmit(MOVE_TO_DIALOG, { ownerUuid: 'Cannot move a project into itself.' }));
                 } else {
                     dispatch(dialogActions.CLOSE_DIALOG({ id: MOVE_TO_DIALOG }));
                     dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Could not move the resource.', hideDuration: 2000 }));
@@ -77,16 +79,18 @@ const MoveToDialogFields = (props: InjectedFormProps<MoveToDialogResource>) =>
         component={Picker}
         validate={validation} />;
 
-const sameUuid = (value: string, allValues: MoveToDialogResource) =>
-    value === allValues.uuid && 'Cannot move the project to itself';
-
-const validation = [require, sameUuid];
+const validation = [require];
 
 const Picker = (props: WrappedFieldProps) =>
-    <div style={{ height: '144px', display: 'flex', flexDirection: 'column' }}>
-        <ProjectTreePicker onChange={projectUuid => props.input.onChange(projectUuid)} />
+    <div style={{ height: '200px', display: 'flex', flexDirection: 'column' }}>
+        <ProjectTreePicker onChange={handleChange(props)} />
         {props.meta.dirty && props.meta.error &&
             <Typography variant='caption' color='error'>
                 {props.meta.error}
             </Typography>}
     </div>;
+
+const handleChange = (props: WrappedFieldProps) => (value: string) =>
+    props.input.value === value
+        ? props.input.onChange('')
+        : props.input.onChange(value);
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list