From f288bc3c4150bcffd3ce61855464badbfbfd7a06 Mon Sep 17 00:00:00 2001 From: pkupczyk <piotr.kupczyk@id.ethz.ch> Date: Sun, 22 Dec 2019 15:36:37 +0100 Subject: [PATCH] SSDM-7583 : ObjectTypeForm - fix a problem when 'Add property' and 'Remove' buttons where enabled when a type form parameter was in focus --- .../types/objectType/ObjectType.jsx | 5 +---- .../types/objectType/ObjectTypeButtons.jsx | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/openbis_ng_ui/src/js/components/types/objectType/ObjectType.jsx b/openbis_ng_ui/src/js/components/types/objectType/ObjectType.jsx index 38605fd2194..679e93880a8 100644 --- a/openbis_ng_ui/src/js/components/types/objectType/ObjectType.jsx +++ b/openbis_ng_ui/src/js/components/types/objectType/ObjectType.jsx @@ -213,10 +213,7 @@ class ObjectType extends React.PureComponent { onAddProperty={this.handleAddProperty} onRemove={this.handleRemove} onSave={this.handleSave} - addSectionEnabled={true} - addPropertyEnabled={selection !== null} - removeEnabled={selection !== null} - saveEnabled={true} + selection={selection} /> <ObjectTypeDialogRemoveSection open={removeSectionDialogOpen} diff --git a/openbis_ng_ui/src/js/components/types/objectType/ObjectTypeButtons.jsx b/openbis_ng_ui/src/js/components/types/objectType/ObjectTypeButtons.jsx index 909bebc8f96..d3164980eec 100644 --- a/openbis_ng_ui/src/js/components/types/objectType/ObjectTypeButtons.jsx +++ b/openbis_ng_ui/src/js/components/types/objectType/ObjectTypeButtons.jsx @@ -16,6 +16,14 @@ const styles = theme => ({ }) class ObjectTypeButtons extends React.PureComponent { + isSectionOrPropertySelected() { + const { selection } = this.props + return ( + selection && + (selection.type === 'property' || selection.type === 'section') + ) + } + render() { logger.log(logger.DEBUG, 'ObjectTypeButtons.render') @@ -24,11 +32,7 @@ class ObjectTypeButtons extends React.PureComponent { onAddSection, onAddProperty, onRemove, - onSave, - addSectionEnabled, - addPropertyEnabled, - removeEnabled, - saveEnabled + onSave } = this.props return ( @@ -37,7 +41,6 @@ class ObjectTypeButtons extends React.PureComponent { classes={{ root: classes.button }} variant='contained' color='secondary' - disabled={!addSectionEnabled} onClick={onAddSection} > Add Section @@ -46,7 +49,7 @@ class ObjectTypeButtons extends React.PureComponent { classes={{ root: classes.button }} variant='contained' color='secondary' - disabled={!addPropertyEnabled} + disabled={!this.isSectionOrPropertySelected()} onClick={onAddProperty} > Add Property @@ -55,7 +58,7 @@ class ObjectTypeButtons extends React.PureComponent { classes={{ root: classes.button }} variant='contained' color='secondary' - disabled={!removeEnabled} + disabled={!this.isSectionOrPropertySelected()} onClick={onRemove} > Remove @@ -64,7 +67,6 @@ class ObjectTypeButtons extends React.PureComponent { classes={{ root: classes.button }} variant='contained' color='primary' - disabled={!saveEnabled} onClick={onSave} > Save -- GitLab