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 38605fd2194256299a4ce946f7fb562b9d4c7bc3..679e93880a8be4ab65df2dbd17f0574f7a832c4c 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 909bebc8f9606a9e465a04bcedd401c5f2b4ec89..d3164980eec25a30e62e593aa219b3e0acd61a97 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