Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STSMACOM-836 omit "+ New" button when user lacks permission #1477

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* `DateRangeFilter` - add the optional `hideCalendarButton` property to hide the calendar icon button; add error message for invalid YYYY format. Refs STSMACOM-855.
* Display `System` user when there is no `updatedByUserId` field in metadata. Refs STSMACOM-858.
* Fix `<DateRangeFilter>` only shows an error in one of failed inputs. Fixes STSMACOM-857.
* Omit (don't disable) "+ New" button in `<EditableList>` when user lacks permission. Refs STSMACOM-836.

## [9.1.3](https://github.com/folio-org/stripes-smart-components/tree/v9.1.3) (2024-05-06)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v9.1.2...v9.1.3)
Expand Down
7 changes: 3 additions & 4 deletions lib/EditableList/EditableListForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ class EditableListForm extends React.Component {
const adjustedColumnMapping = { ...columnMapping, ...actionColumnMapping };
const activeRowIndex = this.state.status.findIndex(({ editing }) => editing);
const isEditing = activeRowIndex !== -1;
const isCreateDisabled = isEditing || !canCreate;

const cellFormatters = Object.assign({}, this.props.formatter, { actions: item => this.getActions(fields, item) });
const contentData = this.getValues(fields);
Expand All @@ -713,7 +712,7 @@ class EditableListForm extends React.Component {
{
name: 'new',
handler: () => {
if (!isCreateDisabled) this.onAdd(fields);
if (!isEditing) this.onAdd(fields);
},
},
{
Expand Down Expand Up @@ -745,12 +744,12 @@ class EditableListForm extends React.Component {
<Col xs>
<Headline size="medium" margin="none">{this.props.label}</Headline>
</Col>
{ (editable && !hideCreateButton) &&
{ (editable && canCreate && !hideCreateButton) &&
<Col xs>
<Row end="xs">
<Col xs>
<Button
disabled={isCreateDisabled}
disabled={isEditing}
marginBottom0
id={`clickable-add-${this.testingId}`}
onClick={() => this.onAdd(fields)}
Expand Down
Loading