Skip to content

Commit

Permalink
STSMACOM-797 <ControlledVocab> - last updated by column - show "Sys…
Browse files Browse the repository at this point in the history
…tem" when items are created by system user
  • Loading branch information
BogdanDenis committed Jan 15, 2024
1 parent 6ebd303 commit d2de249
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* `<EditCustomFieldsSettings>` now passes the `entityType` when making PUT requests to `/custom-fields`. Refs FCFIELDS-44.
* Added `tenant` prop to `<ControlledVocab>`. Refs STSMACOM-794.
* Use the default match and search option in Advanced search when they are not entered. Refs STSMACOM-793.
* `<ControlledVocab>` - last updated by column - show "System" when items are created by system user. Refs STSMACOM-797.

## [9.0.0](https://github.com/folio-org/stripes-smart-components/tree/v9.0.0) (2023-10-11)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v8.0.0...v9.0.0)
Expand Down
4 changes: 4 additions & 0 deletions lib/ControlledVocab/ControlledVocab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import EditableList from '../EditableList';
import css from './ControlledVocab.css';
import makeRefdataActuatorsBoundTo from './actuators-refdata';

const SYSTEM_USER_ID = '00000000-0000-0000-0000-000000000000';

const getTenantFromRESTResource = (queryParams, pathComponents, resourceValues, logger, props) => {
const {
tenant,
Expand Down Expand Up @@ -444,6 +446,8 @@ class ControlledVocab extends React.Component {
const { firstName, lastName = '' } = record.personal;
const name = firstName ? `${lastName}, ${firstName}` : lastName;
user = <Link to={`/users/view/${metadata.updatedByUserId}`}>{name}</Link>;
} else if (metadata.updatedByUserId === SYSTEM_USER_ID) {
user = <FormattedMessage id="stripes-smart-components.system" />;
}

return (
Expand Down
10 changes: 7 additions & 3 deletions lib/ControlledVocab/tests/ControlledVocab-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('ControlledVocab', () => {
// eslint-disable-next-line no-undef
beforeEach(() => mountComponent(true, server, { translations }));

it('should have row count 5', () => cv.has({ rowCount: 5 }));
it('should have row count 6', () => cv.has({ rowCount: 6 }));

describe('clicking Delete icon on first row', () => {
beforeEach(async () => {
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('ControlledVocab', () => {
// eslint-disable-next-line no-undef
beforeEach(() => mountComponent(true, server, { labelSingular }));

it('should have row count 5', () => cv.has({ rowCount: 5 }));
it('should have row count 6', () => cv.has({ rowCount: 6 }));

describe('clicking Delete icon on first row', () => {
beforeEach(async () => {
Expand Down Expand Up @@ -232,10 +232,14 @@ describe('ControlledVocab', () => {
await mountComponent(false, server, { listSuppressor });
});

it('should have row count 5', () => cv.has({ rowCount: 5 }));
it('should have row count 6', () => cv.has({ rowCount: 6 }));

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();
});

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();
});
});
});
12 changes: 11 additions & 1 deletion lib/ControlledVocab/tests/mountComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,18 @@ export default async function (editable, server, props) {
'updatedDate' : '2019-04-18T16:41:36.806+0000',
'updatedByUserId' : 'user-2'
}
}, {
'id' : '40ee00ca-a518-4b49-be01-0638d0a4ac57',
'name' : 'Københavns Universitet',
'code' : 'KU',
'metadata' : {
'createdDate' : '2024-01-09T01:49:57.008+00:00',
'createdByUserId' : '00000000-0000-0000-0000-000000000000',
'updatedDate' : '2024-01-09T01:49:57.008+00:00',
'updatedByUserId' : '00000000-0000-0000-0000-000000000000'
}
}],
'totalRecords' : 5
'totalRecords' : 6
});
});

Expand Down

0 comments on commit d2de249

Please sign in to comment.