diff --git a/CHANGELOG.md b/CHANGELOG.md index fd6d2f173..e951229f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ## [10.0.4] IN PROGRESS * Fetch sharing of local instance status in the context of member tenant. Refs UIIN-2680. +* Handle errors when sharing local instances failed. Refs UIIN-2682. ## [10.0.3] IN PROGRESS diff --git a/src/ViewInstance.js b/src/ViewInstance.js index 03d57e728..3802edda1 100644 --- a/src/ViewInstance.js +++ b/src/ViewInstance.js @@ -443,20 +443,23 @@ class ViewInstance extends React.Component { this.setState({ isImportRecordModalOpened: false }); } + showUnsuccessfulShareInstanceCallout = (instanceTitle) => { + this.calloutRef.current?.sendCallout({ + type: 'error', + message: , + }); + } + checkInstanceSharingProgress = ({ sourceTenantId, instanceIdentifier }) => { return this.props.mutator.shareInstance.GET({ params: { sourceTenantId, instanceIdentifier }, }); } - waitForInstanceSharingComplete = ({ sourceTenantId, instanceIdentifier, instanceTitle }) => { + waitForInstanceSharingComplete = ({ sourceTenantId, instanceIdentifier }) => { return new Promise((resolve, reject) => { this.intervalId = setInterval(() => { const onError = error => { - this.calloutRef.current.sendCallout({ - type: 'error', - message: , - }); clearInterval(this.intervalId); reject(error); }; @@ -498,7 +501,7 @@ class ViewInstance extends React.Component { isInstanceSharing: true, }); - await this.waitForInstanceSharingComplete({ sourceTenantId, instanceIdentifier, instanceTitle }); + await this.waitForInstanceSharingComplete({ sourceTenantId, instanceIdentifier }); }) .then(async () => { await this.props.refetchInstance(); @@ -512,11 +515,9 @@ class ViewInstance extends React.Component { this.setState({ isUnlinkAuthoritiesModalOpen: false, isShareLocalInstanceModalOpen: false, + isInstanceSharing: false, }); - this.calloutRef.current?.sendCallout({ - type: 'error', - message: , - }); + this.showUnsuccessfulShareInstanceCallout(instanceTitle); }); } @@ -545,6 +546,13 @@ class ViewInstance extends React.Component { } else { this.handleShareLocalInstance(selectedInstance); } + }).catch(() => { + this.setState({ isShareLocalInstanceModalOpen: false }); + + this.calloutRef.current.sendCallout({ + type: 'error', + message: , + }); }); } @@ -931,27 +939,59 @@ class ViewInstance extends React.Component { const isInstanceLoading = isLoading || !instance || isCentralTenantPermissionsLoading; const keyInStorageToHoldingsAccsState = ['holdings']; - if (isUserLacksPermToViewSharedInstance) { - return ( - } - /> - ); - } + const getDetails = (data) => { + if (isUserLacksPermToViewSharedInstance) { + return ( + } + /> + ); + } + + if (isInstanceSharing) { + return ( + } + /> + ); + } + + if (isInstanceLoading) { + return ; + } - if (isInstanceSharing) { return ( - } - /> + actionMenu={this.createActionMenuGetter(instance, data)} + instance={instance} + tagsEnabled={tagsEnabled} + ref={this.accordionStatusRef} + userTenantPermissions={this.state.userTenantPermissions} + isShared={isShared} + > + { + (!holdingsrecordid && !itemid) ? + ( + + + + ) + : + null + } + ); - } - - if (isInstanceLoading) { - return ; - } + }; return ( @@ -961,34 +1001,7 @@ class ViewInstance extends React.Component { isWithinScope={checkScope} scope={document.body} > - - { - (!holdingsrecordid && !itemid) ? - ( - - - - ) - : - null - } - - + {getDetails(data)} {this.state.afterCreate && !isEmpty(instance) &&