diff --git a/CHANGELOG.md b/CHANGELOG.md index 11c4af975..86e92a23d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ * DateRangeFilter - pass `requiredFields` argument to all calls of `validateDateRange`. STSMACOM-853. * Bump up `actions/upload-artifact@v2` to `actions/upload-artifact@v4`. Refs STSMACOM-854. * `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 `` only shows an error in one of failed inputs. Fixes STSMACOM-857. +* Omit (don't disable) "+ New" button in `` when user lacks permission. Refs STSMACOM-836. * Avoid deprecated `defaultProps` for functional components. Refs STSMACOM-835. ## [9.1.3](https://github.com/folio-org/stripes-smart-components/tree/v9.1.3) (2024-05-06) diff --git a/lib/ControlledVocab/ControlledVocab.js b/lib/ControlledVocab/ControlledVocab.js index 39d341d12..9aa65a413 100644 --- a/lib/ControlledVocab/ControlledVocab.js +++ b/lib/ControlledVocab/ControlledVocab.js @@ -476,7 +476,7 @@ class ControlledVocab extends React.Component { const { firstName, lastName = '' } = record.personal; const name = firstName ? `${lastName}, ${firstName}` : lastName; user = {name}; - } else if (metadata.updatedByUserId === SYSTEM_USER_ID) { + } else if (metadata.updatedByUserId === SYSTEM_USER_ID || !metadata.updatedByUserId) { user = ; } diff --git a/lib/ControlledVocab/tests/ControlledVocab-test.js b/lib/ControlledVocab/tests/ControlledVocab-test.js index bc3eeed16..ddb7cae11 100644 --- a/lib/ControlledVocab/tests/ControlledVocab-test.js +++ b/lib/ControlledVocab/tests/ControlledVocab-test.js @@ -46,7 +46,7 @@ describe('ControlledVocab', () => { // eslint-disable-next-line no-undef beforeEach(() => mountComponent(true, server, { translations })); - it('should have row count 6', () => cv.has({ rowCount: 6 })); + it('should have row count 7', () => cv.has({ rowCount: 7 })); describe('clicking Delete icon on first row', () => { beforeEach(async () => { @@ -79,7 +79,7 @@ describe('ControlledVocab', () => { // eslint-disable-next-line no-undef beforeEach(() => mountComponent(true, server, { labelSingular })); - it('should have row count 6', () => cv.has({ rowCount: 6 })); + it('should have row count 7', () => cv.has({ rowCount: 7 })); describe('clicking Delete icon on first row', () => { beforeEach(async function () { @@ -268,7 +268,7 @@ describe('ControlledVocab', () => { await mountComponent(false, server, { listSuppressor }); }); - it('should have row count 6', () => cv.has({ rowCount: 6 })); + it('should have row count 7', () => cv.has({ rowCount: 7 })); it('should render the row with last updated by user-1 without user firstname or lastname', async () => { await mcl.find(MultiColumnListCell({ row: 4, columnIndex: 3, content: '4/18/2019 by ' })).exists(); @@ -277,5 +277,9 @@ describe('ControlledVocab', () => { it('should render the row with last updated by system with "System" text', async () => { await mcl.find(MultiColumnListCell({ row: 6, columnIndex: 3, content: '1/9/2024 by System' })).exists(); }); + + it('should render the row with last updated by system without data about user', async () => { + await mcl.find(MultiColumnListCell({ row: 7, columnIndex: 3, content: '1/9/2024 by System' })).exists(); + }); }); }); diff --git a/lib/ControlledVocab/tests/mountComponent.js b/lib/ControlledVocab/tests/mountComponent.js index 3283ab567..f3a894939 100644 --- a/lib/ControlledVocab/tests/mountComponent.js +++ b/lib/ControlledVocab/tests/mountComponent.js @@ -69,6 +69,14 @@ export default async function (editable, server, props) { 'updatedDate' : '2024-01-09T01:49:57.008+00:00', 'updatedByUserId' : '00000000-0000-0000-0000-000000000000' } + }, { + 'id' : '40ee00ca-a518-4b49-be01-0638d0a4ac56', + 'name' : 'Københavns Universitet', + 'code' : 'KU', + 'metadata' : { + 'createdDate' : '2024-01-09T01:49:57.008+00:00', + 'updatedDate' : '2024-01-09T01:49:57.008+00:00', + } }]; server.get('location-units/institutions', (schema, request) => { diff --git a/lib/EditableList/EditableListForm.js b/lib/EditableList/EditableListForm.js index 1b926a228..3a0128c74 100644 --- a/lib/EditableList/EditableListForm.js +++ b/lib/EditableList/EditableListForm.js @@ -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); @@ -713,7 +712,7 @@ class EditableListForm extends React.Component { { name: 'new', handler: () => { - if (!isCreateDisabled) this.onAdd(fields); + if (!isEditing) this.onAdd(fields); }, }, { @@ -745,12 +744,12 @@ class EditableListForm extends React.Component { {this.props.label} - { (editable && !hideCreateButton) && + { (editable && canCreate && !hideCreateButton) &&