Skip to content

Commit

Permalink
UIIN-2634: Remove error when search for an item (#2318)
Browse files Browse the repository at this point in the history
* UIIN-2634: Remove error when search for an item

* UIIN-2634: Fix tests
  • Loading branch information
OleksandrHladchenko1 authored Oct 23, 2023
1 parent 90f2bff commit 4054062
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* Instance. Series heading has vanished in detailed view. Fixes UIIN-2601.
* Remove error message after switch from Instance Edit screen to another app. Fixes UIIN-2600.
* Enable/disable consortial holdings/item actions based on User permissions. Refs UIIN-2452.
* User receives an error when searching for an item in the Inventory app. Fixes UIIN-2634.

## [10.0.0](https://github.com/folio-org/ui-inventory/tree/v10.0.0) (2023-10-13)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v9.4.12...v10.0.0)
Expand Down
3 changes: 2 additions & 1 deletion src/ViewHoldingsRecord.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,10 @@ class ViewHoldingsRecord extends React.Component {
referenceTables,
goTo,
stripes,
location: { state: { tenantFrom } },
location,
} = this.props;
const { instance } = this.state;
const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant;

if (this.isAwaitingResource()) return <LoadingView />;

Expand Down
18 changes: 15 additions & 3 deletions src/components/InstancesList/InstancesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import saveAs from 'file-saver';
import moment from 'moment';
import classnames from 'classnames';
import { stringify } from 'query-string';

import {
Pluggable,
Expand Down Expand Up @@ -134,6 +135,7 @@ class InstancesList extends React.Component {
}),
stripes: PropTypes.object.isRequired,
history: PropTypes.shape({
push: PropTypes.func,
listen: PropTypes.func,
replace: PropTypes.func,
}),
Expand Down Expand Up @@ -956,8 +958,9 @@ class InstancesList extends React.Component {
const {
parentResources,
parentMutator: { itemsByQuery },
goTo,
getParams,
stripes,
history,
} = this.props;
const { query, qindex } = parentResources?.query ?? {};
const { searchInProgress } = this.state;
Expand All @@ -973,7 +976,10 @@ class InstancesList extends React.Component {
}

itemsByQuery.reset();
const items = await itemsByQuery.GET({ params: { query: itemQuery } });
const items = await itemsByQuery.GET({
params: { query: itemQuery },
tenant: stripes.okapi.tenant,
});

this.setState({ searchInProgress: false });

Expand All @@ -984,7 +990,13 @@ class InstancesList extends React.Component {
}

const { id, holdingsRecordId } = items[0];
goTo(`/inventory/view/${instance.id}/${holdingsRecordId}/${id}`, getParams());
const search = stringify(getParams());

history.push({
pathname: `/inventory/view/${instance.id}/${holdingsRecordId}/${id}`,
search,
state: { tenantTo: stripes.okapi.tenant },
});

return null;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/InstancesList/InstancesList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ describe('InstancesList', () => {
params: {
query: `${option}=="${_query}"`,
},
tenant: 'diku',
});
});
});
Expand Down
3 changes: 2 additions & 1 deletion src/routes/ItemRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ class ItemRoute extends React.Component {
onClose = () => {
const {
stripes,
location: { state: { tenantFrom } },
location,
} = this.props;
const tenantFrom = location?.state?.tenantFrom || stripes.okapi.tenant;

switchAffiliation(stripes, tenantFrom, this.goBack);
}
Expand Down

0 comments on commit 4054062

Please sign in to comment.