Skip to content

Commit

Permalink
[Upd #18] Updated buttons hiding dependent on user role
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope authored and blcham committed Dec 17, 2023
1 parent 39702f4 commit a16f664
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions js/components/record/Record.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,40 +106,38 @@ class Record extends React.Component {
const {record, recordSaved, formgen} = this.props;

return <div className="mt-3 text-center">
{this._renderRoleSpecificButtons()}
<Button className="mx-1" variant='danger' size='sm'
disabled={formgen.status === ACTION_STATUS.PENDING || recordSaved.status === ACTION_STATUS.PENDING
|| !this.state.isFormValid || !record.state.isComplete()|| record.phase === RECORD_PHASE.REJECTED}
hidden={record.phase === RECORD_PHASE.COMPLETED ||
EXTENSIONS === EXTENSION_CONSTANTS.OPERATOR}
onClick={this.props.handlers.onReject}>
{this.i18n('reject')}{recordSaved.status === ACTION_STATUS.PENDING && <LoaderSmall/>}
</Button>

<Button className="mx-1" variant='success' size='sm'
disabled={formgen.status === ACTION_STATUS.PENDING || recordSaved.status === ACTION_STATUS.PENDING
|| !this.state.isFormValid || !record.state.isComplete() || record.phase === RECORD_PHASE.COMPLETED}
hidden={record.phase === RECORD_PHASE.COMPLETED ||
record.phase === RECORD_PHASE.PUBLISHED}
onClick={this.props.handlers.onComplete}>
{this.i18n('complete')}{recordSaved.status === ACTION_STATUS.PENDING && <LoaderSmall/>}
</Button>

<Button className="mx-1" variant='success' size='sm'
disabled={formgen.status === ACTION_STATUS.PENDING || recordSaved.status === ACTION_STATUS.PENDING
|| !this.state.isFormValid || !record.state.isComplete()}
hidden={(record.phase === RECORD_PHASE.COMPLETED && !this._isAdmin()) ||
record.phase === RECORD_PHASE.PUBLISHED}
onClick={this.props.handlers.onSave}>
{this.i18n('save')}{recordSaved.status === ACTION_STATUS.PENDING && <LoaderSmall/>}
</Button>
<Button className="mx-1" variant='link' size='sm'
hidden={record.phase === RECORD_PHASE.COMPLETED || record.phase === RECORD_PHASE.PUBLISHED}
onClick={this.props.handlers.onCancel}>{this.i18n('cancel')}</Button>
</div>
}

_renderRoleSpecificButtons() {
const {record, recordSaved, formgen} = this.props;

return <>
{EXTENSIONS === EXTENSION_CONSTANTS.SUPPLIER &&
<Button className="mx-1" variant='danger' size='sm'
disabled={formgen.status === ACTION_STATUS.PENDING || recordSaved.status === ACTION_STATUS.PENDING
|| !this.state.isFormValid || !record.state.isComplete()|| record.phase === RECORD_PHASE.REJECTED}
onClick={this.props.handlers.onReject}>
{this.i18n('reject')}{recordSaved.status === ACTION_STATUS.PENDING && <LoaderSmall/>}
</Button>
}
{EXTENSIONS === EXTENSION_CONSTANTS.OPERATOR &&
<Button className="mx-1" variant='success' size='sm'
disabled={formgen.status === ACTION_STATUS.PENDING || recordSaved.status === ACTION_STATUS.PENDING
|| !this.state.isFormValid || !record.state.isComplete() || record.phase === RECORD_PHASE.COMPLETED}
onClick={this.props.handlers.onComplete}>
{this.i18n('complete')}{recordSaved.status === ACTION_STATUS.PENDING && <LoaderSmall/>}
</Button>}
</>;
}

_renderInstitution() {
const record = this.props.record;
if (!record.institution) {
Expand Down

0 comments on commit a16f664

Please sign in to comment.