[ARVADOS-WORKBENCH2] created: 2.3.0-121-gaa0a2249
Git user
git at public.arvados.org
Fri Dec 17 22:53:34 UTC 2021
at aa0a2249b6bf5b3e5b69034dfa5fab4b809ae6ce (commit)
commit aa0a2249b6bf5b3e5b69034dfa5fab4b809ae6ce
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Fri Dec 17 19:31:03 2021 -0300
18219: Unifies code for showing the list of properties on rsc forms.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/views-components/collection-properties/create-collection-properties-list.tsx b/src/views-components/collection-properties/create-collection-properties-list.tsx
deleted file mode 100644
index b6e02cb6..00000000
--- a/src/views-components/collection-properties/create-collection-properties-list.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import React from 'react';
-import { connect } from 'react-redux';
-import { Dispatch } from 'redux';
-import {
- withStyles,
- StyleRulesCallback,
- WithStyles,
-} from '@material-ui/core';
-import { RootState } from 'store/store';
-import {
- COLLECTION_CREATE_FORM_SELECTOR,
- CollectionProperties,
- COLLECTION_CREATE_FORM_NAME
-} from 'store/collections/collection-create-actions';
-import { ArvadosTheme } from 'common/custom-theme';
-import { getPropertyChip } from '../resource-properties-form/property-chip';
-import { removePropertyFromResourceForm } from 'store/resources/resources-actions';
-
-type CssRules = 'tag';
-
-const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
- tag: {
- marginRight: theme.spacing.unit,
- marginBottom: theme.spacing.unit
- }
-});
-
-interface CreateCollectionPropertiesListDataProps {
- properties: CollectionProperties;
-}
-
-interface CreateCollectionPropertiesListActionProps {
- handleDelete: (key: string, value: string) => void;
-}
-
-const mapStateToProps = (state: RootState): CreateCollectionPropertiesListDataProps => {
- const properties = COLLECTION_CREATE_FORM_SELECTOR(state, 'properties');
- return { properties };
-};
-
-const mapDispatchToProps = (dispatch: Dispatch): CreateCollectionPropertiesListActionProps => ({
- handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromResourceForm(key, value, COLLECTION_CREATE_FORM_NAME))
-});
-
-type CreateCollectionPropertiesListProps = CreateCollectionPropertiesListDataProps &
- CreateCollectionPropertiesListActionProps & WithStyles<CssRules>;
-
-const List = withStyles(styles)(
- ({ classes, handleDelete, properties }: CreateCollectionPropertiesListProps) =>
- <div>
- {properties &&
- Object.keys(properties).map(k =>
- Array.isArray(properties[k])
- ? (properties[k] as string[]).map((v: string) =>
- getPropertyChip(
- k, v,
- () => handleDelete(k, v),
- classes.tag))
- : getPropertyChip(
- k, (properties[k] as string),
- () => handleDelete(k, (properties[k] as string)),
- classes.tag))
- }
- </div>
-);
-
-export const CreateCollectionPropertiesList = connect(mapStateToProps, mapDispatchToProps)(List);
\ No newline at end of file
diff --git a/src/views-components/collection-properties/update-collection-properties-list.tsx b/src/views-components/collection-properties/update-collection-properties-list.tsx
deleted file mode 100644
index 792786f2..00000000
--- a/src/views-components/collection-properties/update-collection-properties-list.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import React from 'react';
-import { connect } from 'react-redux';
-import { Dispatch } from 'redux';
-import {
- withStyles,
- StyleRulesCallback,
- WithStyles,
-} from '@material-ui/core';
-import { RootState } from 'store/store';
-import {
- COLLECTION_UPDATE_FORM_SELECTOR,
- COLLECTION_UPDATE_FORM_NAME,
-} from 'store/collections/collection-update-actions';
-import { ArvadosTheme } from 'common/custom-theme';
-import { getPropertyChip } from '../resource-properties-form/property-chip';
-import { CollectionProperties } from 'store/collections/collection-create-actions';
-import { removePropertyFromResourceForm } from 'store/resources/resources-actions';
-
-type CssRules = 'tag';
-
-const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
- tag: {
- marginRight: theme.spacing.unit,
- marginBottom: theme.spacing.unit
- }
-});
-
-interface UpdateCollectionPropertiesListDataProps {
- properties: CollectionProperties;
-}
-
-interface UpdateCollectionPropertiesListActionProps {
- handleDelete: (key: string, value: string) => void;
-}
-
-const mapStateToProps = (state: RootState): UpdateCollectionPropertiesListDataProps => {
- const properties = COLLECTION_UPDATE_FORM_SELECTOR(state, 'properties');
- return { properties };
-};
-
-const mapDispatchToProps = (dispatch: Dispatch): UpdateCollectionPropertiesListActionProps => ({
- handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromResourceForm(key, value, COLLECTION_UPDATE_FORM_NAME))
-});
-
-type UpdateCollectionPropertiesListProps = UpdateCollectionPropertiesListDataProps &
- UpdateCollectionPropertiesListActionProps & WithStyles<CssRules>;
-
-const List = withStyles(styles)(
- ({ classes, handleDelete, properties }: UpdateCollectionPropertiesListProps) =>
- <div>
- {properties &&
- Object.keys(properties).map(k =>
- Array.isArray(properties[k])
- ? (properties[k] as string[]).map((v: string) =>
- getPropertyChip(
- k, v,
- () => handleDelete(k, v),
- classes.tag))
- : getPropertyChip(
- k, (properties[k] as string),
- () => handleDelete(k, (properties[k] as string)),
- classes.tag))
- }
- </div>
-);
-
-export const UpdateCollectionPropertiesList = connect(mapStateToProps, mapDispatchToProps)(List);
\ No newline at end of file
diff --git a/src/views-components/dialog-create/dialog-collection-create.tsx b/src/views-components/dialog-create/dialog-collection-create.tsx
index b75ad50f..163eb983 100644
--- a/src/views-components/dialog-create/dialog-collection-create.tsx
+++ b/src/views-components/dialog-create/dialog-collection-create.tsx
@@ -5,7 +5,7 @@
import React from 'react';
import { InjectedFormProps, Field } from 'redux-form';
import { WithDialogProps } from 'store/dialog/with-dialog';
-import { CollectionCreateFormDialogData } from 'store/collections/collection-create-actions';
+import { CollectionCreateFormDialogData, COLLECTION_CREATE_FORM_NAME } from 'store/collections/collection-create-actions';
import { FormDialog } from 'components/form-dialog/form-dialog';
import {
CollectionNameField,
@@ -14,9 +14,9 @@ import {
} from 'views-components/form-fields/collection-form-fields';
import { FileUploaderField } from '../file-uploader/file-uploader';
import { ResourceParentField } from '../form-fields/resource-form-fields';
-import { CreateCollectionPropertiesList } from 'views-components/collection-properties/create-collection-properties-list';
import { CreateCollectionPropertiesForm } from 'views-components/collection-properties/create-collection-properties-form';
import { FormGroup, FormLabel } from '@material-ui/core';
+import { resourcePropertiesList } from 'views-components/resource-properties/resource-properties-list';
type DialogCollectionProps = WithDialogProps<{}> & InjectedFormProps<CollectionCreateFormDialogData>;
@@ -28,6 +28,8 @@ export const DialogCollectionCreate = (props: DialogCollectionProps) =>
{...props}
/>;
+const CreateCollectionPropertiesList = resourcePropertiesList(COLLECTION_CREATE_FORM_NAME);
+
const CollectionAddFields = () => <span>
<ResourceParentField />
<CollectionNameField />
diff --git a/src/views-components/dialog-create/dialog-project-create.tsx b/src/views-components/dialog-create/dialog-project-create.tsx
index 81e9485c..34860599 100644
--- a/src/views-components/dialog-create/dialog-project-create.tsx
+++ b/src/views-components/dialog-create/dialog-project-create.tsx
@@ -5,13 +5,13 @@
import React from 'react';
import { InjectedFormProps } from 'redux-form';
import { WithDialogProps } from 'store/dialog/with-dialog';
-import { ProjectCreateFormDialogData } from 'store/projects/project-create-actions';
+import { ProjectCreateFormDialogData, PROJECT_CREATE_FORM_NAME } from 'store/projects/project-create-actions';
import { FormDialog } from 'components/form-dialog/form-dialog';
import { ProjectNameField, ProjectDescriptionField } from 'views-components/form-fields/project-form-fields';
import { CreateProjectPropertiesForm } from 'views-components/project-properties/create-project-properties-form';
-import { CreateProjectPropertiesList } from 'views-components/project-properties/create-project-properties-list';
import { ResourceParentField } from '../form-fields/resource-form-fields';
import { FormGroup, FormLabel } from '@material-ui/core';
+import { resourcePropertiesList } from 'views-components/resource-properties/resource-properties-list';
type DialogProjectProps = WithDialogProps<{}> & InjectedFormProps<ProjectCreateFormDialogData>;
@@ -23,6 +23,8 @@ export const DialogProjectCreate = (props: DialogProjectProps) =>
{...props}
/>;
+const CreateProjectPropertiesList = resourcePropertiesList(PROJECT_CREATE_FORM_NAME);
+
const ProjectAddFields = () => <span>
<ResourceParentField />
<ProjectNameField />
diff --git a/src/views-components/dialog-update/dialog-collection-update.tsx b/src/views-components/dialog-update/dialog-collection-update.tsx
index 5bdaa4f4..852dab1a 100644
--- a/src/views-components/dialog-update/dialog-collection-update.tsx
+++ b/src/views-components/dialog-update/dialog-collection-update.tsx
@@ -5,7 +5,7 @@
import React from 'react';
import { InjectedFormProps } from 'redux-form';
import { WithDialogProps } from 'store/dialog/with-dialog';
-import { CollectionUpdateFormDialogData } from 'store/collections/collection-update-actions';
+import { CollectionUpdateFormDialogData, COLLECTION_UPDATE_FORM_NAME } from 'store/collections/collection-update-actions';
import { FormDialog } from 'components/form-dialog/form-dialog';
import {
CollectionNameField,
@@ -13,8 +13,8 @@ import {
CollectionStorageClassesField
} from 'views-components/form-fields/collection-form-fields';
import { UpdateCollectionPropertiesForm } from 'views-components/collection-properties/update-collection-properties-form';
-import { UpdateCollectionPropertiesList } from 'views-components/collection-properties/update-collection-properties-list';
import { FormGroup, FormLabel } from '@material-ui/core';
+import { resourcePropertiesList } from 'views-components/resource-properties/resource-properties-list';
type DialogCollectionProps = WithDialogProps<{}> & InjectedFormProps<CollectionUpdateFormDialogData>;
@@ -26,6 +26,8 @@ export const DialogCollectionUpdate = (props: DialogCollectionProps) =>
{...props}
/>;
+const UpdateCollectionPropertiesList = resourcePropertiesList(COLLECTION_UPDATE_FORM_NAME);
+
const CollectionEditFields = () => <span>
<CollectionNameField />
<CollectionDescriptionField />
diff --git a/src/views-components/dialog-update/dialog-project-update.tsx b/src/views-components/dialog-update/dialog-project-update.tsx
index 96e6d927..9737858a 100644
--- a/src/views-components/dialog-update/dialog-project-update.tsx
+++ b/src/views-components/dialog-update/dialog-project-update.tsx
@@ -5,13 +5,13 @@
import React from 'react';
import { InjectedFormProps } from 'redux-form';
import { WithDialogProps } from 'store/dialog/with-dialog';
-import { ProjectUpdateFormDialogData } from 'store/projects/project-update-actions';
+import { ProjectUpdateFormDialogData, PROJECT_UPDATE_FORM_NAME } from 'store/projects/project-update-actions';
import { FormDialog } from 'components/form-dialog/form-dialog';
import { ProjectNameField, ProjectDescriptionField, UsersField } from 'views-components/form-fields/project-form-fields';
import { GroupClass } from 'models/group';
import { FormGroup, FormLabel } from '@material-ui/core';
import { UpdateProjectPropertiesForm } from 'views-components/project-properties/update-project-properties-form';
-import { UpdateProjectPropertiesList } from 'views-components/project-properties/update-project-properties-list';
+import { resourcePropertiesList } from 'views-components/resource-properties/resource-properties-list';
type DialogProjectProps = WithDialogProps<{sourcePanel: GroupClass, create?: boolean}> & InjectedFormProps<ProjectUpdateFormDialogData>;
@@ -34,6 +34,8 @@ export const DialogProjectUpdate = (props: DialogProjectProps) => {
/>;
};
+const UpdateProjectPropertiesList = resourcePropertiesList(PROJECT_UPDATE_FORM_NAME);
+
// Also used as "Group Edit Fields"
const ProjectEditFields = () => <span>
<ProjectNameField />
diff --git a/src/views-components/project-properties/update-project-properties-list.tsx b/src/views-components/project-properties/update-project-properties-list.tsx
deleted file mode 100644
index 5ac22b92..00000000
--- a/src/views-components/project-properties/update-project-properties-list.tsx
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import React from 'react';
-import { connect } from 'react-redux';
-import { Dispatch } from 'redux';
-import {
- withStyles,
- StyleRulesCallback,
- WithStyles,
-} from '@material-ui/core';
-import { RootState } from 'store/store';
-import {
- PROJECT_UPDATE_FORM_SELECTOR,
- PROJECT_UPDATE_FORM_NAME,
-} from 'store/projects/project-update-actions';
-import { ArvadosTheme } from 'common/custom-theme';
-import { getPropertyChip } from '../resource-properties-form/property-chip';
-import { ProjectProperties } from 'store/projects/project-create-actions';
-import { removePropertyFromResourceForm } from 'store/resources/resources-actions';
-
-type CssRules = 'tag';
-
-const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
- tag: {
- marginRight: theme.spacing.unit,
- marginBottom: theme.spacing.unit
- }
-});
-
-interface UpdateProjectPropertiesListDataProps {
- properties: ProjectProperties;
-}
-
-interface UpdateProjectPropertiesListActionProps {
- handleDelete: (key: string, value: string) => void;
-}
-
-const mapStateToProps = (state: RootState): UpdateProjectPropertiesListDataProps => {
- const properties = PROJECT_UPDATE_FORM_SELECTOR(state, 'properties');
- return { properties };
-};
-
-const mapDispatchToProps = (dispatch: Dispatch): UpdateProjectPropertiesListActionProps => ({
- handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromResourceForm(key, value, PROJECT_UPDATE_FORM_NAME))
-});
-
-type UpdateProjectPropertiesListProps = UpdateProjectPropertiesListDataProps &
- UpdateProjectPropertiesListActionProps & WithStyles<CssRules>;
-
-const List = withStyles(styles)(
- ({ classes, handleDelete, properties }: UpdateProjectPropertiesListProps) =>
- <div>
- {properties &&
- Object.keys(properties).map(k =>
- Array.isArray(properties[k])
- ? (properties[k] as string[]).map((v: string) =>
- getPropertyChip(
- k, v,
- () => handleDelete(k, v),
- classes.tag))
- : getPropertyChip(
- k, (properties[k] as string),
- () => handleDelete(k, (properties[k] as string)),
- classes.tag))
- }
- </div>
-);
-
-export const UpdateProjectPropertiesList = connect(mapStateToProps, mapDispatchToProps)(List);
\ No newline at end of file
diff --git a/src/views-components/project-properties/create-project-properties-list.tsx b/src/views-components/resource-properties/resource-properties-list.tsx
similarity index 58%
rename from src/views-components/project-properties/create-project-properties-list.tsx
rename to src/views-components/resource-properties/resource-properties-list.tsx
index ac7dc6fd..a7b58252 100644
--- a/src/views-components/project-properties/create-project-properties-list.tsx
+++ b/src/views-components/resource-properties/resource-properties-list.tsx
@@ -11,14 +11,10 @@ import {
WithStyles,
} from '@material-ui/core';
import { RootState } from 'store/store';
-import {
- PROJECT_CREATE_FORM_SELECTOR,
- ProjectProperties,
- PROJECT_CREATE_FORM_NAME
-} from 'store/projects/project-create-actions';
import { ArvadosTheme } from 'common/custom-theme';
import { getPropertyChip } from '../resource-properties-form/property-chip';
import { removePropertyFromResourceForm } from 'store/resources/resources-actions';
+import { formValueSelector } from 'redux-form';
type CssRules = 'tag';
@@ -29,28 +25,19 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
}
});
-interface CreateProjectPropertiesListDataProps {
- properties: ProjectProperties;
+interface ResourcePropertiesListDataProps {
+ properties: {[key: string]: string | string[]};
}
-interface CreateProjectPropertiesListActionProps {
+interface ResourcePropertiesListActionProps {
handleDelete: (key: string, value: string) => void;
}
-const mapStateToProps = (state: RootState): CreateProjectPropertiesListDataProps => {
- const properties = PROJECT_CREATE_FORM_SELECTOR(state, 'properties');
- return { properties };
-};
-
-const mapDispatchToProps = (dispatch: Dispatch): CreateProjectPropertiesListActionProps => ({
- handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromResourceForm(key, value, PROJECT_CREATE_FORM_NAME))
-});
-
-type CreateProjectPropertiesListProps = CreateProjectPropertiesListDataProps &
- CreateProjectPropertiesListActionProps & WithStyles<CssRules>;
+type ResourcePropertiesListProps = ResourcePropertiesListDataProps &
+ResourcePropertiesListActionProps & WithStyles<CssRules>;
const List = withStyles(styles)(
- ({ classes, handleDelete, properties }: CreateProjectPropertiesListProps) =>
+ ({ classes, handleDelete, properties }: ResourcePropertiesListProps) =>
<div>
{properties &&
Object.keys(properties).map(k =>
@@ -68,4 +55,12 @@ const List = withStyles(styles)(
</div>
);
-export const CreateProjectPropertiesList = connect(mapStateToProps, mapDispatchToProps)(List);
\ No newline at end of file
+export const resourcePropertiesList = (formName: string) =>
+ connect(
+ (state: RootState): ResourcePropertiesListDataProps => ({
+ properties: formValueSelector(formName)(state, 'properties')
+ }),
+ (dispatch: Dispatch): ResourcePropertiesListActionProps => ({
+ handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromResourceForm(key, value, formName))
+ })
+ )(List);
\ No newline at end of file
commit 6521d10377432141aaec5408dbfba2952bf0656e
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Fri Dec 17 18:46:12 2021 -0300
18219: Unifies collection/project create/update properties handling actions.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts
index 22202b15..17fecc1e 100644
--- a/src/store/collections/collection-create-actions.ts
+++ b/src/store/collections/collection-create-actions.ts
@@ -3,7 +3,14 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { reset, startSubmit, stopSubmit, initialize, FormErrors, change, formValueSelector } from 'redux-form';
+import {
+ reset,
+ startSubmit,
+ stopSubmit,
+ initialize,
+ FormErrors,
+ formValueSelector
+} from 'redux-form';
import { RootState } from 'store/store';
import { getUserUuid } from "common/getuser";
import { dialogActions } from "store/dialog/dialog-actions";
@@ -15,8 +22,6 @@ import { progressIndicatorActions } from "store/progress-indicator/progress-indi
import { isProjectOrRunProcessRoute } from 'store/projects/project-create-actions';
import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
import { CollectionResource } from "models/collection";
-import { ResourcePropertiesFormData } from "views-components/resource-properties-form/resource-properties-form";
-import { addProperty, deleteProperty } from "lib/resource-properties";
export interface CollectionCreateFormDialogData {
ownerUuid: string;
@@ -78,23 +83,3 @@ export const createCollection = (data: CollectionCreateFormDialogData) =>
dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_CREATE_FORM_NAME));
}
};
-
-export const addPropertyToCreateCollectionForm = (data: ResourcePropertiesFormData) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const properties = { ...COLLECTION_CREATE_FORM_SELECTOR(getState(), 'properties') };
- const key = data.keyID || data.key;
- const value = data.valueID || data.value;
- dispatch(change(
- COLLECTION_CREATE_FORM_NAME,
- 'properties',
- addProperty(properties, key, value)));
- };
-
-export const removePropertyFromCreateCollectionForm = (key: string, value: string) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const properties = { ...COLLECTION_CREATE_FORM_SELECTOR(getState(), 'properties') };
- dispatch(change(
- COLLECTION_CREATE_FORM_NAME,
- 'properties',
- deleteProperty(properties, key, value)));
- };
diff --git a/src/store/collections/collection-update-actions.ts b/src/store/collections/collection-update-actions.ts
index 0096bc48..2caaf88a 100644
--- a/src/store/collections/collection-update-actions.ts
+++ b/src/store/collections/collection-update-actions.ts
@@ -4,7 +4,6 @@
import { Dispatch } from "redux";
import {
- change,
FormErrors,
formValueSelector,
initialize,
@@ -23,8 +22,6 @@ import { updateResources } from "../resources/resources-actions";
import { loadDetailsPanel } from "../details-panel/details-panel-action";
import { getResource } from "store/resources/resources";
import { CollectionProperties } from "./collection-create-actions";
-import { ResourcePropertiesFormData } from "views-components/resource-properties-form/resource-properties-form";
-import { addProperty, deleteProperty } from "lib/resource-properties";
export interface CollectionUpdateFormDialogData {
uuid: string;
@@ -83,23 +80,3 @@ export const updateCollection = (collection: CollectionUpdateFormDialogData) =>
}
);
};
-
-export const addPropertyToUpdateCollectionForm = (data: ResourcePropertiesFormData) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const properties = { ...COLLECTION_UPDATE_FORM_SELECTOR(getState(), 'properties') };
- const key = data.keyID || data.key;
- const value = data.valueID || data.value;
- dispatch(change(
- COLLECTION_UPDATE_FORM_NAME,
- 'properties',
- addProperty(properties, key, value)));
- };
-
-export const removePropertyFromUpdateCollectionForm = (key: string, value: string) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const properties = { ...COLLECTION_UPDATE_FORM_SELECTOR(getState(), 'properties') };
- dispatch(change(
- COLLECTION_UPDATE_FORM_NAME,
- 'properties',
- deleteProperty(properties, key, value)));
- };
diff --git a/src/store/projects/project-create-actions.ts b/src/store/projects/project-create-actions.ts
index 352759fa..c7d17c51 100644
--- a/src/store/projects/project-create-actions.ts
+++ b/src/store/projects/project-create-actions.ts
@@ -3,7 +3,14 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { reset, startSubmit, stopSubmit, initialize, FormErrors, formValueSelector, change } from 'redux-form';
+import {
+ reset,
+ startSubmit,
+ stopSubmit,
+ initialize,
+ FormErrors,
+ formValueSelector
+} from 'redux-form';
import { RootState } from 'store/store';
import { getUserUuid } from "common/getuser";
import { dialogActions } from "store/dialog/dialog-actions";
@@ -11,9 +18,7 @@ import { getCommonResourceServiceError, CommonResourceServiceError } from 'servi
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 { RouterState } from "react-router-redux";
-import { addProperty, deleteProperty } from "lib/resource-properties";
export interface ProjectCreateFormDialogData {
ownerUuid: string;
@@ -66,23 +71,3 @@ export const createProject = (project: Partial<ProjectResource>) =>
return undefined;
}
};
-
-export const addPropertyToCreateProjectForm = (data: ResourcePropertiesFormData) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const properties = { ...PROJECT_CREATE_FORM_SELECTOR(getState(), 'properties') };
- const key = data.keyID || data.key;
- const value = data.valueID || data.value;
- dispatch(change(
- PROJECT_CREATE_FORM_NAME,
- 'properties',
- addProperty(properties, key, value)));
- };
-
-export const removePropertyFromCreateProjectForm = (key: string, value: string) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const properties = { ...PROJECT_CREATE_FORM_SELECTOR(getState(), 'properties') };
- dispatch(change(
- PROJECT_CREATE_FORM_NAME,
- 'properties',
- deleteProperty(properties, key, value)));
- };
diff --git a/src/store/projects/project-update-actions.ts b/src/store/projects/project-update-actions.ts
index e5fc34d8..36f66ccf 100644
--- a/src/store/projects/project-update-actions.ts
+++ b/src/store/projects/project-update-actions.ts
@@ -4,7 +4,6 @@
import { Dispatch } from "redux";
import {
- change,
FormErrors,
formValueSelector,
initialize,
@@ -22,8 +21,6 @@ import { ServiceRepository } from "services/services";
import { projectPanelActions } from 'store/project-panel/project-panel-action';
import { GroupClass } from "models/group";
import { Participant } from "views-components/sharing-dialog/participant-select";
-import { ResourcePropertiesFormData } from "views-components/resource-properties-form/resource-properties-form";
-import { addProperty, deleteProperty } from "lib/resource-properties";
import { ProjectProperties } from "./project-create-actions";
export interface ProjectUpdateFormDialogData {
@@ -68,23 +65,3 @@ export const updateProject = (project: ProjectUpdateFormDialogData) =>
return ;
}
};
-
-export const addPropertyToUpdateProjectForm = (data: ResourcePropertiesFormData) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const properties = { ...PROJECT_UPDATE_FORM_SELECTOR(getState(), 'properties') };
- const key = data.keyID || data.key;
- const value = data.valueID || data.value;
- dispatch(change(
- PROJECT_UPDATE_FORM_NAME,
- 'properties',
- addProperty(properties, key, value)));
- };
-
-export const removePropertyFromUpdateProjectForm = (key: string, value: string) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const properties = { ...PROJECT_UPDATE_FORM_SELECTOR(getState(), 'properties') };
- dispatch(change(
- PROJECT_UPDATE_FORM_NAME,
- 'properties',
- deleteProperty(properties, key, value)));
- };
diff --git a/src/store/resources/resources-actions.ts b/src/store/resources/resources-actions.ts
index 8e6d16f9..1d1355a8 100644
--- a/src/store/resources/resources-actions.ts
+++ b/src/store/resources/resources-actions.ts
@@ -12,6 +12,8 @@ import { addProperty, deleteProperty } from 'lib/resource-properties';
import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
import { getResource } from './resources';
import { TagProperty } from 'models/tag';
+import { change, formValueSelector } from 'redux-form';
+import { ResourcePropertiesFormData } from 'views-components/resource-properties-form/resource-properties-form';
export const resourcesActions = unionize({
SET_RESOURCES: ofType<Resource[]>(),
@@ -93,3 +95,23 @@ export const createResourceProperty = (data: TagProperty) =>
dispatch(snackbarActions.OPEN_SNACKBAR({ message: errorMsg, hideDuration: 2000, kind: SnackbarKind.ERROR }));
}
};
+
+export const addPropertyToResourceForm = (data: ResourcePropertiesFormData, formName: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const properties = { ...formValueSelector(formName)(getState(), 'properties') };
+ const key = data.keyID || data.key;
+ const value = data.valueID || data.value;
+ dispatch(change(
+ formName,
+ 'properties',
+ addProperty(properties, key, value)));
+ };
+
+export const removePropertyFromResourceForm = (key: string, value: string, formName: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const properties = { ...formValueSelector(formName)(getState(), 'properties') };
+ dispatch(change(
+ formName,
+ 'properties',
+ deleteProperty(properties, key, value)));
+ };
diff --git a/src/views-components/collection-properties/create-collection-properties-form.tsx b/src/views-components/collection-properties/create-collection-properties-form.tsx
index 8e3f8eb8..ab389ddc 100644
--- a/src/views-components/collection-properties/create-collection-properties-form.tsx
+++ b/src/views-components/collection-properties/create-collection-properties-form.tsx
@@ -6,12 +6,13 @@ import { reduxForm, reset } from 'redux-form';
import { withStyles } from '@material-ui/core';
import {
COLLECTION_CREATE_PROPERTIES_FORM_NAME,
- addPropertyToCreateCollectionForm
+ COLLECTION_CREATE_FORM_NAME
} from 'store/collections/collection-create-actions';
import {
ResourcePropertiesForm,
ResourcePropertiesFormData
} from 'views-components/resource-properties-form/resource-properties-form';
+import { addPropertyToResourceForm } from 'store/resources/resources-actions';
const Form = withStyles(
({ spacing }) => (
@@ -26,7 +27,7 @@ const Form = withStyles(
export const CreateCollectionPropertiesForm = reduxForm<ResourcePropertiesFormData>({
form: COLLECTION_CREATE_PROPERTIES_FORM_NAME,
onSubmit: (data, dispatch) => {
- dispatch(addPropertyToCreateCollectionForm(data));
+ dispatch(addPropertyToResourceForm(data, COLLECTION_CREATE_FORM_NAME));
dispatch(reset(COLLECTION_CREATE_PROPERTIES_FORM_NAME));
}
})(Form);
\ No newline at end of file
diff --git a/src/views-components/collection-properties/create-collection-properties-list.tsx b/src/views-components/collection-properties/create-collection-properties-list.tsx
index 9784b55e..b6e02cb6 100644
--- a/src/views-components/collection-properties/create-collection-properties-list.tsx
+++ b/src/views-components/collection-properties/create-collection-properties-list.tsx
@@ -12,12 +12,13 @@ import {
} from '@material-ui/core';
import { RootState } from 'store/store';
import {
- removePropertyFromCreateCollectionForm,
COLLECTION_CREATE_FORM_SELECTOR,
- CollectionProperties
+ CollectionProperties,
+ COLLECTION_CREATE_FORM_NAME
} from 'store/collections/collection-create-actions';
import { ArvadosTheme } from 'common/custom-theme';
import { getPropertyChip } from '../resource-properties-form/property-chip';
+import { removePropertyFromResourceForm } from 'store/resources/resources-actions';
type CssRules = 'tag';
@@ -42,7 +43,7 @@ const mapStateToProps = (state: RootState): CreateCollectionPropertiesListDataPr
};
const mapDispatchToProps = (dispatch: Dispatch): CreateCollectionPropertiesListActionProps => ({
- handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromCreateCollectionForm(key, value))
+ handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromResourceForm(key, value, COLLECTION_CREATE_FORM_NAME))
});
type CreateCollectionPropertiesListProps = CreateCollectionPropertiesListDataProps &
diff --git a/src/views-components/collection-properties/update-collection-properties-form.tsx b/src/views-components/collection-properties/update-collection-properties-form.tsx
index dc00de30..13a29ad4 100644
--- a/src/views-components/collection-properties/update-collection-properties-form.tsx
+++ b/src/views-components/collection-properties/update-collection-properties-form.tsx
@@ -5,13 +5,13 @@
import { reduxForm, reset } from 'redux-form';
import { withStyles } from '@material-ui/core';
import {
- addPropertyToUpdateCollectionForm,
COLLECTION_UPDATE_PROPERTIES_FORM_NAME
} from 'store/collections/collection-update-actions';
import {
ResourcePropertiesForm,
ResourcePropertiesFormData
} from 'views-components/resource-properties-form/resource-properties-form';
+import { addPropertyToResourceForm } from 'store/resources/resources-actions';
const Form = withStyles(
({ spacing }) => (
@@ -26,7 +26,7 @@ const Form = withStyles(
export const UpdateCollectionPropertiesForm = reduxForm<ResourcePropertiesFormData>({
form: COLLECTION_UPDATE_PROPERTIES_FORM_NAME,
onSubmit: (data, dispatch) => {
- dispatch(addPropertyToUpdateCollectionForm(data));
+ dispatch(addPropertyToResourceForm(data, COLLECTION_UPDATE_PROPERTIES_FORM_NAME));
dispatch(reset(COLLECTION_UPDATE_PROPERTIES_FORM_NAME));
}
})(Form);
\ No newline at end of file
diff --git a/src/views-components/collection-properties/update-collection-properties-list.tsx b/src/views-components/collection-properties/update-collection-properties-list.tsx
index 26cf5e70..792786f2 100644
--- a/src/views-components/collection-properties/update-collection-properties-list.tsx
+++ b/src/views-components/collection-properties/update-collection-properties-list.tsx
@@ -12,12 +12,13 @@ import {
} from '@material-ui/core';
import { RootState } from 'store/store';
import {
- removePropertyFromUpdateCollectionForm,
COLLECTION_UPDATE_FORM_SELECTOR,
+ COLLECTION_UPDATE_FORM_NAME,
} from 'store/collections/collection-update-actions';
import { ArvadosTheme } from 'common/custom-theme';
import { getPropertyChip } from '../resource-properties-form/property-chip';
import { CollectionProperties } from 'store/collections/collection-create-actions';
+import { removePropertyFromResourceForm } from 'store/resources/resources-actions';
type CssRules = 'tag';
@@ -42,7 +43,7 @@ const mapStateToProps = (state: RootState): UpdateCollectionPropertiesListDataPr
};
const mapDispatchToProps = (dispatch: Dispatch): UpdateCollectionPropertiesListActionProps => ({
- handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromUpdateCollectionForm(key, value))
+ handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromResourceForm(key, value, COLLECTION_UPDATE_FORM_NAME))
});
type UpdateCollectionPropertiesListProps = UpdateCollectionPropertiesListDataProps &
diff --git a/src/views-components/project-properties/create-project-properties-form.tsx b/src/views-components/project-properties/create-project-properties-form.tsx
index c49d738a..aa9965b5 100644
--- a/src/views-components/project-properties/create-project-properties-form.tsx
+++ b/src/views-components/project-properties/create-project-properties-form.tsx
@@ -6,12 +6,13 @@ import { reduxForm, reset } from 'redux-form';
import { withStyles } from '@material-ui/core';
import {
PROJECT_CREATE_PROPERTIES_FORM_NAME,
- addPropertyToCreateProjectForm
+ PROJECT_CREATE_FORM_NAME
} from 'store/projects/project-create-actions';
import {
ResourcePropertiesForm,
ResourcePropertiesFormData
} from 'views-components/resource-properties-form/resource-properties-form';
+import { addPropertyToResourceForm } from 'store/resources/resources-actions';
const Form = withStyles(
({ spacing }) => (
@@ -26,7 +27,7 @@ const Form = withStyles(
export const CreateProjectPropertiesForm = reduxForm<ResourcePropertiesFormData>({
form: PROJECT_CREATE_PROPERTIES_FORM_NAME,
onSubmit: (data, dispatch) => {
- dispatch(addPropertyToCreateProjectForm(data));
+ dispatch(addPropertyToResourceForm(data, PROJECT_CREATE_FORM_NAME));
dispatch(reset(PROJECT_CREATE_PROPERTIES_FORM_NAME));
}
})(Form);
\ No newline at end of file
diff --git a/src/views-components/project-properties/create-project-properties-list.tsx b/src/views-components/project-properties/create-project-properties-list.tsx
index 8a61dcf7..ac7dc6fd 100644
--- a/src/views-components/project-properties/create-project-properties-list.tsx
+++ b/src/views-components/project-properties/create-project-properties-list.tsx
@@ -11,9 +11,14 @@ import {
WithStyles,
} from '@material-ui/core';
import { RootState } from 'store/store';
-import { removePropertyFromCreateProjectForm, PROJECT_CREATE_FORM_SELECTOR, ProjectProperties } from 'store/projects/project-create-actions';
+import {
+ PROJECT_CREATE_FORM_SELECTOR,
+ ProjectProperties,
+ PROJECT_CREATE_FORM_NAME
+} from 'store/projects/project-create-actions';
import { ArvadosTheme } from 'common/custom-theme';
import { getPropertyChip } from '../resource-properties-form/property-chip';
+import { removePropertyFromResourceForm } from 'store/resources/resources-actions';
type CssRules = 'tag';
@@ -38,7 +43,7 @@ const mapStateToProps = (state: RootState): CreateProjectPropertiesListDataProps
};
const mapDispatchToProps = (dispatch: Dispatch): CreateProjectPropertiesListActionProps => ({
- handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromCreateProjectForm(key, value))
+ handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromResourceForm(key, value, PROJECT_CREATE_FORM_NAME))
});
type CreateProjectPropertiesListProps = CreateProjectPropertiesListDataProps &
diff --git a/src/views-components/project-properties/update-project-properties-form.tsx b/src/views-components/project-properties/update-project-properties-form.tsx
index e6e78e34..e6151229 100644
--- a/src/views-components/project-properties/update-project-properties-form.tsx
+++ b/src/views-components/project-properties/update-project-properties-form.tsx
@@ -6,12 +6,13 @@ import { reduxForm, reset } from 'redux-form';
import { withStyles } from '@material-ui/core';
import {
PROJECT_UPDATE_PROPERTIES_FORM_NAME,
- addPropertyToUpdateProjectForm
+ PROJECT_UPDATE_FORM_NAME
} from 'store/projects/project-update-actions';
import {
ResourcePropertiesForm,
ResourcePropertiesFormData
} from 'views-components/resource-properties-form/resource-properties-form';
+import { addPropertyToResourceForm } from 'store/resources/resources-actions';
const Form = withStyles(
({ spacing }) => (
@@ -26,7 +27,7 @@ const Form = withStyles(
export const UpdateProjectPropertiesForm = reduxForm<ResourcePropertiesFormData>({
form: PROJECT_UPDATE_PROPERTIES_FORM_NAME,
onSubmit: (data, dispatch) => {
- dispatch(addPropertyToUpdateProjectForm(data));
+ dispatch(addPropertyToResourceForm(data, PROJECT_UPDATE_FORM_NAME));
dispatch(reset(PROJECT_UPDATE_PROPERTIES_FORM_NAME));
}
})(Form);
\ No newline at end of file
diff --git a/src/views-components/project-properties/update-project-properties-list.tsx b/src/views-components/project-properties/update-project-properties-list.tsx
index 5572af73..5ac22b92 100644
--- a/src/views-components/project-properties/update-project-properties-list.tsx
+++ b/src/views-components/project-properties/update-project-properties-list.tsx
@@ -12,12 +12,13 @@ import {
} from '@material-ui/core';
import { RootState } from 'store/store';
import {
- removePropertyFromUpdateProjectForm,
PROJECT_UPDATE_FORM_SELECTOR,
+ PROJECT_UPDATE_FORM_NAME,
} from 'store/projects/project-update-actions';
import { ArvadosTheme } from 'common/custom-theme';
import { getPropertyChip } from '../resource-properties-form/property-chip';
import { ProjectProperties } from 'store/projects/project-create-actions';
+import { removePropertyFromResourceForm } from 'store/resources/resources-actions';
type CssRules = 'tag';
@@ -42,7 +43,7 @@ const mapStateToProps = (state: RootState): UpdateProjectPropertiesListDataProps
};
const mapDispatchToProps = (dispatch: Dispatch): UpdateProjectPropertiesListActionProps => ({
- handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromUpdateProjectForm(key, value))
+ handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromResourceForm(key, value, PROJECT_UPDATE_FORM_NAME))
});
type UpdateProjectPropertiesListProps = UpdateProjectPropertiesListDataProps &
commit 40b55e355fe0a206a4cb3eec676e44d935b7d5ec
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Fri Dec 17 18:03:14 2021 -0300
18219: Adds property edition capabilities to create & update dialogs.
There's too much code duplication. Some might be simple to avoid.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/store/collections/collection-create-actions.ts b/src/store/collections/collection-create-actions.ts
index 81d8948c..22202b15 100644
--- a/src/store/collections/collection-create-actions.ts
+++ b/src/store/collections/collection-create-actions.ts
@@ -3,7 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { reset, startSubmit, stopSubmit, initialize, FormErrors } from 'redux-form';
+import { reset, startSubmit, stopSubmit, initialize, FormErrors, change, formValueSelector } from 'redux-form';
import { RootState } from 'store/store';
import { getUserUuid } from "common/getuser";
import { dialogActions } from "store/dialog/dialog-actions";
@@ -15,15 +15,24 @@ import { progressIndicatorActions } from "store/progress-indicator/progress-indi
import { isProjectOrRunProcessRoute } from 'store/projects/project-create-actions';
import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
import { CollectionResource } from "models/collection";
+import { ResourcePropertiesFormData } from "views-components/resource-properties-form/resource-properties-form";
+import { addProperty, deleteProperty } from "lib/resource-properties";
export interface CollectionCreateFormDialogData {
ownerUuid: string;
name: string;
description: string;
storageClassesDesired: string[];
+ properties: CollectionProperties;
+}
+
+export interface CollectionProperties {
+ [key: string]: string | string[];
}
export const COLLECTION_CREATE_FORM_NAME = "collectionCreateFormName";
+export const COLLECTION_CREATE_PROPERTIES_FORM_NAME = "collectionCreatePropertiesFormName";
+export const COLLECTION_CREATE_FORM_SELECTOR = formValueSelector(COLLECTION_CREATE_FORM_NAME);
export const openCollectionCreateDialog = (ownerUuid: string) =>
(dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
@@ -69,3 +78,23 @@ export const createCollection = (data: CollectionCreateFormDialogData) =>
dispatch(progressIndicatorActions.STOP_WORKING(COLLECTION_CREATE_FORM_NAME));
}
};
+
+export const addPropertyToCreateCollectionForm = (data: ResourcePropertiesFormData) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const properties = { ...COLLECTION_CREATE_FORM_SELECTOR(getState(), 'properties') };
+ const key = data.keyID || data.key;
+ const value = data.valueID || data.value;
+ dispatch(change(
+ COLLECTION_CREATE_FORM_NAME,
+ 'properties',
+ addProperty(properties, key, value)));
+ };
+
+export const removePropertyFromCreateCollectionForm = (key: string, value: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const properties = { ...COLLECTION_CREATE_FORM_SELECTOR(getState(), 'properties') };
+ dispatch(change(
+ COLLECTION_CREATE_FORM_NAME,
+ 'properties',
+ deleteProperty(properties, key, value)));
+ };
diff --git a/src/store/collections/collection-update-actions.ts b/src/store/collections/collection-update-actions.ts
index 04f42b8d..0096bc48 100644
--- a/src/store/collections/collection-update-actions.ts
+++ b/src/store/collections/collection-update-actions.ts
@@ -3,7 +3,14 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { FormErrors, initialize, startSubmit, stopSubmit } from 'redux-form';
+import {
+ change,
+ FormErrors,
+ formValueSelector,
+ initialize,
+ startSubmit,
+ stopSubmit
+} from 'redux-form';
import { RootState } from "store/store";
import { collectionPanelActions } from "store/collection-panel/collection-panel-action";
import { dialogActions } from "store/dialog/dialog-actions";
@@ -15,15 +22,21 @@ import { snackbarActions, SnackbarKind } from "../snackbar/snackbar-actions";
import { updateResources } from "../resources/resources-actions";
import { loadDetailsPanel } from "../details-panel/details-panel-action";
import { getResource } from "store/resources/resources";
+import { CollectionProperties } from "./collection-create-actions";
+import { ResourcePropertiesFormData } from "views-components/resource-properties-form/resource-properties-form";
+import { addProperty, deleteProperty } from "lib/resource-properties";
export interface CollectionUpdateFormDialogData {
uuid: string;
name: string;
description?: string;
storageClassesDesired?: string[];
+ properties?: CollectionProperties;
}
export const COLLECTION_UPDATE_FORM_NAME = 'collectionUpdateFormName';
+export const COLLECTION_UPDATE_PROPERTIES_FORM_NAME = "collectionCreatePropertiesFormName";
+export const COLLECTION_UPDATE_FORM_SELECTOR = formValueSelector(COLLECTION_UPDATE_FORM_NAME);
export const openCollectionUpdateDialog = (resource: CollectionUpdateFormDialogData) =>
(dispatch: Dispatch) => {
@@ -41,7 +54,8 @@ export const updateCollection = (collection: CollectionUpdateFormDialogData) =>
services.collectionService.update(uuid, {
name: collection.name,
storageClassesDesired: collection.storageClassesDesired,
- description: collection.description }
+ description: collection.description,
+ properties: collection.properties }
).then(updatedCollection => {
updatedCollection = {...cachedCollection, ...updatedCollection};
dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: updatedCollection as CollectionResource }));
@@ -69,3 +83,23 @@ export const updateCollection = (collection: CollectionUpdateFormDialogData) =>
}
);
};
+
+export const addPropertyToUpdateCollectionForm = (data: ResourcePropertiesFormData) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const properties = { ...COLLECTION_UPDATE_FORM_SELECTOR(getState(), 'properties') };
+ const key = data.keyID || data.key;
+ const value = data.valueID || data.value;
+ dispatch(change(
+ COLLECTION_UPDATE_FORM_NAME,
+ 'properties',
+ addProperty(properties, key, value)));
+ };
+
+export const removePropertyFromUpdateCollectionForm = (key: string, value: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const properties = { ...COLLECTION_UPDATE_FORM_SELECTOR(getState(), 'properties') };
+ dispatch(change(
+ COLLECTION_UPDATE_FORM_NAME,
+ 'properties',
+ deleteProperty(properties, key, value)));
+ };
diff --git a/src/store/context-menu/context-menu-actions.ts b/src/store/context-menu/context-menu-actions.ts
index 9a8733ba..38433eb2 100644
--- a/src/store/context-menu/context-menu-actions.ts
+++ b/src/store/context-menu/context-menu-actions.ts
@@ -41,6 +41,7 @@ export type ContextMenuResource = {
outputUuid?: string;
workflowUuid?: string;
storageClassesDesired?: string[];
+ properties?: { [key: string]: string | string[] };
};
export const isKeyboardClick = (event: React.MouseEvent<HTMLElement>) => event.nativeEvent.detail === 0;
diff --git a/src/store/projects/project-update-actions.ts b/src/store/projects/project-update-actions.ts
index ba176753..e5fc34d8 100644
--- a/src/store/projects/project-update-actions.ts
+++ b/src/store/projects/project-update-actions.ts
@@ -3,23 +3,40 @@
// SPDX-License-Identifier: AGPL-3.0
import { Dispatch } from "redux";
-import { FormErrors, initialize, reset, startSubmit, stopSubmit } from 'redux-form';
+import {
+ change,
+ FormErrors,
+ formValueSelector,
+ initialize,
+ reset,
+ startSubmit,
+ stopSubmit
+} 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";
+import {
+ getCommonResourceServiceError,
+ CommonResourceServiceError
+} from "services/common-service/common-resource-service";
import { ServiceRepository } from "services/services";
import { projectPanelActions } from 'store/project-panel/project-panel-action';
import { GroupClass } from "models/group";
import { Participant } from "views-components/sharing-dialog/participant-select";
+import { ResourcePropertiesFormData } from "views-components/resource-properties-form/resource-properties-form";
+import { addProperty, deleteProperty } from "lib/resource-properties";
+import { ProjectProperties } from "./project-create-actions";
export interface ProjectUpdateFormDialogData {
uuid: string;
name: string;
users?: Participant[];
description?: string;
+ properties?: ProjectProperties;
}
export const PROJECT_UPDATE_FORM_NAME = 'projectUpdateFormName';
+export const PROJECT_UPDATE_PROPERTIES_FORM_NAME = 'projectUpdatePropertiesFormName';
+export const PROJECT_UPDATE_FORM_SELECTOR = formValueSelector(PROJECT_UPDATE_FORM_NAME);
export const openProjectUpdateDialog = (resource: ProjectUpdateFormDialogData) =>
(dispatch: Dispatch, getState: () => RootState) => {
@@ -32,7 +49,13 @@ export const updateProject = (project: ProjectUpdateFormDialogData) =>
const uuid = project.uuid || '';
dispatch(startSubmit(PROJECT_UPDATE_FORM_NAME));
try {
- const updatedProject = await services.projectService.update(uuid, { name: project.name, description: project.description });
+ const updatedProject = await services.projectService.update(
+ uuid,
+ {
+ name: project.name,
+ description: project.description,
+ properties: project.properties,
+ });
dispatch(projectPanelActions.REQUEST_ITEMS());
dispatch(reset(PROJECT_UPDATE_FORM_NAME));
dispatch(dialogActions.CLOSE_DIALOG({ id: PROJECT_UPDATE_FORM_NAME }));
@@ -45,3 +68,23 @@ export const updateProject = (project: ProjectUpdateFormDialogData) =>
return ;
}
};
+
+export const addPropertyToUpdateProjectForm = (data: ResourcePropertiesFormData) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const properties = { ...PROJECT_UPDATE_FORM_SELECTOR(getState(), 'properties') };
+ const key = data.keyID || data.key;
+ const value = data.valueID || data.value;
+ dispatch(change(
+ PROJECT_UPDATE_FORM_NAME,
+ 'properties',
+ addProperty(properties, key, value)));
+ };
+
+export const removePropertyFromUpdateProjectForm = (key: string, value: string) =>
+ (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const properties = { ...PROJECT_UPDATE_FORM_SELECTOR(getState(), 'properties') };
+ dispatch(change(
+ PROJECT_UPDATE_FORM_NAME,
+ 'properties',
+ deleteProperty(properties, key, value)));
+ };
diff --git a/src/views-components/collection-properties/create-collection-properties-form.tsx b/src/views-components/collection-properties/create-collection-properties-form.tsx
new file mode 100644
index 00000000..8e3f8eb8
--- /dev/null
+++ b/src/views-components/collection-properties/create-collection-properties-form.tsx
@@ -0,0 +1,32 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { reduxForm, reset } from 'redux-form';
+import { withStyles } from '@material-ui/core';
+import {
+ COLLECTION_CREATE_PROPERTIES_FORM_NAME,
+ addPropertyToCreateCollectionForm
+} from 'store/collections/collection-create-actions';
+import {
+ ResourcePropertiesForm,
+ ResourcePropertiesFormData
+} from 'views-components/resource-properties-form/resource-properties-form';
+
+const Form = withStyles(
+ ({ spacing }) => (
+ { container:
+ {
+ paddingTop: spacing.unit,
+ margin: 0,
+ }
+ })
+ )(ResourcePropertiesForm);
+
+export const CreateCollectionPropertiesForm = reduxForm<ResourcePropertiesFormData>({
+ form: COLLECTION_CREATE_PROPERTIES_FORM_NAME,
+ onSubmit: (data, dispatch) => {
+ dispatch(addPropertyToCreateCollectionForm(data));
+ dispatch(reset(COLLECTION_CREATE_PROPERTIES_FORM_NAME));
+ }
+})(Form);
\ No newline at end of file
diff --git a/src/views-components/collection-properties/create-collection-properties-list.tsx b/src/views-components/collection-properties/create-collection-properties-list.tsx
new file mode 100644
index 00000000..9784b55e
--- /dev/null
+++ b/src/views-components/collection-properties/create-collection-properties-list.tsx
@@ -0,0 +1,70 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import React from 'react';
+import { connect } from 'react-redux';
+import { Dispatch } from 'redux';
+import {
+ withStyles,
+ StyleRulesCallback,
+ WithStyles,
+} from '@material-ui/core';
+import { RootState } from 'store/store';
+import {
+ removePropertyFromCreateCollectionForm,
+ COLLECTION_CREATE_FORM_SELECTOR,
+ CollectionProperties
+} from 'store/collections/collection-create-actions';
+import { ArvadosTheme } from 'common/custom-theme';
+import { getPropertyChip } from '../resource-properties-form/property-chip';
+
+type CssRules = 'tag';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ tag: {
+ marginRight: theme.spacing.unit,
+ marginBottom: theme.spacing.unit
+ }
+});
+
+interface CreateCollectionPropertiesListDataProps {
+ properties: CollectionProperties;
+}
+
+interface CreateCollectionPropertiesListActionProps {
+ handleDelete: (key: string, value: string) => void;
+}
+
+const mapStateToProps = (state: RootState): CreateCollectionPropertiesListDataProps => {
+ const properties = COLLECTION_CREATE_FORM_SELECTOR(state, 'properties');
+ return { properties };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): CreateCollectionPropertiesListActionProps => ({
+ handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromCreateCollectionForm(key, value))
+});
+
+type CreateCollectionPropertiesListProps = CreateCollectionPropertiesListDataProps &
+ CreateCollectionPropertiesListActionProps & WithStyles<CssRules>;
+
+const List = withStyles(styles)(
+ ({ classes, handleDelete, properties }: CreateCollectionPropertiesListProps) =>
+ <div>
+ {properties &&
+ Object.keys(properties).map(k =>
+ Array.isArray(properties[k])
+ ? (properties[k] as string[]).map((v: string) =>
+ getPropertyChip(
+ k, v,
+ () => handleDelete(k, v),
+ classes.tag))
+ : getPropertyChip(
+ k, (properties[k] as string),
+ () => handleDelete(k, (properties[k] as string)),
+ classes.tag))
+ }
+ </div>
+);
+
+export const CreateCollectionPropertiesList = connect(mapStateToProps, mapDispatchToProps)(List);
\ No newline at end of file
diff --git a/src/views-components/collection-properties/update-collection-properties-form.tsx b/src/views-components/collection-properties/update-collection-properties-form.tsx
new file mode 100644
index 00000000..dc00de30
--- /dev/null
+++ b/src/views-components/collection-properties/update-collection-properties-form.tsx
@@ -0,0 +1,32 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { reduxForm, reset } from 'redux-form';
+import { withStyles } from '@material-ui/core';
+import {
+ addPropertyToUpdateCollectionForm,
+ COLLECTION_UPDATE_PROPERTIES_FORM_NAME
+} from 'store/collections/collection-update-actions';
+import {
+ ResourcePropertiesForm,
+ ResourcePropertiesFormData
+} from 'views-components/resource-properties-form/resource-properties-form';
+
+const Form = withStyles(
+ ({ spacing }) => (
+ { container:
+ {
+ paddingTop: spacing.unit,
+ margin: 0,
+ }
+ })
+ )(ResourcePropertiesForm);
+
+export const UpdateCollectionPropertiesForm = reduxForm<ResourcePropertiesFormData>({
+ form: COLLECTION_UPDATE_PROPERTIES_FORM_NAME,
+ onSubmit: (data, dispatch) => {
+ dispatch(addPropertyToUpdateCollectionForm(data));
+ dispatch(reset(COLLECTION_UPDATE_PROPERTIES_FORM_NAME));
+ }
+})(Form);
\ No newline at end of file
diff --git a/src/views-components/collection-properties/update-collection-properties-list.tsx b/src/views-components/collection-properties/update-collection-properties-list.tsx
new file mode 100644
index 00000000..26cf5e70
--- /dev/null
+++ b/src/views-components/collection-properties/update-collection-properties-list.tsx
@@ -0,0 +1,70 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import React from 'react';
+import { connect } from 'react-redux';
+import { Dispatch } from 'redux';
+import {
+ withStyles,
+ StyleRulesCallback,
+ WithStyles,
+} from '@material-ui/core';
+import { RootState } from 'store/store';
+import {
+ removePropertyFromUpdateCollectionForm,
+ COLLECTION_UPDATE_FORM_SELECTOR,
+} from 'store/collections/collection-update-actions';
+import { ArvadosTheme } from 'common/custom-theme';
+import { getPropertyChip } from '../resource-properties-form/property-chip';
+import { CollectionProperties } from 'store/collections/collection-create-actions';
+
+type CssRules = 'tag';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ tag: {
+ marginRight: theme.spacing.unit,
+ marginBottom: theme.spacing.unit
+ }
+});
+
+interface UpdateCollectionPropertiesListDataProps {
+ properties: CollectionProperties;
+}
+
+interface UpdateCollectionPropertiesListActionProps {
+ handleDelete: (key: string, value: string) => void;
+}
+
+const mapStateToProps = (state: RootState): UpdateCollectionPropertiesListDataProps => {
+ const properties = COLLECTION_UPDATE_FORM_SELECTOR(state, 'properties');
+ return { properties };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): UpdateCollectionPropertiesListActionProps => ({
+ handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromUpdateCollectionForm(key, value))
+});
+
+type UpdateCollectionPropertiesListProps = UpdateCollectionPropertiesListDataProps &
+ UpdateCollectionPropertiesListActionProps & WithStyles<CssRules>;
+
+const List = withStyles(styles)(
+ ({ classes, handleDelete, properties }: UpdateCollectionPropertiesListProps) =>
+ <div>
+ {properties &&
+ Object.keys(properties).map(k =>
+ Array.isArray(properties[k])
+ ? (properties[k] as string[]).map((v: string) =>
+ getPropertyChip(
+ k, v,
+ () => handleDelete(k, v),
+ classes.tag))
+ : getPropertyChip(
+ k, (properties[k] as string),
+ () => handleDelete(k, (properties[k] as string)),
+ classes.tag))
+ }
+ </div>
+);
+
+export const UpdateCollectionPropertiesList = connect(mapStateToProps, mapDispatchToProps)(List);
\ No newline at end of file
diff --git a/src/views-components/dialog-create/dialog-collection-create.tsx b/src/views-components/dialog-create/dialog-collection-create.tsx
index c85a6d12..b75ad50f 100644
--- a/src/views-components/dialog-create/dialog-collection-create.tsx
+++ b/src/views-components/dialog-create/dialog-collection-create.tsx
@@ -14,6 +14,9 @@ import {
} from 'views-components/form-fields/collection-form-fields';
import { FileUploaderField } from '../file-uploader/file-uploader';
import { ResourceParentField } from '../form-fields/resource-form-fields';
+import { CreateCollectionPropertiesList } from 'views-components/collection-properties/create-collection-properties-list';
+import { CreateCollectionPropertiesForm } from 'views-components/collection-properties/create-collection-properties-form';
+import { FormGroup, FormLabel } from '@material-ui/core';
type DialogCollectionProps = WithDialogProps<{}> & InjectedFormProps<CollectionCreateFormDialogData>;
@@ -29,6 +32,11 @@ const CollectionAddFields = () => <span>
<ResourceParentField />
<CollectionNameField />
<CollectionDescriptionField />
+ <FormLabel>Properties</FormLabel>
+ <FormGroup>
+ <CreateCollectionPropertiesForm />
+ <CreateCollectionPropertiesList />
+ </FormGroup>
<CollectionStorageClassesField defaultClasses={['default']} />
<Field
name='files'
diff --git a/src/views-components/dialog-create/dialog-project-create.tsx b/src/views-components/dialog-create/dialog-project-create.tsx
index 85a2380e..81e9485c 100644
--- a/src/views-components/dialog-create/dialog-project-create.tsx
+++ b/src/views-components/dialog-create/dialog-project-create.tsx
@@ -11,6 +11,7 @@ import { ProjectNameField, ProjectDescriptionField } from 'views-components/form
import { CreateProjectPropertiesForm } from 'views-components/project-properties/create-project-properties-form';
import { CreateProjectPropertiesList } from 'views-components/project-properties/create-project-properties-list';
import { ResourceParentField } from '../form-fields/resource-form-fields';
+import { FormGroup, FormLabel } from '@material-ui/core';
type DialogProjectProps = WithDialogProps<{}> & InjectedFormProps<ProjectCreateFormDialogData>;
@@ -26,6 +27,9 @@ const ProjectAddFields = () => <span>
<ResourceParentField />
<ProjectNameField />
<ProjectDescriptionField />
- <CreateProjectPropertiesForm />
- <CreateProjectPropertiesList />
+ <FormLabel>Properties</FormLabel>
+ <FormGroup>
+ <CreateProjectPropertiesForm />
+ <CreateProjectPropertiesList />
+ </FormGroup>
</span>;
diff --git a/src/views-components/dialog-forms/create-collection-dialog.ts b/src/views-components/dialog-forms/create-collection-dialog.ts
index 7ef6e4b3..d989d431 100644
--- a/src/views-components/dialog-forms/create-collection-dialog.ts
+++ b/src/views-components/dialog-forms/create-collection-dialog.ts
@@ -17,7 +17,13 @@ export const CreateCollectionDialog = compose(
onSubmit: (data, dispatch) => {
// Somehow an extra field called 'files' gets added, copy
// the data object to get rid of it.
- dispatch(createCollection({ ownerUuid: data.ownerUuid, name: data.name, description: data.description, storageClassesDesired: data.storageClassesDesired }));
+ dispatch(createCollection({
+ ownerUuid: data.ownerUuid,
+ name: data.name,
+ description: data.description,
+ storageClassesDesired: data.storageClassesDesired,
+ properties: data.properties,
+ }));
}
})
)(DialogCollectionCreate);
diff --git a/src/views-components/dialog-update/dialog-collection-update.tsx b/src/views-components/dialog-update/dialog-collection-update.tsx
index cce64d27..5bdaa4f4 100644
--- a/src/views-components/dialog-update/dialog-collection-update.tsx
+++ b/src/views-components/dialog-update/dialog-collection-update.tsx
@@ -12,6 +12,9 @@ import {
CollectionDescriptionField,
CollectionStorageClassesField
} from 'views-components/form-fields/collection-form-fields';
+import { UpdateCollectionPropertiesForm } from 'views-components/collection-properties/update-collection-properties-form';
+import { UpdateCollectionPropertiesList } from 'views-components/collection-properties/update-collection-properties-list';
+import { FormGroup, FormLabel } from '@material-ui/core';
type DialogCollectionProps = WithDialogProps<{}> & InjectedFormProps<CollectionUpdateFormDialogData>;
@@ -26,5 +29,10 @@ export const DialogCollectionUpdate = (props: DialogCollectionProps) =>
const CollectionEditFields = () => <span>
<CollectionNameField />
<CollectionDescriptionField />
+ <FormLabel>Properties</FormLabel>
+ <FormGroup>
+ <UpdateCollectionPropertiesForm />
+ <UpdateCollectionPropertiesList />
+ </FormGroup>
<CollectionStorageClassesField />
</span>;
diff --git a/src/views-components/dialog-update/dialog-project-update.tsx b/src/views-components/dialog-update/dialog-project-update.tsx
index fda7c47d..96e6d927 100644
--- a/src/views-components/dialog-update/dialog-project-update.tsx
+++ b/src/views-components/dialog-update/dialog-project-update.tsx
@@ -9,6 +9,9 @@ import { ProjectUpdateFormDialogData } from 'store/projects/project-update-actio
import { FormDialog } from 'components/form-dialog/form-dialog';
import { ProjectNameField, ProjectDescriptionField, UsersField } from 'views-components/form-fields/project-form-fields';
import { GroupClass } from 'models/group';
+import { FormGroup, FormLabel } from '@material-ui/core';
+import { UpdateProjectPropertiesForm } from 'views-components/project-properties/update-project-properties-form';
+import { UpdateProjectPropertiesList } from 'views-components/project-properties/update-project-properties-list';
type DialogProjectProps = WithDialogProps<{sourcePanel: GroupClass, create?: boolean}> & InjectedFormProps<ProjectUpdateFormDialogData>;
@@ -35,6 +38,11 @@ export const DialogProjectUpdate = (props: DialogProjectProps) => {
const ProjectEditFields = () => <span>
<ProjectNameField />
<ProjectDescriptionField />
+ <FormLabel>Properties</FormLabel>
+ <FormGroup>
+ <UpdateProjectPropertiesForm />
+ <UpdateProjectPropertiesList />
+ </FormGroup>
</span>;
const GroupAddFields = () => <span>
diff --git a/src/views-components/project-properties/update-project-properties-form.tsx b/src/views-components/project-properties/update-project-properties-form.tsx
new file mode 100644
index 00000000..e6e78e34
--- /dev/null
+++ b/src/views-components/project-properties/update-project-properties-form.tsx
@@ -0,0 +1,32 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { reduxForm, reset } from 'redux-form';
+import { withStyles } from '@material-ui/core';
+import {
+ PROJECT_UPDATE_PROPERTIES_FORM_NAME,
+ addPropertyToUpdateProjectForm
+} from 'store/projects/project-update-actions';
+import {
+ ResourcePropertiesForm,
+ ResourcePropertiesFormData
+} from 'views-components/resource-properties-form/resource-properties-form';
+
+const Form = withStyles(
+ ({ spacing }) => (
+ { container:
+ {
+ paddingTop: spacing.unit,
+ margin: 0,
+ }
+ })
+ )(ResourcePropertiesForm);
+
+export const UpdateProjectPropertiesForm = reduxForm<ResourcePropertiesFormData>({
+ form: PROJECT_UPDATE_PROPERTIES_FORM_NAME,
+ onSubmit: (data, dispatch) => {
+ dispatch(addPropertyToUpdateProjectForm(data));
+ dispatch(reset(PROJECT_UPDATE_PROPERTIES_FORM_NAME));
+ }
+})(Form);
\ No newline at end of file
diff --git a/src/views-components/project-properties/update-project-properties-list.tsx b/src/views-components/project-properties/update-project-properties-list.tsx
new file mode 100644
index 00000000..5572af73
--- /dev/null
+++ b/src/views-components/project-properties/update-project-properties-list.tsx
@@ -0,0 +1,70 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import React from 'react';
+import { connect } from 'react-redux';
+import { Dispatch } from 'redux';
+import {
+ withStyles,
+ StyleRulesCallback,
+ WithStyles,
+} from '@material-ui/core';
+import { RootState } from 'store/store';
+import {
+ removePropertyFromUpdateProjectForm,
+ PROJECT_UPDATE_FORM_SELECTOR,
+} from 'store/projects/project-update-actions';
+import { ArvadosTheme } from 'common/custom-theme';
+import { getPropertyChip } from '../resource-properties-form/property-chip';
+import { ProjectProperties } from 'store/projects/project-create-actions';
+
+type CssRules = 'tag';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ tag: {
+ marginRight: theme.spacing.unit,
+ marginBottom: theme.spacing.unit
+ }
+});
+
+interface UpdateProjectPropertiesListDataProps {
+ properties: ProjectProperties;
+}
+
+interface UpdateProjectPropertiesListActionProps {
+ handleDelete: (key: string, value: string) => void;
+}
+
+const mapStateToProps = (state: RootState): UpdateProjectPropertiesListDataProps => {
+ const properties = PROJECT_UPDATE_FORM_SELECTOR(state, 'properties');
+ return { properties };
+};
+
+const mapDispatchToProps = (dispatch: Dispatch): UpdateProjectPropertiesListActionProps => ({
+ handleDelete: (key: string, value: string) => dispatch<any>(removePropertyFromUpdateProjectForm(key, value))
+});
+
+type UpdateProjectPropertiesListProps = UpdateProjectPropertiesListDataProps &
+ UpdateProjectPropertiesListActionProps & WithStyles<CssRules>;
+
+const List = withStyles(styles)(
+ ({ classes, handleDelete, properties }: UpdateProjectPropertiesListProps) =>
+ <div>
+ {properties &&
+ Object.keys(properties).map(k =>
+ Array.isArray(properties[k])
+ ? (properties[k] as string[]).map((v: string) =>
+ getPropertyChip(
+ k, v,
+ () => handleDelete(k, v),
+ classes.tag))
+ : getPropertyChip(
+ k, (properties[k] as string),
+ () => handleDelete(k, (properties[k] as string)),
+ classes.tag))
+ }
+ </div>
+);
+
+export const UpdateProjectPropertiesList = connect(mapStateToProps, mapDispatchToProps)(List);
\ No newline at end of file
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index adc3e995..851008c0 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -220,7 +220,8 @@ export const CollectionPanel = withStyles(styles)(
}
handleContextMenu = (event: React.MouseEvent<any>) => {
- const { uuid, ownerUuid, name, description, kind, storageClassesDesired } = this.props.item;
+ const { uuid, ownerUuid, name, description,
+ kind, storageClassesDesired, properties } = this.props.item;
const menuKind = this.props.dispatch<any>(resourceUuidToContextMenuKind(uuid));
const resource = {
uuid,
@@ -230,6 +231,7 @@ export const CollectionPanel = withStyles(styles)(
storageClassesDesired,
kind,
menuKind,
+ properties,
};
// Avoid expanding/collapsing the panel
event.stopPropagation();
diff --git a/src/views/project-panel/project-panel.tsx b/src/views/project-panel/project-panel.tsx
index 4a3f60a6..e08aea32 100644
--- a/src/views/project-panel/project-panel.tsx
+++ b/src/views/project-panel/project-panel.tsx
@@ -185,6 +185,7 @@ export const ProjectPanel = withStyles(styles)(
menuKind,
description: resource.description,
storageClassesDesired: (resource as CollectionResource).storageClassesDesired,
+ properties: ('properties' in resource) ? resource.properties : {},
}));
}
this.props.dispatch<any>(loadDetailsPanel(resourceUuid));
commit 8725d0bc4185a0624784d8feac120ec8acff089d
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Fri Dec 17 18:01:45 2021 -0300
18219: Improves the property adding form layout.
Instead of dividing the horizontal space equally between the 2 input fields
and the button, make just the both input fields take all the available
space.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/views-components/resource-properties-form/resource-properties-form.tsx b/src/views-components/resource-properties-form/resource-properties-form.tsx
index 94a3c955..979d772e 100644
--- a/src/views-components/resource-properties-form/resource-properties-form.tsx
+++ b/src/views-components/resource-properties-form/resource-properties-form.tsx
@@ -30,7 +30,7 @@ export const ResourcePropertiesForm = ({ handleSubmit, change, submitting, inval
<Grid item xs>
<PropertyValueField />
</Grid>
- <Grid item xs>
+ <Grid item>
<Button
data-cy='property-add-btn'
disabled={invalid}
commit 75db4557b4adabd65c89294f97da0a6aad599e43
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Thu Dec 16 10:19:44 2021 -0300
18219: Requests MPV custom props forwarding on the process panel.
Those props are properly handled so they don't generate any DOM warnings.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/views/process-panel/process-panel-root.tsx b/src/views/process-panel/process-panel-root.tsx
index deb5f1b0..6fb9c09d 100644
--- a/src/views/process-panel/process-panel-root.tsx
+++ b/src/views/process-panel/process-panel-root.tsx
@@ -48,7 +48,7 @@ const panelsData: MPVPanelState[] = [
export const ProcessPanelRoot = withStyles(styles)(({ process, ...props }: ProcessPanelRootProps) =>
process
? <MPVContainer className={props.classes.root} spacing={8} panelStates={panelsData} justify-content="flex-start" direction="column" wrap="nowrap">
- <MPVPanelContent xs="auto">
+ <MPVPanelContent forwardProps xs="auto">
<ProcessInformationCard
process={process}
onContextMenu={event => props.onContextMenu(event, process)}
@@ -58,10 +58,10 @@ export const ProcessPanelRoot = withStyles(styles)(({ process, ...props }: Proce
cancelProcess={props.cancelProcess}
/>
</MPVPanelContent>
- <MPVPanelContent xs="auto">
+ <MPVPanelContent forwardProps xs="auto">
<ProcessDetailsCard process={process} />
</MPVPanelContent>
- <MPVPanelContent xs>
+ <MPVPanelContent forwardProps xs>
<SubprocessPanel />
</MPVPanelContent>
</MPVContainer>
commit a6be5a3b336233c9fd28d640402929fe4e309b26
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Thu Dec 16 10:17:31 2021 -0300
18219: Disables custom props forwarding on MPV components by default.
This is to avoid warning messages like:
Warning: React does not recognize the `panelIlluminated` prop on a DOM element.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/components/multi-panel-view/multi-panel-view.test.tsx b/src/components/multi-panel-view/multi-panel-view.test.tsx
index 6cf13d78..d690e82f 100644
--- a/src/components/multi-panel-view/multi-panel-view.test.tsx
+++ b/src/components/multi-panel-view/multi-panel-view.test.tsx
@@ -10,7 +10,7 @@ import { Button } from "@material-ui/core";
configure({ adapter: new Adapter() });
-const PanelMock = ({panelName, panelMaximized, doHidePanel, doMaximizePanel, children, ...rest}) =>
+const PanelMock = ({panelName, panelMaximized, doHidePanel, doMaximizePanel, panelIlluminated, panelRef, children, ...rest}) =>
<div {...rest}>{children}</div>;
describe('<MPVContainer />', () => {
diff --git a/src/components/multi-panel-view/multi-panel-view.tsx b/src/components/multi-panel-view/multi-panel-view.tsx
index dbb37921..185c3b90 100644
--- a/src/components/multi-panel-view/multi-panel-view.tsx
+++ b/src/components/multi-panel-view/multi-panel-view.tsx
@@ -64,6 +64,7 @@ interface MPVPanelDataProps {
panelMaximized?: boolean;
panelIlluminated?: boolean;
panelRef?: MutableRefObject<any>;
+ forwardProps?: boolean;
}
interface MPVPanelActionProps {
@@ -77,7 +78,7 @@ export type MPVPanelProps = MPVPanelDataProps & MPVPanelActionProps;
type MPVPanelContentProps = {children: ReactElement} & MPVPanelProps & GridProps;
// Grid item compatible component for layout and MPV props passing
-export const MPVPanelContent = ({doHidePanel, doMaximizePanel, panelName, panelMaximized, panelIlluminated, panelRef, ...props}: MPVPanelContentProps) => {
+export const MPVPanelContent = ({doHidePanel, doMaximizePanel, panelName, panelMaximized, panelIlluminated, panelRef, forwardProps, ...props}: MPVPanelContentProps) => {
useEffect(() => {
if (panelRef && panelRef.current) {
panelRef.current.scrollIntoView({behavior: 'smooth'});
@@ -87,7 +88,9 @@ export const MPVPanelContent = ({doHidePanel, doMaximizePanel, panelName, panelM
return <Grid item {...props}>
<span ref={panelRef} /> {/* Element to scroll to when the panel is selected */}
<Paper style={{height: '100%'}} elevation={panelIlluminated ? 8 : 0}>
- {React.cloneElement(props.children, { doHidePanel, doMaximizePanel, panelName, panelMaximized })}
+ { forwardProps
+ ? React.cloneElement(props.children, { doHidePanel, doMaximizePanel, panelName, panelMaximized })
+ : props.children }
</Paper>
</Grid>;
}
commit be7d8afed27347d0b55818e64fce3e036e5300d8
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Wed Dec 15 18:03:04 2021 -0300
18219: Updates cypress tests.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/cypress/integration/collection.spec.js b/cypress/integration/collection.spec.js
index 82a26cef..03ec1b58 100644
--- a/cypress/integration/collection.spec.js
+++ b/cypress/integration/collection.spec.js
@@ -85,6 +85,17 @@ describe('Collection panel tests', function () {
cy.loginAs(activeUser);
cy.goToPath(`/collections/${this.testCollection.uuid}`);
+ cy.get('[data-cy=collection-info-panel')
+ .should('contain', this.testCollection.name)
+ .and('not.contain', 'Color: Magenta')
+ .and('not.contain', 'Size: S');
+ cy.get('[data-cy=additional-info-icon]').click();
+
+ cy.get('[data-cy=details-panel]').within(() => {
+ cy.get('[data-cy=property-editor-btn]').click();
+ });
+ cy.get('[data-cy=resource-properties-dialog').contains('Edit properties');
+
// Key: Color (IDTAGCOLORS) - Value: Magenta (IDVALCOLORS3)
cy.get('[data-cy=resource-properties-form]').within(() => {
cy.get('[data-cy=property-field-key]').within(() => {
@@ -96,7 +107,7 @@ describe('Collection panel tests', function () {
cy.root().submit();
});
// Confirm proper vocabulary labels are displayed on the UI.
- cy.get('[data-cy=collection-properties-panel]')
+ cy.get('[data-cy=resource-properties-dialog]')
.should('contain', 'Color: Magenta');
// Confirm proper vocabulary IDs were saved on the backend.
cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
@@ -120,7 +131,7 @@ describe('Collection panel tests', function () {
cy.root().submit();
});
// Confirm proper vocabulary labels are displayed on the UI.
- cy.get('[data-cy=collection-properties-panel]')
+ cy.get('[data-cy=resource-properties-dialog]')
.should('contain', 'Size: S');
// Confirm proper vocabulary IDs were saved on the backend.
cy.doRequest('GET', `/arvados/v1/collections/${this.testCollection.uuid}`)
@@ -128,6 +139,15 @@ describe('Collection panel tests', function () {
.then(function () {
expect(this.collection.properties.IDTAGSIZES).to.equal('IDVALSIZES2');
});
+
+ // Close property editor & confirm properties display on the UI.
+ cy.get('[data-cy=resource-properties-dialog]').within(() => {
+ cy.get('[data-cy=close-dialog-btn]').click();
+ });
+ cy.get('[data-cy=collection-info-panel')
+ .should('contain', this.testCollection.name)
+ .and('contain', 'Color: Magenta')
+ .and('contain', 'Size: S');
});
});
@@ -186,29 +206,9 @@ describe('Collection panel tests', function () {
.should('contain', 'Add to favorites')
.and(`${isWritable ? '' : 'not.'}contain`, 'Edit collection');
cy.get('body').click(); // Collapse the menu avoiding details panel expansion
- cy.get('[data-cy=collection-properties-panel]')
- .should('contain', 'someKey')
- .and('contain', 'someValue')
- .and('not.contain', 'anotherKey')
- .and('not.contain', 'anotherValue')
- if (isWritable === true) {
- // Check that properties can be added.
- cy.get('[data-cy=resource-properties-form]').within(() => {
- cy.get('[data-cy=property-field-key]').within(() => {
- cy.get('input').type('anotherKey');
- });
- cy.get('[data-cy=property-field-value]').within(() => {
- cy.get('input').type('anotherValue');
- });
- cy.root().submit();
- })
- cy.get('[data-cy=collection-properties-panel]')
- .should('contain', 'anotherKey')
- .and('contain', 'anotherValue')
- } else {
- // Properties form shouldn't be displayed.
- cy.get('[data-cy=resource-properties-form]').should('not.exist');
- }
+ cy.get('[data-cy=collection-info-panel]')
+ .should('contain', 'someKey: someValue')
+ .and('not.contain', 'anotherKey: anotherValue');
// Check that the file listing show both read & write operations
cy.get('[data-cy=collection-files-panel]').within(() => {
cy.wait(1000);
@@ -313,63 +313,6 @@ describe('Collection panel tests', function () {
});
});
- it.skip('renames a file to a different directory', function () {
- // Creates the collection using the admin token so we can set up
- // a bogus manifest text without block signatures.
- cy.createCollection(adminUser.token, {
- name: `Test collection ${Math.floor(Math.random() * 999999)}`,
- owner_uuid: activeUser.user.uuid,
- manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
- })
- .as('testCollection').then(function () {
- cy.loginAs(activeUser);
- cy.goToPath(`/collections/${this.testCollection.uuid}`);
-
- ['subdir', 'G%C3%BCnter\'s%20file', 'table%&?*2'].forEach((subdir) => {
- cy.get('[data-cy=collection-files-panel]')
- .contains('bar').rightclick({force: true});
- cy.get('[data-cy=context-menu]')
- .contains('Rename')
- .click();
- cy.get('[data-cy=form-dialog]')
- .should('contain', 'Rename')
- .within(() => {
- cy.get('input').type(`{selectall}{backspace}${subdir}/foo`);
- });
- cy.get('[data-cy=form-submit-btn]').click();
- cy.get('[data-cy=collection-files-panel]')
- .should('not.contain', 'bar')
- .and('contain', subdir);
- // Look for the "arrow icon" and expand the "subdir" directory.
- cy.get('[data-cy=virtual-file-tree] > div > i').click();
- // Rename 'subdir/foo' to 'foo'
- cy.get('[data-cy=collection-files-panel]')
- .contains('foo').rightclick();
- cy.get('[data-cy=context-menu]')
- .contains('Rename')
- .click();
- cy.get('[data-cy=form-dialog]')
- .should('contain', 'Rename')
- .within(() => {
- cy.get('input')
- .should('have.value', `${subdir}/foo`)
- .type(`{selectall}{backspace}bar`);
- });
- cy.get('[data-cy=form-submit-btn]').click();
- cy.get('[data-cy=collection-files-panel]')
- .should('contain', subdir) // empty dir kept
- .and('contain', 'bar');
-
- cy.get('[data-cy=collection-files-panel]')
- .contains(subdir).rightclick();
- cy.get('[data-cy=context-menu]')
- .contains('Remove')
- .click();
- cy.get('[data-cy=confirmation-dialog-ok-btn]').click();
- });
- });
- });
-
it('renames a file to a different directory', function () {
// Creates the collection using the admin token so we can set up
// a bogus manifest text without block signatures.
diff --git a/cypress/integration/project.spec.js b/cypress/integration/project.spec.js
index b3d6bbed..3ffdcc2d 100644
--- a/cypress/integration/project.spec.js
+++ b/cypress/integration/project.spec.js
@@ -28,7 +28,7 @@ describe('Project tests', function() {
cy.clearLocalStorage();
});
- it('adds creates a new project with properties', function() {
+ it('creates a new project with properties', function() {
const projName = `Test project (${Math.floor(999999 * Math.random())})`;
cy.loginAs(activeUser);
cy.get('[data-cy=side-panel-button]').click();
diff --git a/src/views-components/details-panel/details-panel.tsx b/src/views-components/details-panel/details-panel.tsx
index 058db81b..399f4ef4 100644
--- a/src/views-components/details-panel/details-panel.tsx
+++ b/src/views-components/details-panel/details-panel.tsx
@@ -160,6 +160,7 @@ export const DetailsPanel = withStyles(styles)(
const item = getItem(res);
return <Grid
+ data-cy='details-panel'
container
direction="column"
item
diff --git a/src/views-components/resource-properties-dialog/resource-properties-dialog.tsx b/src/views-components/resource-properties-dialog/resource-properties-dialog.tsx
index b634715f..2502f50a 100644
--- a/src/views-components/resource-properties-dialog/resource-properties-dialog.tsx
+++ b/src/views-components/resource-properties-dialog/resource-properties-dialog.tsx
@@ -60,6 +60,7 @@ export const ResourcePropertiesDialog = connect(mapStateToProps, mapDispatchToPr
onClose={closeDialog}
fullWidth
maxWidth='sm'>
+ <div data-cy='resource-properties-dialog'>
<DialogTitle>Edit properties</DialogTitle>
<DialogContent>
<ResourcePropertiesDialogForm uuid={resource ? resource.uuid : ''} />
@@ -80,12 +81,14 @@ export const ResourcePropertiesDialog = connect(mapStateToProps, mapDispatchToPr
</DialogContent>
<DialogActions>
<Button
+ data-cy='close-dialog-btn'
variant='text'
color='primary'
onClick={closeDialog}>
Close
</Button>
</DialogActions>
+ </div>
</Dialog>
)
));
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index 5aeaef18..adc3e995 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -345,7 +345,7 @@ export const CollectionDetailsAttributes = connect(null, mapDispatchToProps)(
<DetailsAttribute classLabel={classes.label} classValue={classes.value}
label='Properties'>
{ !props.twoCol
- ? <div onClick={props.onClick}>
+ ? <div data-cy='property-editor-btn' onClick={props.onClick}>
<RenameIcon className={classes.editIcon} />
</div>
: '' }
commit d60348e41975a5e48f09773f4d0accec11e93da4
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Wed Dec 15 16:31:32 2021 -0300
18219: Replaces properties form on collection panel.
* Removes properties form subpanel from the main collection panel.
* Adds property chips to collection's info & details panel.
* Allows property editing from the details panel.
* Replaces resource-specific property form components with a generic one.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts
index ee476524..c50ff6a8 100644
--- a/src/store/collection-panel/collection-panel-action.ts
+++ b/src/store/collection-panel/collection-panel-action.ts
@@ -9,15 +9,12 @@ import {
import { CollectionResource } from 'models/collection';
import { RootState } from "store/store";
import { ServiceRepository } from "services/services";
-import { TagProperty } from "models/tag";
import { snackbarActions } from "../snackbar/snackbar-actions";
import { resourcesActions } from "store/resources/resources-actions";
import { unionize, ofType, UnionOf } from 'common/unionize';
import { SnackbarKind } from 'store/snackbar/snackbar-actions';
import { navigateTo } from 'store/navigation/navigation-action';
import { loadDetailsPanel } from 'store/details-panel/details-panel-action';
-import { addProperty, deleteProperty } from "lib/resource-properties";
-import { getResource } from "store/resources/resources";
export const collectionPanelActions = unionize({
SET_COLLECTION: ofType<CollectionResource>(),
@@ -27,8 +24,6 @@ export const collectionPanelActions = unionize({
export type CollectionPanelAction = UnionOf<typeof collectionPanelActions>;
-export const COLLECTION_TAG_FORM_NAME = 'collectionTagForm';
-
export const loadCollectionPanel = (uuid: string, forceReload = false) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
const { collectionPanel: { item } } = getState();
@@ -44,37 +39,6 @@ export const loadCollectionPanel = (uuid: string, forceReload = false) =>
return collection;
};
-export const createCollectionTag = (data: TagProperty) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const item = getState().collectionPanel.item;
- if (!item) { return; }
-
- const properties = Object.assign({}, item.properties);
- const key = data.keyID || data.key;
- const value = data.valueID || data.value;
- const cachedCollection = getResource<CollectionResource>(item.uuid)(getState().resources);
- services.collectionService.update(
- item.uuid, {
- properties: addProperty(properties, key, value)
- }
- ).then(updatedCollection => {
- updatedCollection = {...cachedCollection, ...updatedCollection};
- dispatch(collectionPanelActions.SET_COLLECTION(updatedCollection));
- dispatch(resourcesActions.SET_RESOURCES([updatedCollection]));
- dispatch(snackbarActions.OPEN_SNACKBAR({
- message: "Property has been successfully added.",
- hideDuration: 2000,
- kind: SnackbarKind.SUCCESS }));
- dispatch<any>(loadDetailsPanel(updatedCollection.uuid));
- return updatedCollection;
- }).catch (e =>
- dispatch(snackbarActions.OPEN_SNACKBAR({
- message: e.errors[0],
- hideDuration: 2000,
- kind: SnackbarKind.ERROR }))
- );
- };
-
export const navigateToProcess = (uuid: string) =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
try {
@@ -84,29 +48,3 @@ export const navigateToProcess = (uuid: string) =>
dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'This process does not exist!', hideDuration: 2000, kind: SnackbarKind.ERROR }));
}
};
-
-export const deleteCollectionTag = (key: string, value: string) =>
- (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const item = getState().collectionPanel.item;
- if (!item) { return; }
-
- const properties = Object.assign({}, item.properties);
- const cachedCollection = getResource<CollectionResource>(item.uuid)(getState().resources);
- services.collectionService.update(
- item.uuid, {
- properties: deleteProperty(properties, key, value)
- }
- ).then(updatedCollection => {
- updatedCollection = {...cachedCollection, ...updatedCollection};
- dispatch(collectionPanelActions.SET_COLLECTION(updatedCollection));
- dispatch(resourcesActions.SET_RESOURCES([updatedCollection]));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Tag has been successfully deleted.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
- dispatch<any>(loadDetailsPanel(updatedCollection.uuid));
- return updatedCollection;
- }).catch (e => {
- dispatch(snackbarActions.OPEN_SNACKBAR({
- message: e.errors[0],
- hideDuration: 2000,
- kind: SnackbarKind.ERROR }));
- });
- };
diff --git a/src/store/details-panel/details-panel-action.ts b/src/store/details-panel/details-panel-action.ts
index bda35441..90ca0f4f 100644
--- a/src/store/details-panel/details-panel-action.ts
+++ b/src/store/details-panel/details-panel-action.ts
@@ -7,13 +7,9 @@ import { RootState } from 'store/store';
import { Dispatch } from 'redux';
import { dialogActions } from 'store/dialog/dialog-actions';
import { getResource } from 'store/resources/resources';
-import { ProjectResource } from "models/project";
import { ServiceRepository } from 'services/services';
-import { TagProperty } from 'models/tag';
-import { startSubmit, stopSubmit } from 'redux-form';
import { resourcesActions } from 'store/resources/resources-actions';
import {snackbarActions, SnackbarKind} from 'store/snackbar/snackbar-actions';
-import { addProperty, deleteProperty } from 'lib/resource-properties';
import { FilterBuilder } from 'services/api/filter-builder';
import { OrderBuilder } from 'services/api/order-builder';
import { CollectionResource } from 'models/collection';
@@ -29,8 +25,8 @@ export const detailsPanelActions = unionize({
export type DetailsPanelAction = UnionOf<typeof detailsPanelActions>;
-export const PROJECT_PROPERTIES_FORM_NAME = 'projectPropertiesFormName';
-export const PROJECT_PROPERTIES_DIALOG_NAME = 'projectPropertiesDialogName';
+export const RESOURCE_PROPERTIES_FORM_NAME = 'resourcePropertiesFormName';
+export const RESOURCE_PROPERTIES_DIALOG_NAME = 'resourcePropertiesDialogName';
export const loadDetailsPanel = (uuid: string) =>
(dispatch: Dispatch, getState: () => RootState) => {
@@ -55,9 +51,9 @@ export const openDetailsPanel = (uuid?: string, tabNr: number = 0) =>
}
};
-export const openProjectPropertiesDialog = () =>
+export const openResourcePropertiesDialog = () =>
(dispatch: Dispatch) => {
- dispatch<any>(dialogActions.OPEN_DIALOG({ id: PROJECT_PROPERTIES_DIALOG_NAME, data: { } }));
+ dispatch<any>(dialogActions.OPEN_DIALOG({ id: RESOURCE_PROPERTIES_DIALOG_NAME, data: { } }));
};
export const refreshCollectionVersionsList = (uuid: string) =>
@@ -76,49 +72,6 @@ export const refreshCollectionVersionsList = (uuid: string) =>
);
};
-export const deleteProjectProperty = (key: string, value: string) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const { detailsPanel, resources } = getState();
- const project = getResource(detailsPanel.resourceUuid)(resources) as ProjectResource;
- if (!project) { return; }
-
- const properties = Object.assign({}, project.properties);
-
- try {
- const updatedProject = await services.projectService.update(
- project.uuid, {
- properties: deleteProperty(properties, key, value),
- });
- dispatch(resourcesActions.SET_RESOURCES([updatedProject]));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully deleted.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
- } catch (e) {
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.errors[0], hideDuration: 2000, kind: SnackbarKind.ERROR }));
- }
- };
-
-export const createProjectProperty = (data: TagProperty) =>
- async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const { detailsPanel, resources } = getState();
- const project = getResource(detailsPanel.resourceUuid)(resources) as ProjectResource;
- if (!project) { return; }
-
- dispatch(startSubmit(PROJECT_PROPERTIES_FORM_NAME));
- try {
- const key = data.keyID || data.key;
- const value = data.valueID || data.value;
- const properties = Object.assign({}, project.properties);
- const updatedProject = await services.projectService.update(
- project.uuid, {
- properties: addProperty(properties, key, value),
- }
- );
- dispatch(resourcesActions.SET_RESOURCES([updatedProject]));
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully added.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
- dispatch(stopSubmit(PROJECT_PROPERTIES_FORM_NAME));
- } catch (e) {
- dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.errors[0], hideDuration: 2000, kind: SnackbarKind.ERROR }));
- }
- };
export const toggleDetailsPanel = () => (dispatch: Dispatch, getState: () => RootState) => {
// because of material-ui issue resizing details panel breaks tabs.
// triggering window resize event fixes that.
diff --git a/src/store/resources/resources-actions.ts b/src/store/resources/resources-actions.ts
index 6c05da32..8e6d16f9 100644
--- a/src/store/resources/resources-actions.ts
+++ b/src/store/resources/resources-actions.ts
@@ -3,11 +3,15 @@
// SPDX-License-Identifier: AGPL-3.0
import { unionize, ofType, UnionOf } from 'common/unionize';
-import { extractUuidKind, Resource } from 'models/resource';
+import { extractUuidKind, Resource, ResourceWithProperties } from 'models/resource';
import { Dispatch } from 'redux';
import { RootState } from 'store/store';
import { ServiceRepository } from 'services/services';
import { getResourceService } from 'services/services';
+import { addProperty, deleteProperty } from 'lib/resource-properties';
+import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
+import { getResource } from './resources';
+import { TagProperty } from 'models/tag';
export const resourcesActions = unionize({
SET_RESOURCES: ofType<Resource[]>(),
@@ -33,3 +37,59 @@ export const loadResource = (uuid: string, showErrors?: boolean) =>
} catch {}
return undefined;
};
+
+export const deleteResourceProperty = (uuid: string, key: string, value: string) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const { resources } = getState();
+
+ const rsc = getResource(uuid)(resources) as ResourceWithProperties;
+ if (!rsc) { return; }
+
+ const kind = extractUuidKind(uuid);
+ const service = getResourceService(kind)(services);
+ if (!service) { return; }
+
+ const properties = Object.assign({}, rsc.properties);
+
+ try {
+ let updatedRsc = await service.update(
+ uuid, {
+ properties: deleteProperty(properties, key, value),
+ });
+ updatedRsc = {...rsc, ...updatedRsc};
+ dispatch<any>(updateResources([updatedRsc]));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully deleted.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ } catch (e) {
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: e.errors[0], hideDuration: 2000, kind: SnackbarKind.ERROR }));
+ }
+ };
+
+export const createResourceProperty = (data: TagProperty) =>
+ async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+ const { uuid } = data;
+ const { resources } = getState();
+
+ const rsc = getResource(uuid)(resources) as ResourceWithProperties;
+ if (!rsc) { return; }
+
+ const kind = extractUuidKind(uuid);
+ const service = getResourceService(kind)(services);
+ if (!service) { return; }
+
+ try {
+ const key = data.keyID || data.key;
+ const value = data.valueID || data.value;
+ const properties = Object.assign({}, rsc.properties);
+ let updatedRsc = await service.update(
+ rsc.uuid, {
+ properties: addProperty(properties, key, value),
+ }
+ );
+ updatedRsc = {...rsc, ...updatedRsc};
+ dispatch<any>(updateResources([updatedRsc]));
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Property has been successfully added.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
+ } catch (e) {
+ const errorMsg = e.errors && e.errors.length > 0 ? e.errors[0] : "Error while adding property";
+ dispatch(snackbarActions.OPEN_SNACKBAR({ message: errorMsg, hideDuration: 2000, kind: SnackbarKind.ERROR }));
+ }
+ };
diff --git a/src/views-components/details-panel/project-details.tsx b/src/views-components/details-panel/project-details.tsx
index 41ba6f00..82e3e754 100644
--- a/src/views-components/details-panel/project-details.tsx
+++ b/src/views-components/details-panel/project-details.tsx
@@ -4,7 +4,7 @@
import React from 'react';
import { connect } from 'react-redux';
-import { openProjectPropertiesDialog } from 'store/details-panel/details-panel-action';
+import { openResourcePropertiesDialog } from 'store/details-panel/details-panel-action';
import { ProjectIcon, RenameIcon, FilterGroupIcon } from 'components/icon/icon';
import { ProjectResource } from 'models/project';
import { formatDate } from 'common/formatters';
@@ -55,7 +55,7 @@ interface ProjectDetailsComponentActionProps {
}
const mapDispatchToProps = (dispatch: Dispatch) => ({
- onClick: () => dispatch<any>(openProjectPropertiesDialog()),
+ onClick: () => dispatch<any>(openResourcePropertiesDialog()),
});
type ProjectDetailsComponentProps = ProjectDetailsComponentDataProps & ProjectDetailsComponentActionProps & WithStyles<CssRules>;
diff --git a/src/views-components/project-properties-dialog/project-properties-dialog.tsx b/src/views-components/project-properties-dialog/project-properties-dialog.tsx
deleted file mode 100644
index 19d3bb56..00000000
--- a/src/views-components/project-properties-dialog/project-properties-dialog.tsx
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import React from "react";
-import { Dispatch } from "redux";
-import { connect } from "react-redux";
-import { RootState } from 'store/store';
-import { withDialog, WithDialogProps } from "store/dialog/with-dialog";
-import { ProjectResource } from 'models/project';
-import { PROJECT_PROPERTIES_DIALOG_NAME, deleteProjectProperty } from 'store/details-panel/details-panel-action';
-import { Dialog, DialogTitle, DialogContent, DialogActions, Button, withStyles, StyleRulesCallback, WithStyles } from '@material-ui/core';
-import { ArvadosTheme } from 'common/custom-theme';
-import { ProjectPropertiesForm } from 'views-components/project-properties-dialog/project-properties-form';
-import { getResource } from 'store/resources/resources';
-import { getPropertyChip } from "../resource-properties-form/property-chip";
-
-type CssRules = 'tag';
-
-const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
- tag: {
- marginRight: theme.spacing.unit,
- marginBottom: theme.spacing.unit
- }
-});
-
-interface ProjectPropertiesDialogDataProps {
- project: ProjectResource;
-}
-
-interface ProjectPropertiesDialogActionProps {
- handleDelete: (key: string, value: string) => void;
-}
-
-const mapStateToProps = ({ detailsPanel, resources, properties }: RootState): ProjectPropertiesDialogDataProps => ({
- project: getResource(detailsPanel.resourceUuid)(resources) as ProjectResource,
-});
-
-const mapDispatchToProps = (dispatch: Dispatch): ProjectPropertiesDialogActionProps => ({
- handleDelete: (key: string, value: string) => () => dispatch<any>(deleteProjectProperty(key, value)),
-});
-
-type ProjectPropertiesDialogProps = ProjectPropertiesDialogDataProps & ProjectPropertiesDialogActionProps & WithDialogProps<{}> & WithStyles<CssRules>;
-
-export const ProjectPropertiesDialog = connect(mapStateToProps, mapDispatchToProps)(
- withStyles(styles)(
- withDialog(PROJECT_PROPERTIES_DIALOG_NAME)(
- ({ classes, open, closeDialog, handleDelete, project }: ProjectPropertiesDialogProps) =>
- <Dialog open={open}
- onClose={closeDialog}
- fullWidth
- maxWidth='sm'>
- <DialogTitle>Properties</DialogTitle>
- <DialogContent>
- <ProjectPropertiesForm />
- {project && project.properties &&
- Object.keys(project.properties).map(k =>
- Array.isArray(project.properties[k])
- ? project.properties[k].map((v: string) =>
- getPropertyChip(
- k, v,
- handleDelete(k, v),
- classes.tag))
- : getPropertyChip(
- k, project.properties[k],
- handleDelete(k, project.properties[k]),
- classes.tag)
- )
- }
- </DialogContent>
- <DialogActions>
- <Button
- variant='text'
- color='primary'
- onClick={closeDialog}>
- Close
- </Button>
- </DialogActions>
- </Dialog>
- )
- ));
diff --git a/src/views-components/project-properties-dialog/project-properties-form.tsx b/src/views-components/resource-properties-dialog/resource-properties-dialog-form.tsx
similarity index 56%
rename from src/views-components/project-properties-dialog/project-properties-form.tsx
rename to src/views-components/resource-properties-dialog/resource-properties-dialog-form.tsx
index f36bacf4..cfb999cc 100644
--- a/src/views-components/project-properties-dialog/project-properties-form.tsx
+++ b/src/views-components/resource-properties-dialog/resource-properties-dialog-form.tsx
@@ -3,17 +3,18 @@
// SPDX-License-Identifier: AGPL-3.0
import { reduxForm, reset } from 'redux-form';
-import { PROJECT_PROPERTIES_FORM_NAME, createProjectProperty } from 'store/details-panel/details-panel-action';
+import { RESOURCE_PROPERTIES_FORM_NAME } from 'store/details-panel/details-panel-action';
import { ResourcePropertiesForm, ResourcePropertiesFormData } from 'views-components/resource-properties-form/resource-properties-form';
import { withStyles } from '@material-ui/core';
import { Dispatch } from 'redux';
+import { createResourceProperty } from 'store/resources/resources-actions';
const Form = withStyles(({ spacing }) => ({ container: { marginBottom: spacing.unit * 2 } }))(ResourcePropertiesForm);
-export const ProjectPropertiesForm = reduxForm<ResourcePropertiesFormData>({
- form: PROJECT_PROPERTIES_FORM_NAME,
+export const ResourcePropertiesDialogForm = reduxForm<ResourcePropertiesFormData, {uuid: string}>({
+ form: RESOURCE_PROPERTIES_FORM_NAME,
onSubmit: (data, dispatch: Dispatch) => {
- dispatch<any>(createProjectProperty(data));
- dispatch(reset(PROJECT_PROPERTIES_FORM_NAME));
+ dispatch<any>(createResourceProperty(data));
+ dispatch(reset(RESOURCE_PROPERTIES_FORM_NAME));
}
})(Form);
diff --git a/src/views-components/resource-properties-dialog/resource-properties-dialog.tsx b/src/views-components/resource-properties-dialog/resource-properties-dialog.tsx
new file mode 100644
index 00000000..b634715f
--- /dev/null
+++ b/src/views-components/resource-properties-dialog/resource-properties-dialog.tsx
@@ -0,0 +1,91 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import React from "react";
+import { Dispatch } from "redux";
+import { connect } from "react-redux";
+import { RootState } from 'store/store';
+import { withDialog, WithDialogProps } from "store/dialog/with-dialog";
+import { RESOURCE_PROPERTIES_DIALOG_NAME } from 'store/details-panel/details-panel-action';
+import {
+ Dialog,
+ DialogTitle,
+ DialogContent,
+ DialogActions,
+ Button,
+ withStyles,
+ StyleRulesCallback,
+ WithStyles
+} from '@material-ui/core';
+import { ArvadosTheme } from 'common/custom-theme';
+import { ResourcePropertiesDialogForm } from 'views-components/resource-properties-dialog/resource-properties-dialog-form';
+import { getResource } from 'store/resources/resources';
+import { getPropertyChip } from "../resource-properties-form/property-chip";
+import { deleteResourceProperty } from "store/resources/resources-actions";
+import { ResourceWithProperties } from "models/resource";
+
+type CssRules = 'tag';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ tag: {
+ marginRight: theme.spacing.unit,
+ marginBottom: theme.spacing.unit
+ }
+});
+
+interface ResourcePropertiesDialogDataProps {
+ resource: ResourceWithProperties;
+}
+
+interface ResourcePropertiesDialogActionProps {
+ handleDelete: (uuid: string, key: string, value: string) => void;
+}
+
+const mapStateToProps = ({ detailsPanel, resources, properties }: RootState): ResourcePropertiesDialogDataProps => ({
+ resource: getResource(detailsPanel.resourceUuid)(resources) as ResourceWithProperties,
+});
+
+const mapDispatchToProps = (dispatch: Dispatch): ResourcePropertiesDialogActionProps => ({
+ handleDelete: (uuid: string, key: string, value: string) => () => dispatch<any>(deleteResourceProperty(uuid, key, value)),
+});
+
+type ResourcePropertiesDialogProps = ResourcePropertiesDialogDataProps & ResourcePropertiesDialogActionProps & WithDialogProps<{}> & WithStyles<CssRules>;
+
+export const ResourcePropertiesDialog = connect(mapStateToProps, mapDispatchToProps)(
+ withStyles(styles)(
+ withDialog(RESOURCE_PROPERTIES_DIALOG_NAME)(
+ ({ classes, open, closeDialog, handleDelete, resource }: ResourcePropertiesDialogProps) =>
+ <Dialog open={open}
+ onClose={closeDialog}
+ fullWidth
+ maxWidth='sm'>
+ <DialogTitle>Edit properties</DialogTitle>
+ <DialogContent>
+ <ResourcePropertiesDialogForm uuid={resource ? resource.uuid : ''} />
+ {resource && resource.properties &&
+ Object.keys(resource.properties).map(k =>
+ Array.isArray(resource.properties[k])
+ ? resource.properties[k].map((v: string) =>
+ getPropertyChip(
+ k, v,
+ handleDelete(resource.uuid, k, v),
+ classes.tag))
+ : getPropertyChip(
+ k, resource.properties[k],
+ handleDelete(resource.uuid, k, resource.properties[k]),
+ classes.tag)
+ )
+ }
+ </DialogContent>
+ <DialogActions>
+ <Button
+ variant='text'
+ color='primary'
+ onClick={closeDialog}>
+ Close
+ </Button>
+ </DialogActions>
+ </Dialog>
+ )
+ ));
diff --git a/src/views-components/resource-properties-form/resource-properties-form.tsx b/src/views-components/resource-properties-form/resource-properties-form.tsx
index 38d76e46..94a3c955 100644
--- a/src/views-components/resource-properties-form/resource-properties-form.tsx
+++ b/src/views-components/resource-properties-form/resource-properties-form.tsx
@@ -11,16 +11,18 @@ import { ProgressButton } from 'components/progress-button/progress-button';
import { GridClassKey } from '@material-ui/core/Grid';
export interface ResourcePropertiesFormData {
+ uuid: string;
[PROPERTY_KEY_FIELD_NAME]: string;
[PROPERTY_KEY_FIELD_ID]: string;
[PROPERTY_VALUE_FIELD_NAME]: string;
[PROPERTY_VALUE_FIELD_ID]: string;
}
-export type ResourcePropertiesFormProps = InjectedFormProps<ResourcePropertiesFormData> & WithStyles<GridClassKey>;
+export type ResourcePropertiesFormProps = {uuid: string; } & InjectedFormProps<ResourcePropertiesFormData, {uuid: string; }> & WithStyles<GridClassKey>;
-export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid, classes }: ResourcePropertiesFormProps ) =>
- <form data-cy='resource-properties-form' onSubmit={handleSubmit}>
+export const ResourcePropertiesForm = ({ handleSubmit, change, submitting, invalid, classes, uuid }: ResourcePropertiesFormProps ) => {
+ change('uuid', uuid); // Sets the uuid field to the uuid of the resource.
+ return <form data-cy='resource-properties-form' onSubmit={handleSubmit}>
<Grid container spacing={16} classes={classes}>
<Grid item xs>
<PropertyKeyField />
@@ -40,7 +42,7 @@ export const ResourcePropertiesForm = ({ handleSubmit, submitting, invalid, clas
</Button>
</Grid>
</Grid>
- </form>;
+ </form>};
export const Button = withStyles(theme => ({
root: { marginTop: theme.spacing.unit }
diff --git a/src/views/collection-panel/collection-panel.tsx b/src/views/collection-panel/collection-panel.tsx
index 794e093f..5aeaef18 100644
--- a/src/views/collection-panel/collection-panel.tsx
+++ b/src/views/collection-panel/collection-panel.tsx
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0
import React from 'react';
+import { Dispatch } from 'redux';
import {
StyleRulesCallback,
WithStyles,
@@ -11,22 +12,21 @@ import {
Grid,
Tooltip,
Typography,
- Card, CardHeader, CardContent,
+ Card
} from '@material-ui/core';
import { connect, DispatchProp } from "react-redux";
import { RouteComponentProps } from 'react-router';
import { ArvadosTheme } from 'common/custom-theme';
import { RootState } from 'store/store';
-import { MoreOptionsIcon, CollectionIcon, ReadOnlyIcon, CollectionOldVersionIcon } from 'components/icon/icon';
+import { MoreOptionsIcon, CollectionIcon, ReadOnlyIcon, CollectionOldVersionIcon, RenameIcon } from 'components/icon/icon';
import { DetailsAttribute } from 'components/details-attribute/details-attribute';
import { CollectionResource, getCollectionUrl } from 'models/collection';
import { CollectionPanelFiles } from 'views-components/collection-panel-files/collection-panel-files';
-import { CollectionTagForm } from './collection-tag-form';
-import { deleteCollectionTag, navigateToProcess, collectionPanelActions } from 'store/collection-panel/collection-panel-action';
+import { navigateToProcess, collectionPanelActions } from 'store/collection-panel/collection-panel-action';
import { getResource } from 'store/resources/resources';
import { openContextMenu, resourceUuidToContextMenuKind } from 'store/context-menu/context-menu-actions';
import { formatDate, formatFileSize } from "common/formatters";
-import { openDetailsPanel } from 'store/details-panel/details-panel-action';
+import { openDetailsPanel, openResourcePropertiesDialog } from 'store/details-panel/details-panel-action';
import { snackbarActions, SnackbarKind } from 'store/snackbar/snackbar-actions';
import { getPropertyChip } from 'views-components/resource-properties-form/property-chip';
import { IllegalNamingWarning } from 'components/warning/warning';
@@ -148,7 +148,6 @@ export const CollectionPanel = withStyles(styles)(
const { classes, item, dispatch, isWritable, isOldVersion, isLoadingFiles, tooManyFiles } = this.props;
const panelsData: MPVPanelState[] = [
{name: "Details"},
- {name: "Properties"},
{name: "Files"},
];
return item
@@ -203,37 +202,6 @@ export const CollectionPanel = withStyles(styles)(
</Grid>
</Card>
</MPVPanelContent>
- <MPVPanelContent xs="auto" data-cy='collection-properties-panel'>
- <Card className={classes.propertiesCard}>
- <CardHeader title="Properties" />
- <CardContent><Grid container>
- {isWritable && <Grid item xs={12}>
- <CollectionTagForm />
- </Grid>}
- <Grid item xs={12}>
- {Object.keys(item.properties).length > 0
- ? Object.keys(item.properties).map(k =>
- Array.isArray(item.properties[k])
- ? item.properties[k].map((v: string) =>
- getPropertyChip(
- k, v,
- isWritable
- ? this.handleDelete(k, v)
- : undefined,
- classes.tag))
- : getPropertyChip(
- k, item.properties[k],
- isWritable
- ? this.handleDelete(k, item.properties[k])
- : undefined,
- classes.tag)
- )
- : <div className={classes.centeredLabel}>No properties set on this collection.</div>
- }
- </Grid>
- </Grid></CardContent>
- </Card>
- </MPVPanelContent>
<MPVPanelContent xs>
<Card className={classes.filesCard}>
<CollectionPanelFiles
@@ -275,10 +243,6 @@ export const CollectionPanel = withStyles(styles)(
kind: SnackbarKind.SUCCESS
}))
- handleDelete = (key: string, value: string) => () => {
- this.props.dispatch<any>(deleteCollectionTag(key, value));
- }
-
openCollectionDetails = (e: React.MouseEvent<HTMLElement>) => {
const { item } = this.props;
if (item) {
@@ -295,9 +259,25 @@ export const CollectionPanel = withStyles(styles)(
)
);
-export const CollectionDetailsAttributes = (props: { item: CollectionResource, twoCol: boolean, classes?: Record<CssRules, string>, showVersionBrowser?: () => void }) => {
+interface CollectionDetailsActionProps {
+ onClick: () => void;
+}
+
+interface CollectionDetailsProps {
+ item: CollectionResource;
+ classes?: any;
+ twoCol?: boolean;
+ showVersionBrowser?: () => void;
+}
+
+const mapDispatchToProps = (dispatch: Dispatch) => ({
+ onClick: () => dispatch<any>(openResourcePropertiesDialog()),
+});
+
+export const CollectionDetailsAttributes = connect(null, mapDispatchToProps)(
+(props: CollectionDetailsProps & CollectionDetailsActionProps) => {
const item = props.item;
- const classes = props.classes || { label: '', value: '', button: '' };
+ const classes = props.classes || { label: '', value: '', button: '', tag: '' };
const isOldVersion = item && item.currentVersionUuid !== item.uuid;
const mdSize = props.twoCol ? 6 : 12;
const showVersionBrowser = props.showVersionBrowser;
@@ -361,5 +341,22 @@ export const CollectionDetailsAttributes = (props: { item: CollectionResource, t
<DetailsAttribute classLabel={classes.label} classValue={classes.value}
label='Storage classes' value={item.storageClassesDesired.join(', ')} />
</Grid>
+ <Grid item xs={12} md={mdSize}>
+ <DetailsAttribute classLabel={classes.label} classValue={classes.value}
+ label='Properties'>
+ { !props.twoCol
+ ? <div onClick={props.onClick}>
+ <RenameIcon className={classes.editIcon} />
+ </div>
+ : '' }
+ </DetailsAttribute>
+ { Object.keys(item.properties).length > 0
+ ? Object.keys(item.properties).map(k =>
+ Array.isArray(item.properties[k])
+ ? item.properties[k].map((v: string) =>
+ getPropertyChip(k, v, undefined, classes.tag))
+ : getPropertyChip(k, item.properties[k], undefined, classes.tag))
+ : <div className={classes.value}>No properties</div> }
+ </Grid>
</Grid>;
-};
+});
diff --git a/src/views/collection-panel/collection-tag-form.tsx b/src/views/collection-panel/collection-tag-form.tsx
deleted file mode 100644
index 6d9cbd59..00000000
--- a/src/views/collection-panel/collection-tag-form.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) The Arvados Authors. All rights reserved.
-//
-// SPDX-License-Identifier: AGPL-3.0
-
-import { reduxForm, reset } from 'redux-form';
-import { createCollectionTag, COLLECTION_TAG_FORM_NAME } from 'store/collection-panel/collection-panel-action';
-import { ResourcePropertiesForm, ResourcePropertiesFormData } from 'views-components/resource-properties-form/resource-properties-form';
-import { withStyles } from '@material-ui/core';
-import { Dispatch } from 'redux';
-
-const Form = withStyles(({ spacing }) => ({ container: { marginBottom: spacing.unit * 2 } }))(ResourcePropertiesForm);
-
-export const CollectionTagForm = reduxForm<ResourcePropertiesFormData>({
- form: COLLECTION_TAG_FORM_NAME,
- onSubmit: (data, dispatch: Dispatch) => {
- dispatch<any>(createCollectionTag(data));
- dispatch(reset(COLLECTION_TAG_FORM_NAME));
- }
-})(Form);
diff --git a/src/views/workbench/workbench.tsx b/src/views/workbench/workbench.tsx
index 25d70776..ea24c872 100644
--- a/src/views/workbench/workbench.tsx
+++ b/src/views/workbench/workbench.tsx
@@ -54,7 +54,7 @@ import { AdvancedTabDialog } from 'views-components/advanced-tab-dialog/advanced
import { ProcessInputDialog } from 'views-components/process-input-dialog/process-input-dialog';
import { VirtualMachineUserPanel } from 'views/virtual-machine-panel/virtual-machine-user-panel';
import { VirtualMachineAdminPanel } from 'views/virtual-machine-panel/virtual-machine-admin-panel';
-import { ProjectPropertiesDialog } from 'views-components/project-properties-dialog/project-properties-dialog';
+import { ResourcePropertiesDialog } from 'views-components/resource-properties-dialog/resource-properties-dialog';
import { RepositoriesPanel } from 'views/repositories-panel/repositories-panel';
import { KeepServicePanel } from 'views/keep-service-panel/keep-service-panel';
import { ApiClientAuthorizationPanel } from 'views/api-client-authorization-panel/api-client-authorization-panel';
@@ -242,7 +242,7 @@ export const WorkbenchPanel =
<PartialCopyToCollectionDialog />
<ProcessCommandDialog />
<ProcessInputDialog />
- <ProjectPropertiesDialog />
+ <ResourcePropertiesDialog />
<RestoreCollectionVersionDialog />
<RemoveApiClientAuthorizationDialog />
<RemoveGroupDialog />
commit 1be05c9f56147aa776819a4f66bf021cb4556874
Author: Lucas Di Pentima <lucas.dipentima at curii.com>
Date: Tue Dec 14 18:27:49 2021 -0300
18219: Extracts 'properties' into a separate interface for typing reasons.
We'll be treating Collections, Projects, etc as "ResourcesWithProperties".
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima at curii.com>
diff --git a/src/models/collection.ts b/src/models/collection.ts
index baa25c7a..3effe672 100644
--- a/src/models/collection.ts
+++ b/src/models/collection.ts
@@ -2,13 +2,16 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { ResourceKind, TrashableResource } from "./resource";
+import {
+ ResourceKind,
+ TrashableResource,
+ ResourceWithProperties
+} from "./resource";
-export interface CollectionResource extends TrashableResource {
+export interface CollectionResource extends TrashableResource, ResourceWithProperties {
kind: ResourceKind.COLLECTION;
name: string;
description: string;
- properties: any;
portableDataHash: string;
manifestText: string;
replicationDesired: number;
diff --git a/src/models/container-request.ts b/src/models/container-request.ts
index 9a57a41d..99ec4cf0 100644
--- a/src/models/container-request.ts
+++ b/src/models/container-request.ts
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { Resource, ResourceKind } from "./resource";
+import { Resource, ResourceKind, ResourceWithProperties } from "./resource";
import { MountType } from "models/mount-types";
import { RuntimeConstraints } from './runtime-constraints';
import { SchedulingParameters } from './scheduling-parameters';
@@ -13,11 +13,10 @@ export enum ContainerRequestState {
FINAL = "Final"
}
-export interface ContainerRequestResource extends Resource {
+export interface ContainerRequestResource extends Resource, ResourceWithProperties {
kind: ResourceKind.CONTAINER_REQUEST;
name: string;
description: string;
- properties: any;
state: ContainerRequestState;
requestingContainerUuid: string | null;
containerUuid: string | null;
diff --git a/src/models/group.ts b/src/models/group.ts
index a0c22212..3f3656cc 100644
--- a/src/models/group.ts
+++ b/src/models/group.ts
@@ -2,14 +2,19 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { ResourceKind, TrashableResource, ResourceObjectType, RESOURCE_UUID_REGEX } from "./resource";
+import {
+ ResourceKind,
+ ResourceWithProperties,
+ RESOURCE_UUID_REGEX,
+ ResourceObjectType,
+ TrashableResource
+} from "./resource";
-export interface GroupResource extends TrashableResource {
+export interface GroupResource extends TrashableResource, ResourceWithProperties {
kind: ResourceKind.GROUP;
name: string;
groupClass: GroupClass | null;
description: string;
- properties: any;
writableBy: string[];
ensure_unique_name: boolean;
}
diff --git a/src/models/link.ts b/src/models/link.ts
index 828dced2..f55c5ccf 100644
--- a/src/models/link.ts
+++ b/src/models/link.ts
@@ -2,16 +2,15 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { Resource, ResourceKind } from 'models/resource';
+import { Resource, ResourceKind, ResourceWithProperties } from 'models/resource';
-export interface LinkResource extends Resource {
+export interface LinkResource extends Resource, ResourceWithProperties {
headUuid: string;
headKind: ResourceKind;
tailUuid: string;
tailKind: string;
linkClass: string;
name: string;
- properties: any;
kind: ResourceKind.LINK;
}
diff --git a/src/models/log.ts b/src/models/log.ts
index 55967f88..3397993b 100644
--- a/src/models/log.ts
+++ b/src/models/log.ts
@@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: AGPL-3.0
-import { Resource } from "./resource";
+import { Resource, ResourceWithProperties } from "./resource";
import { ResourceKind } from 'models/resource';
export enum LogEventType {
@@ -18,11 +18,10 @@ export enum LogEventType {
STDERR = 'stderr',
}
-export interface LogResource extends Resource {
+export interface LogResource extends Resource, ResourceWithProperties {
kind: ResourceKind.LOG;
objectUuid: string;
eventAt: string;
eventType: string;
summary: string;
- properties: any;
}
diff --git a/src/models/resource.ts b/src/models/resource.ts
index c94c4b25..fd867277 100644
--- a/src/models/resource.ts
+++ b/src/models/resource.ts
@@ -14,6 +14,10 @@ export interface Resource {
etag: string;
}
+export interface ResourceWithProperties extends Resource {
+ properties: any;
+}
+
export interface EditableResource extends Resource {
isEditable: boolean;
}
diff --git a/src/models/tag.ts b/src/models/tag.ts
index f4e5854a..fa36486d 100644
--- a/src/models/tag.ts
+++ b/src/models/tag.ts
@@ -10,6 +10,7 @@ export interface TagResource extends LinkResource {
}
export interface TagProperty {
+ uuid: string;
key: string;
keyID?: string;
value: string;
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list