Skip to content

Commit

Permalink
Merge branch 'master' into STSMACOM-835
Browse files Browse the repository at this point in the history
  • Loading branch information
zburke authored Oct 3, 2024
2 parents 1267791 + 7524e80 commit c2a075a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<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.
* 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)
Expand Down
2 changes: 1 addition & 1 deletion lib/ControlledVocab/ControlledVocab.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ 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) {
} else if (metadata.updatedByUserId === SYSTEM_USER_ID || !metadata.updatedByUserId) {
user = <FormattedMessage id="stripes-smart-components.system" />;
}

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 @@ -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 () => {
Expand Down Expand Up @@ -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 () {
Expand Down Expand Up @@ -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();
Expand All @@ -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();
});
});
});
8 changes: 8 additions & 0 deletions lib/ControlledVocab/tests/mountComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
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
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ const TheComponent = ({
};

setFilterValue({
...defaultFilterState,
...filterValue,
errors: {
...defaultFilterState.errors, // reset filter errors on every change
...filterValue.errors,
[errorName]: dateIsInvalid
},
selectedValues: newSelectedValues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ describe('DateRangeFilter', () => {
});
});

describe('and both dates are invalid', () => {
beforeEach(async () => {
await startPicker.fillIn('1999-13-32');
await endPicker.fillIn('1999-13-32');
});

it('should display corresponding error below start date input', () => startPicker.find(ErrorInteractor(invalidMessage)).exists());
it('should display corresponding error below end date input', () => endPicker.find(ErrorInteractor(invalidMessage)).exists());
});

describe('when start date is missing and "Apply" button was clicked', () => {
beforeEach(async () => {
await endPicker.fillIn('2005-01-03');
Expand Down

0 comments on commit c2a075a

Please sign in to comment.