cancel-running-workflow
[arvados-workbench2.git] / src / store / projects / project-create-actions.ts
index 625bd29e1db8725a3f6ca29c0f91a49f5e935de3..ddcd233fd5ad8053dbe60819bdfdf63f364335bb 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { Dispatch } from "redux";
-import { reset, startSubmit, stopSubmit, initialize, FormErrors, formValueSelector, change, arrayPush } from 'redux-form';
+import { reset, startSubmit, stopSubmit, initialize, FormErrors, formValueSelector, change } from 'redux-form';
 import { RootState } from '~/store/store';
 import { dialogActions } from "~/store/dialog/dialog-actions";
 import { getCommonResourceServiceError, CommonResourceServiceError } from '~/services/common-service/common-resource-service';
@@ -11,17 +11,21 @@ import { ProjectResource } from '~/models/project';
 import { ServiceRepository } from '~/services/services';
 import { matchProjectRoute, matchRunProcessRoute } from '~/routes/routes';
 import { ResourcePropertiesFormData } from '~/views-components/resource-properties-form/resource-properties-form';
-import { GraphChange } from '../../lib/cwl-svg/plugins/plugin';
 
 export interface ProjectCreateFormDialogData {
     ownerUuid: string;
     name: string;
     description: string;
-    properties: any;
+    properties: ProjectProperties;
+}
+
+export interface ProjectProperties {
+    [key: string]: string;
 }
 
 export const PROJECT_CREATE_FORM_NAME = 'projectCreateFormName';
 export const PROJECT_CREATE_PROPERTIES_FORM_NAME = 'projectCreatePropertiesFormName';
+export const PROJECT_CREATE_FORM_SELECTOR = formValueSelector(PROJECT_CREATE_FORM_NAME);
 
 export const isProjectOrRunProcessRoute = ({ router }: RootState) => {
     const pathname = router.location ? router.location.pathname : '';
@@ -70,16 +74,14 @@ export const createProject = (project: Partial<ProjectResource>) =>
 
 export const addPropertyToCreateProjectForm = (data: ResourcePropertiesFormData) =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const selector = formValueSelector(PROJECT_CREATE_FORM_NAME);
-        const properties = selector(getState(), 'properties') || {};
+        const properties = { ...PROJECT_CREATE_FORM_SELECTOR(getState(), 'properties') };
         properties[data.key] = data.value;
-        dispatch(change(PROJECT_CREATE_FORM_NAME, 'properties', {...properties } ));
+        dispatch(change(PROJECT_CREATE_FORM_NAME, 'properties', properties ));
     };
 
 export const removePropertyFromCreateProjectForm = (key: string) =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-        const selector = formValueSelector(PROJECT_CREATE_FORM_NAME);
-        const properties = selector(getState(), 'properties');
+        const properties = { ...PROJECT_CREATE_FORM_SELECTOR(getState(), 'properties') };
         delete properties[key];
-        dispatch(change(PROJECT_CREATE_FORM_NAME, 'properties', { ...properties } ));
+        dispatch(change(PROJECT_CREATE_FORM_NAME, 'properties', properties ));
     };
\ No newline at end of file