Skip to content

Commit

Permalink
UIU-2081: Show user-readable message when user is not found (#1687)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuklis authored and zburke committed Apr 27, 2021
1 parent 127de9e commit 19668be
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change history for ui-users

## 6.0.4 IN PROGRESS

* Show user-readable message when user is not found. Fixes UIU-2081.

## [6.0.3](https://github.com/folio-org/ui-users/tree/v6.0.3) (2021-04-23)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v6.0.2...v6.0.3)

Expand All @@ -19,7 +23,6 @@

* Configure Jest/RTL. Refs UIU-2112.
* Lock stripes-cli to ~2.1.1, and thus stripes-webpack to ~1.1.0. Refs UIU-2137.
* Show user-readable message when user is not found. Fixes UIU-2081.
* Fix Custom Fields error message by adding a missing permission. Fixes UIU-2104.
* Fix Notify patron box behavior for New fee/fine when default patron notice is set. Refs UIU-2111.
* Fix disabling "Save & close" button for Manual patron block. Refs UIU-2123.
Expand Down
6 changes: 5 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/** @param {import('karma').Config} config */
module.exports = config => config.set({ client: { captureConsole: false } });
module.exports = config => config.set({
client: {
captureConsole: false
},
});
20 changes: 20 additions & 0 deletions src/components/ErrorPane/ErrorPane.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import PropTypes from 'prop-types';

import {
Pane,
Layout,
} from '@folio/stripes/components';

const ErrorPane = ({ children, ...props }) => (
<Pane defaultWidth="fill" {...props}>
<Layout element="p" className="textCentered">
{children}
</Layout>
</Pane>
);

ErrorPane.propTypes = {
children: PropTypes.node,
};

export default ErrorPane;
1 change: 1 addition & 0 deletions src/components/ErrorPane/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ErrorPane';
1 change: 1 addition & 0 deletions src/routes/UserRecordContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class UserRecordContainer extends React.Component {
const { path } = action.meta;
return refresh || (path && path.match(/link/));
},
throwErrors: false,
},
hasManualPatronBlocks: {
type: 'okapi',
Expand Down
19 changes: 19 additions & 0 deletions src/views/UserDetail/UserDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import RequestFeeFineBlockButtons from '../../components/RequestFeeFineBlockButt
import { departmentsShape } from '../../shapes';

import ExportFeesFinesReportButton from './components';
import ErrorPane from '../../components/ErrorPane';

class UserDetail extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -407,6 +408,10 @@ class UserDetail extends React.Component {
});
}

userNotFound = () => {
return this.props.resources?.selUser?.failed?.httpStatus === 404;
}

render() {
const {
resources,
Expand Down Expand Up @@ -459,6 +464,20 @@ class UserDetail extends React.Component {
.map(departmentId => departments.find(({ id }) => id === departmentId)?.name);
const accounts = resources?.accounts;

if (this.userNotFound()) {
return (
<ErrorPane
id="pane-user-not-found"
defaultWidth={paneWidth}
paneTitle={<FormattedMessage id="ui-users.information.userDetails" />}
dismissible
onClose={this.onClose}
>
<FormattedMessage id="ui-users.errors.userNotFound" />
</ErrorPane>
);
}

if (!user) {
return (
<LoadingPane
Expand Down
14 changes: 14 additions & 0 deletions test/bigtest/interactors/user-not-found-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {
interactor,
isPresent,
} from '@bigtest/interactor';

@interactor class UserNotFoundPage {
userNotFoundPanePresent = isPresent('#pane-user-not-found-content');

whenLoaded() {
return this.when(() => this.isPresent).timeout(5000);
}
}

export default new UserNotFoundPage('#pane-user-not-found');
5 changes: 5 additions & 0 deletions test/bigtest/interactors/user-view-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@ import proxyItemCSS from '../../../src/components/ProxyGroup/ProxyItem/ProxyItem
actionMenuEditUserButton = scoped('[data-test-actions-menu-edit]');
actionMenuExportFeeFineReport = scoped('[data-test-export-fee-fine-report]');
actionMenuExportFeeFineReportButton = scoped('[data-test-export-fee-fine-report]', ButtonInteractor);
userNotFoundPanePresent = isPresent('#pane-user-not-found-content');

callout = new CalloutInteractor();

whenLoaded() {
return this.when(() => this.isPresent).timeout(5000);
}

whenNotFoundPaneLoaded() {
return this.when(() => this.userNotFoundPanePresent);
}
}

export default new InstanceViewPage('[data-test-instance-details]');
29 changes: 29 additions & 0 deletions test/bigtest/tests/user-not-found-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
beforeEach,
describe,
it,
} from '@bigtest/mocha';
import { expect } from 'chai';

import setupApplication from '../helpers/setup-application';
import UserNotFoundPage from '../interactors/user-not-found-page';

describe('User not found', () => {
setupApplication();

describe('visit users details for not existing user', () => {
beforeEach(async function () {
this.server.get('/users/not-found', () => {
return new Response(404, {});
}, 404);

this.visit('/users/view/not-found');

await UserNotFoundPage.whenLoaded();
});

it('shows user not found pane', () => {
expect(UserNotFoundPage.userNotFoundPanePresent).to.equal(true);
});
});
});
1 change: 1 addition & 0 deletions translations/ui-users/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
"errors.sponsors.duplicateUserMessage": "Duplicate sponsor has been entered.",
"errors.reviewBeforeRenewal": "{message} Please review {policyName} before retrying renewal.",
"errors.loanNotRenewedReason": "Loan cannot be renewed because: {message}.",
"errors.userNotFound": "User not found",
"hide": "Hide",
"show": "Show",
"active": "Active",
Expand Down

0 comments on commit 19668be

Please sign in to comment.