+++ /dev/null
-// 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
+++ /dev/null
-// 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
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,
} 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>;
{...props}
/>;
+const CreateCollectionPropertiesList = resourcePropertiesList(COLLECTION_CREATE_FORM_NAME);
+
const CollectionAddFields = () => <span>
<ResourceParentField />
<CollectionNameField />
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>;
{...props}
/>;
+const CreateProjectPropertiesList = resourcePropertiesList(PROJECT_CREATE_FORM_NAME);
+
const ProjectAddFields = () => <span>
<ResourceParentField />
<ProjectNameField />
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,
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>;
{...props}
/>;
+const UpdateCollectionPropertiesList = resourcePropertiesList(COLLECTION_UPDATE_FORM_NAME);
+
const CollectionEditFields = () => <span>
<CollectionNameField />
<CollectionDescriptionField />
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>;
/>;
};
+const UpdateProjectPropertiesList = resourcePropertiesList(PROJECT_UPDATE_FORM_NAME);
+
// Also used as "Group Edit Fields"
const ProjectEditFields = () => <span>
<ProjectNameField />
+++ /dev/null
-// 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
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';
}
});
-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 =>
</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