WithStyles,
} from '@material-ui/core';
import { RootState } from 'store/store';
-import { removePropertyFromCreateProjectForm, PROJECT_CREATE_FORM_SELECTOR, ProjectProperties } 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>(removePropertyFromCreateProjectForm(key, value))
-});
-
-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