[ARVADOS-WORKBENCH2] updated: 1.2.0-132-g9bad01c

Git user git at public.curoverse.com
Thu Aug 23 05:33:34 EDT 2018


Summary of changes:
 src/store/collections/collection-update-actions.ts | 58 ++++++++++++++++++++++
 .../collections/collection-updater-actions.ts      | 52 -------------------
 .../collection-form-fields.tsx}                    |  2 +-
 .../collection-partial-copy-dialog.tsx             |  2 +-
 .../action-sets/collection-action-set.ts           |  2 +-
 .../action-sets/collection-resource-action-set.ts  |  2 +-
 .../dialog-update/dialog-collection-update.tsx     | 19 ++-----
 .../update-collection-dialog.ts                    |  2 +-
 8 files changed, 68 insertions(+), 71 deletions(-)
 create mode 100644 src/store/collections/collection-update-actions.ts
 delete mode 100644 src/store/collections/collection-updater-actions.ts
 rename src/views-components/{form-dialog/collection-form-dialog.tsx => collection-form-fields/collection-form-fields.tsx} (93%)

       via  9bad01c91c6c67d5067419ab709129ff1d1e6b18 (commit)
      from  067999ebaee9a0decd80d3251afa5b8c102e7907 (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 9bad01c91c6c67d5067419ab709129ff1d1e6b18
Author: Janicki Artur <artur.janicki at contractors.roche.com>
Date:   Thu Aug 23 11:33:27 2018 +0200

    store - change collection update action name, create collection form fields
    
    Feature #14103
    
    Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki at contractors.roche.com>

diff --git a/src/store/collections/collection-update-actions.ts b/src/store/collections/collection-update-actions.ts
new file mode 100644
index 0000000..13df864
--- /dev/null
+++ b/src/store/collections/collection-update-actions.ts
@@ -0,0 +1,58 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from "redux";
+import { getCommonResourceServiceError, CommonResourceServiceError } from "~/common/api/common-resource-service";
+import { ServiceRepository } from "~/services/services";
+import { CollectionResource } from '~/models/collection';
+import { RootState } from "~/store/store";
+import { initialize, startSubmit, stopSubmit } from 'redux-form';
+import { collectionPanelActions } from "~/store/collection-panel/collection-panel-action";
+import { updateDetails } from "~/store/details-panel/details-panel-action";
+import { dialogActions } from "~/store/dialog/dialog-actions";
+import { dataExplorerActions } from "~/store/data-explorer/data-explorer-action";
+import { snackbarActions } from "~/store/snackbar/snackbar-actions";
+import { ContextMenuResource } from '~/store/context-menu/context-menu-reducer';
+import { PROJECT_PANEL_ID } from "~/views/project-panel/project-panel";
+
+export interface CollectionUpdateFormDialogData {
+    uuid: string;
+    name: string;
+    description: string;
+}
+
+export const COLLECTION_FORM_NAME = 'collectionEditDialog';
+
+export const openUpdater = (resource: ContextMenuResource) =>
+    (dispatch: Dispatch) => {
+        dispatch(initialize(COLLECTION_FORM_NAME, resource));
+        dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_FORM_NAME, data: {} }));
+    };
+
+export const editCollection = (data: CollectionUpdateFormDialogData) =>
+    async (dispatch: Dispatch) => {
+        await dispatch<any>(updateCollection(data));
+        dispatch(snackbarActions.OPEN_SNACKBAR({
+            message: "Collection has been successfully updated.",
+            hideDuration: 2000
+        }));
+    };
+
+export const updateCollection = (collection: Partial<CollectionResource>) =>
+    async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const uuid = collection.uuid || '';
+        dispatch(startSubmit(COLLECTION_FORM_NAME));
+        try {
+            const updatedCollection = await services.collectionService.update(uuid, collection);
+            dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: updatedCollection as CollectionResource }));
+            dispatch<any>(updateDetails(updatedCollection));
+            dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
+            dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_FORM_NAME }));
+        } catch(e) {
+            const error = getCommonResourceServiceError(e);
+            if (error === CommonResourceServiceError.UNIQUE_VIOLATION) {
+                dispatch(stopSubmit(COLLECTION_FORM_NAME, { name: 'Collection with the same name already exists.' }));
+            }
+        }
+    };
\ No newline at end of file
diff --git a/src/store/collections/collection-updater-actions.ts b/src/store/collections/collection-updater-actions.ts
deleted file mode 100644
index 34eadd1..0000000
--- a/src/store/collections/collection-updater-actions.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { Dispatch } from "redux";
-import { RootState } from "../store";
-import { ServiceRepository } from "~/services/services";
-import { CollectionResource } from '~/models/collection';
-import { initialize } from 'redux-form';
-import { collectionPanelActions } from "../collection-panel/collection-panel-action";
-import { updateDetails } from "~/store/details-panel/details-panel-action";
-import { dialogActions } from "~/store/dialog/dialog-actions";
-import { dataExplorerActions } from "~/store/data-explorer/data-explorer-action";
-import { PROJECT_PANEL_ID } from "~/views/project-panel/project-panel";
-import { snackbarActions } from "~/store/snackbar/snackbar-actions";
-
-export interface CollectionUpdateFormDialogData {
-    name: string;
-    description: string;
-}
-
-export const COLLECTION_FORM_NAME = 'collectionEditDialog';
-
-export const openUpdater = (resource: { name: string, uuid: string }) =>
-    (dispatch: Dispatch) => {
-        dispatch(initialize(COLLECTION_FORM_NAME, resource));
-        dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_FORM_NAME, data: resource }));
-    };
-
-export const editCollection = (data: { name: string, description: string }) =>
-    (dispatch: Dispatch) => {
-        return dispatch<any>(updateCollection(data)).then(() => {
-            dispatch(snackbarActions.OPEN_SNACKBAR({
-                message: "Collection has been successfully updated.",
-                hideDuration: 2000
-            }));
-            dispatch(dataExplorerActions.REQUEST_ITEMS({ id: PROJECT_PANEL_ID }));
-        });
-    };
-
-export const updateCollection = (collection: Partial<CollectionResource>) =>
-    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const uuid = collection.uuid || '';
-        return services.collectionService
-            .update(uuid, collection)
-            .then(collection => {
-                dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: collection as CollectionResource }));
-                dispatch<any>(updateDetails(collection));
-                dispatch(dialogActions.CLOSE_DIALOG({ id: COLLECTION_FORM_NAME }));
-            }
-        );
-    };
\ No newline at end of file
diff --git a/src/views-components/form-dialog/collection-form-dialog.tsx b/src/views-components/collection-form-fields/collection-form-fields.tsx
similarity index 93%
rename from src/views-components/form-dialog/collection-form-dialog.tsx
rename to src/views-components/collection-form-fields/collection-form-fields.tsx
index d5f1d85..10c807b 100644
--- a/src/views-components/form-dialog/collection-form-dialog.tsx
+++ b/src/views-components/collection-form-fields/collection-form-fields.tsx
@@ -6,7 +6,7 @@ import * as React from "react";
 import { Field, WrappedFieldProps } from "redux-form";
 import { TextField } from "~/components/text-field/text-field";
 import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION, COLLECTION_PROJECT_VALIDATION } from "~/validators/validators";
-import { ProjectTreePicker } from "../project-tree-picker/project-tree-picker";
+import { ProjectTreePicker } from "~/views-components/project-tree-picker/project-tree-picker";
 
 export const CollectionPartialCopyFields = () => <div style={{ display: 'flex' }}>
     <div>
diff --git a/src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx b/src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx
index e230470..00aa5ef 100644
--- a/src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx
+++ b/src/views-components/collection-partial-copy-dialog/collection-partial-copy-dialog.tsx
@@ -6,7 +6,7 @@ import * as React from "react";
 import { compose } from "redux";
 import { reduxForm, InjectedFormProps } from 'redux-form';
 import { withDialog, WithDialogProps } from '~/store/dialog/with-dialog';
-import { CollectionPartialCopyFields } from '../form-dialog/collection-form-dialog';
+import { CollectionPartialCopyFields } from '../collection-form-fields/collection-form-fields';
 import { FormDialog } from '~/components/form-dialog/form-dialog';
 import { COLLECTION_PARTIAL_COPY, doCollectionPartialCopy, CollectionPartialCopyFormData } from '~/store/collection-panel/collection-panel-files/collection-panel-files-actions';
 
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 e534382..1b94900 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
@@ -6,7 +6,7 @@ import { ContextMenuActionSet } from "../context-menu-action-set";
 import { ToggleFavoriteAction } from "../actions/favorite-action";
 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/collection-updater-actions";
+import { openUpdater } from "~/store/collections/collection-update-actions";
 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
 import { openMoveCollectionDialog } from '~/store/move-collection-dialog/move-collection-dialog';
 import { openProjectCopyDialog } from "~/store/project-copy-project-dialog/project-copy-project-dialog";
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 1baa641..989c8f1 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
@@ -6,7 +6,7 @@ import { ContextMenuActionSet } from "../context-menu-action-set";
 import { ToggleFavoriteAction } from "../actions/favorite-action";
 import { toggleFavorite } from "~/store/favorites/favorites-actions";
 import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, RemoveIcon } from "~/components/icon/icon";
-import { openUpdater } from "~/store/collections/collection-updater-actions";
+import { openUpdater } from "~/store/collections/collection-update-actions";
 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
 import { openMoveCollectionDialog } from '~/store/move-collection-dialog/move-collection-dialog';
 import { openProjectCopyDialog } from '~/store/project-copy-project-dialog/project-copy-project-dialog';
diff --git a/src/views-components/dialog-update/dialog-collection-update.tsx b/src/views-components/dialog-update/dialog-collection-update.tsx
index 31dd264..7b1d456 100644
--- a/src/views-components/dialog-update/dialog-collection-update.tsx
+++ b/src/views-components/dialog-update/dialog-collection-update.tsx
@@ -3,12 +3,11 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { InjectedFormProps, Field } from 'redux-form';
+import { InjectedFormProps } from 'redux-form';
 import { WithDialogProps } from '~/store/dialog/with-dialog';
-import { CollectionUpdateFormDialogData } from '~/store/collections/collection-updater-actions';
-import { COLLECTION_NAME_VALIDATION, COLLECTION_DESCRIPTION_VALIDATION } from '~/validators/validators';
-import { TextField } from '~/components/text-field/text-field';
+import { CollectionUpdateFormDialogData } from '~/store/collections/collection-update-actions';
 import { FormDialog } from '~/components/form-dialog/form-dialog';
+import { CollectionNameField, CollectionDescriptionField } from '~/views-components/collection-form-fields/collection-form-fields';
 
 type DialogCollectionProps = WithDialogProps<{}> & InjectedFormProps<CollectionUpdateFormDialogData>;
 
@@ -21,14 +20,6 @@ export const DialogCollectionUpdate = (props: DialogCollectionProps) =>
     />;
 
 const CollectionEditFields = () => <span>
-    <Field
-        name='name'
-        component={TextField}
-        validate={COLLECTION_NAME_VALIDATION}
-        label="Collection Name" />
-    <Field
-        name="description"
-        component={TextField}
-        validate={COLLECTION_DESCRIPTION_VALIDATION} 
-        label="Description - optional" />
+    <CollectionNameField />
+    <CollectionDescriptionField />
 </span>;
diff --git a/src/views-components/update-collection-dialog/update-collection-dialog.ts b/src/views-components/update-collection-dialog/update-collection-dialog.ts
index 3556472..7db45fa 100644
--- a/src/views-components/update-collection-dialog/update-collection-dialog.ts
+++ b/src/views-components/update-collection-dialog/update-collection-dialog.ts
@@ -6,7 +6,7 @@ import { compose } from "redux";
 import { reduxForm } from 'redux-form';
 import { withDialog } from "~/store/dialog/with-dialog";
 import { DialogCollectionUpdate } from '../dialog-update/dialog-collection-update';
-import { editCollection, COLLECTION_FORM_NAME, CollectionUpdateFormDialogData } from '~/store/collections/collection-updater-actions';
+import { editCollection, COLLECTION_FORM_NAME, CollectionUpdateFormDialogData } from '~/store/collections/collection-update-actions';
 
 export const UpdateCollectionDialog = compose(
     withDialog(COLLECTION_FORM_NAME),

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list