Skip to content

Commit

Permalink
Merge branch 'master' into UIIN-2452
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrHladchenko1 authored Oct 24, 2023
2 parents 05d6335 + 33589f7 commit 527541f
Show file tree
Hide file tree
Showing 41 changed files with 173 additions and 61 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
* Edit instance success toast no longer shows the instance HRID. Fixes UIIN-2588.
* Show facet options, if they exist, after clicking the +More button. Refs UIIN-2533.
* If Shared & Held by facets were selected in the Browse search, then retain them in the Search lookup after clicking the record. Refs UIIN-2608.
* 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.
* Create new instance success toast no longer shows the instance HRID. Fixes UIIN-2635.
* Optimistic locking message not working for instances in non-consortial tenant. Fixes UIIN-2628.
* Enable/disable consortial holdings/item actions based on User permissions. Refs UIIN-2452.

## [10.0.0](https://github.com/folio-org/ui-inventory/tree/v10.0.0) (2023-10-13)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,13 @@ const ConsortialHoldings = ({
instance,
userTenantPermissions,
}) => {
const stripes = useStripes();
const pathToAccordion = ['consortialHoldings', '_state'];
const instanceId = instance?.id;
const prevInstanceId = useRef(instanceId);

const stripes = useStripes();
const prevInstanceId = useRef(instanceId);
const { consortiaTenantsById } = useContext(DataContext);

const { tenants } = useSearchForShadowInstanceTenants({ instanceId });

const memberTenants = tenants
.map(tenant => consortiaTenantsById[tenant.id])
.filter(tenant => !tenant?.isCentral && (tenant?.id !== stripes.okapi.tenant))
.sort((a, b) => a.name.localeCompare(b.name));

const pathToAccordion = ['consortialHoldings', '_state'];
const [isConsortialAccOpen, setConsortialAccOpen] = useHoldingsAccordionState({ instanceId, pathToAccordion });

useEffect(() => {
Expand All @@ -49,6 +42,13 @@ const ConsortialHoldings = ({
}
}, [instanceId]);

if (!consortiaTenantsById) return null;

const memberTenants = tenants
.map(tenant => consortiaTenantsById[tenant.id])
.filter(tenant => !tenant?.isCentral && (tenant?.id !== stripes.okapi.tenant))
.sort((a, b) => a.name.localeCompare(b.name));

return (
<IfInterface name="consortia">
<Accordion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ const InstanceTitleData = ({
}) => {
const precedingTitles = useMemo(() => {
return checkIfArrayIsEmpty(instance.precedingTitles);
}, [instance]);
}, [instance.precedingTitles]);
const succeedingTitles = useMemo(() => {
return checkIfArrayIsEmpty(instance.succeedingTitles);
}, [instance]);
}, [instance.succeedingTitles]);
const seriesStatements = useMemo(() => {
return checkIfArrayIsEmpty(instance.series);
}, [instance.series]);

return (
<Accordion
Expand Down Expand Up @@ -67,7 +70,7 @@ const InstanceTitleData = ({
</Row>

<TitleSeriesStatements
seriesStatements={instance.series}
seriesStatements={seriesStatements}
source={instance.source}
segment={segment}
/>
Expand Down
10 changes: 4 additions & 6 deletions src/Instance/InstanceEdit/InstanceEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,20 @@ const InstanceEdit = ({
}, [callout, goBack]);

const onError = async error => {
const parsedError = await parseHttpError(error);
const response = await error.response;
const parsedError = await parseHttpError(response);
setHttpError(parsedError);
};

const isMemberTenant = checkIfUserInMemberTenant(stripes);
const tenantId = (isMemberTenant && instance?.shared) ? stripes.user.user.consortium.centralTenantId : stripes.okapi.tenant;

const { mutateInstance } = useInstanceMutation({
options: { onSuccess, onError },
tenantId,
});
const { mutateInstance } = useInstanceMutation({ tenantId });

const onSubmit = useCallback((initialInstance) => {
const updatedInstance = marshalInstance(initialInstance, identifierTypesByName);

return mutateInstance(updatedInstance);
return mutateInstance(updatedInstance, { onSuccess, onError });
}, [mutateInstance]);

if (isInstanceLoading) return <LoadingView />;
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
4 changes: 2 additions & 2 deletions src/ViewInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,9 +960,9 @@ class ViewInstance extends React.Component {

<Callout ref={this.calloutRef} />

{this.state.afterCreate &&
{this.state.afterCreate && !isEmpty(instance) &&
<CalloutRenderer
message={<FormattedMessage id="ui-inventory.instance.successfullySaved" values={{ hrid: instance?.hrid }} />}
message={<FormattedMessage id="ui-inventory.instance.successfullySaved" values={{ hrid: instance.hrid }} />}
/>
}

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
4 changes: 2 additions & 2 deletions src/edit/InstanceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,15 @@ class InstanceForm extends React.Component {
}),
) : [];

const statisticalCodeOptions = referenceTables.statisticalCodes
const statisticalCodeOptions = referenceTables.statisticalCodes ? referenceTables.statisticalCodes
.map(
code => ({
label: refLookup(referenceTables.statisticalCodeTypes, code.statisticalCodeTypeId).name + ': ' + code.code + ' - ' + code.name,
value: code.id,
selected: code.id === initialValues.statisticalCodeId,
})
)
.sort((a, b) => a.label.localeCompare(b.label));
.sort((a, b) => a.label.localeCompare(b.label)) : [];

// Since preceding/succeeding title relationships are split out from other parent/child instances,
// we don't want the type selection box for parent/child to include the preceding-succeeding type
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useInstanceMutation/useInstanceMutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ import { useTenantKy } from '../../common';
const useInstanceMutation = ({ tenantId, options = {} }) => {
const ky = useTenantKy({ tenantId });

const { mutateAsync } = useMutation({
const { mutate } = useMutation({
mutationFn: (instance) => {
const kyMethod = instance.id ? 'put' : 'post';
const kyPath = instance.id ? `inventory/instances/${instance.id}` : 'inventory/instances';

return ky[kyMethod](kyPath, { json: instance });
return ky[kyMethod](kyPath, { json: instance }).json();
},
...options,
});

return {
mutateInstance: mutateAsync,
mutateInstance: mutate,
};
};

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
5 changes: 4 additions & 1 deletion translations/ui-inventory/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/ber.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/cs_CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/en_GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/en_SE.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/es_419.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
5 changes: 4 additions & 1 deletion translations/ui-inventory/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -829,5 +829,8 @@
"shareLocalInstance.toast.successful": "Local instance <b>{instanceTitle}</b> has been successfully shared",
"filters.tenantId": "Held by",
"permission.consortia.inventory.share.local.instance": "Inventory: Share local instance with consortium",
"consortialHoldings": "Consortial holdings"
"consortialHoldings": "Consortial holdings",
"unlinkLocalMarcAuthorities.modal.header": "Linked to local authorities",
"unlinkLocalMarcAuthorities.modal.message": "If you proceed with sharing this instance, then <b>{linkedAuthoritiesLength}</b> bibliographic fields linked to local authority records will retain authorized values but will become uncontrolled",
"unlinkLocalMarcAuthorities.modal.proceed": "Proceed"
}
Loading

0 comments on commit 527541f

Please sign in to comment.