Merge branch '14470-replace-tree-picker-in-copy-dialogs' into 14470-replace-tree...
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Thu, 15 Nov 2018 13:57:46 +0000 (14:57 +0100)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Thu, 15 Nov 2018 13:57:46 +0000 (14:57 +0100)
refs #14470
14470

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/store/collections/collection-copy-actions.ts
src/store/processes/process-copy-actions.ts
src/views-components/dialog-copy/dialog-copy.tsx
src/views-components/dialog-forms/copy-collection-dialog.ts
src/views-components/dialog-forms/copy-process-dialog.ts

index d0387609bd79af99e22630f83b218af2c842afbd..e5a6676c6b4dbc789199f589e3a5315ebe2ed199 100644 (file)
@@ -11,12 +11,14 @@ import { ServiceRepository } from '~/services/services';
 import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
 import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
+import { initProjectsTreePicker } from '~/store/tree-picker/tree-picker-actions';
 
 export const COLLECTION_COPY_FORM_NAME = 'collectionCopyFormName';
 
 export const openCollectionCopyDialog = (resource: { name: string, uuid: string }) =>
     (dispatch: Dispatch) => {
         dispatch<any>(resetPickerProjectTree());
+        dispatch<any>(initProjectsTreePicker(COLLECTION_COPY_FORM_NAME));
         const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, ownerUuid: '', uuid: resource.uuid };
         dispatch<any>(initialize(COLLECTION_COPY_FORM_NAME, initialData));
         dispatch(dialogActions.OPEN_DIALOG({ id: COLLECTION_COPY_FORM_NAME, data: {} }));
index bb8d8f5aeca95d9fd1c27de94817e99cc7251cc3..cd3fe21c28abb97d96334aa2c562202ba8202560 100644 (file)
@@ -11,6 +11,7 @@ import { ServiceRepository } from '~/services/services';
 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
 import { getProcess, ProcessStatus, getProcessStatus } from '~/store/processes/process';
 import { snackbarActions } from '~/store/snackbar/snackbar-actions';
+import { initProjectsTreePicker } from '~/store/tree-picker/tree-picker-actions';
 
 export const PROCESS_COPY_FORM_NAME = 'processCopyFormName';
 
@@ -21,6 +22,7 @@ export const openCopyProcessDialog = (resource: { name: string, uuid: string })
             const processStatus = getProcessStatus(process);
             if (processStatus === ProcessStatus.DRAFT) {
                 dispatch<any>(resetPickerProjectTree());
+                dispatch<any>(initProjectsTreePicker(PROCESS_COPY_FORM_NAME));
                 const initialData: CopyFormDialogData = { name: `Copy of: ${resource.name}`, uuid: resource.uuid, ownerUuid: '' };
                 dispatch<any>(initialize(PROCESS_COPY_FORM_NAME, initialData));
                 dispatch(dialogActions.OPEN_DIALOG({ id: PROCESS_COPY_FORM_NAME, data: {} }));
index 415541595c564ff1d3b672062852af92aaf25461..24e91dae81bb6f6f38457e386ddedcce2bef26a9 100644 (file)
@@ -3,6 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
+import { memoize } from 'lodash/fp';
 import { InjectedFormProps, Field } from 'redux-form';
 import { WithDialogProps } from '~/store/dialog/with-dialog';
 import { FormDialog } from '~/components/form-dialog/form-dialog';
@@ -13,22 +14,25 @@ import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
 
 type CopyFormDialogProps = WithDialogProps<string> & InjectedFormProps<CopyFormDialogData>;
 
-export const DialogCopy = (props: CopyFormDialogProps) =>
+export const DialogCopy = (props: CopyFormDialogProps & { pickerId: string }) =>
     <FormDialog
         dialogTitle='Make a copy'
-        formFields={CopyDialogFields}
+        formFields={CopyDialogFields(props.pickerId)}
         submitLabel='Copy'
         {...props}
     />;
 
-const CopyDialogFields = () => <span>
-    <Field
-        name='name'
-        component={TextField}
-        validate={COPY_NAME_VALIDATION}
-        label="Enter a new name for the copy" />
-    <Field
-        name="ownerUuid"
-        component={ProjectTreePickerField}
-        validate={COPY_FILE_VALIDATION} />
-</span>;
+const CopyDialogFields = memoize((pickerId: string) =>
+    () =>
+        <span>
+            <Field
+                name='name'
+                component={TextField}
+                validate={COPY_NAME_VALIDATION}
+                label="Enter a new name for the copy" />
+            <Field
+                name="ownerUuid"
+                component={ProjectTreePickerField}
+                validate={COPY_FILE_VALIDATION} 
+                pickerId={pickerId}/>
+        </span>);
index 41309fdff6952762ed9ae9d9c2922f53dc3e5082..3c8f7ebf537f4ed755ba2f380e9251a3a4f4d768 100644 (file)
@@ -9,6 +9,7 @@ import { COLLECTION_COPY_FORM_NAME } from '~/store/collections/collection-copy-a
 import { DialogCopy } from "~/views-components/dialog-copy/dialog-copy";
 import { copyCollection } from '~/store/workbench/workbench-actions';
 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
+import { pickerId } from '~/store/tree-picker/picker-id';
 
 export const CopyCollectionDialog = compose(
     withDialog(COLLECTION_COPY_FORM_NAME),
@@ -17,5 +18,6 @@ export const CopyCollectionDialog = compose(
         onSubmit: (data, dispatch) => {
             dispatch(copyCollection(data));
         }
-    })
+    }),
+    pickerId(COLLECTION_COPY_FORM_NAME),
 )(DialogCopy);
\ No newline at end of file
index 4ec17c65da870a95b4a0b5255652c66b141179e7..89d38f83388dcb712ebfe3b2bd8b961801925114 100644 (file)
@@ -9,6 +9,7 @@ import { PROCESS_COPY_FORM_NAME } from '~/store/processes/process-copy-actions';
 import { DialogCopy } from "~/views-components/dialog-copy/dialog-copy";
 import { copyProcess } from '~/store/workbench/workbench-actions';
 import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
+import { pickerId } from "~/store/tree-picker/picker-id";
 
 export const CopyProcessDialog = compose(
     withDialog(PROCESS_COPY_FORM_NAME),
@@ -17,5 +18,6 @@ export const CopyProcessDialog = compose(
         onSubmit: (data, dispatch) => {
             dispatch(copyProcess(data));
         }
-    })
+    }),
+    pickerId(PROCESS_COPY_FORM_NAME),
 )(DialogCopy);
\ No newline at end of file