X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/467d932e354ea551cbff134ac50723bd56cea68d..0bc3340cdc59ede7a02552bcc9f22890f0ef4f91:/src/store/projects/project-create-actions.ts diff --git a/src/store/projects/project-create-actions.ts b/src/store/projects/project-create-actions.ts index 613e828d..ddcd233f 100644 --- a/src/store/projects/project-create-actions.ts +++ b/src/store/projects/project-create-actions.ts @@ -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'; @@ -16,12 +16,16 @@ export interface ProjectCreateFormDialogData { ownerUuid: string; name: string; description: string; - properties: { [key: string]: string }; + 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 CREATE_FORM_SELECTOR = formValueSelector(PROJECT_CREATE_FORM_NAME); +export const PROJECT_CREATE_FORM_SELECTOR = formValueSelector(PROJECT_CREATE_FORM_NAME); export const isProjectOrRunProcessRoute = ({ router }: RootState) => { const pathname = router.location ? router.location.pathname : ''; @@ -70,14 +74,14 @@ export const createProject = (project: Partial) => export const addPropertyToCreateProjectForm = (data: ResourcePropertiesFormData) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const properties = CREATE_FORM_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 properties = CREATE_FORM_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