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: {} }));
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';
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: {} }));
// 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';
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>);
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),
onSubmit: (data, dispatch) => {
dispatch(copyCollection(data));
}
- })
+ }),
+ pickerId(COLLECTION_COPY_FORM_NAME),
)(DialogCopy);
\ No newline at end of file
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),
onSubmit: (data, dispatch) => {
dispatch(copyProcess(data));
}
- })
+ }),
+ pickerId(PROCESS_COPY_FORM_NAME),
)(DialogCopy);
\ No newline at end of file