From e25b55c26599e3217b6221eaf48a85cac7e343eb Mon Sep 17 00:00:00 2001
From: Oleksandr Hladchenko
<85172747+oleksandrhladchenko1@users.noreply.github.com>
Date: Tue, 5 Dec 2023 15:13:05 +0200
Subject: [PATCH] UIIN-2704: Disable the Share button after clicking on it once
(#2364)
(cherry picked from commit 6854a2303f8a612b66bd2126f006d0f3c88947a1)
---
src/ViewInstance.js | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/src/ViewInstance.js b/src/ViewInstance.js
index 6bfe5e8bc..cbc7bae12 100644
--- a/src/ViewInstance.js
+++ b/src/ViewInstance.js
@@ -190,6 +190,7 @@ class ViewInstance extends React.Component {
isImportRecordModalOpened: false,
isCopyrightModalOpened: false,
isShareLocalInstanceModalOpen: false,
+ isShareButtonDisabled: false,
isUnlinkAuthoritiesModalOpen: false,
linkedAuthoritiesLength: 0,
isNewOrderModalOpen: false,
@@ -499,6 +500,7 @@ class ViewInstance extends React.Component {
isUnlinkAuthoritiesModalOpen: false,
isShareLocalInstanceModalOpen: false,
isInstanceSharing: true,
+ isShareButtonDisabled: false,
});
await this.waitForInstanceSharingComplete({ sourceTenantId, instanceIdentifier });
@@ -516,12 +518,15 @@ class ViewInstance extends React.Component {
isUnlinkAuthoritiesModalOpen: false,
isShareLocalInstanceModalOpen: false,
isInstanceSharing: false,
+ isShareButtonDisabled: false,
});
this.showUnsuccessfulShareInstanceCallout(instanceTitle);
});
}
checkIfHasLinkedAuthorities = () => {
+ this.setState({ isShareButtonDisabled: true });
+
const { selectedInstance } = this.props;
const authorityIds = getLinkedAuthorityIds(selectedInstance);
@@ -547,7 +552,10 @@ class ViewInstance extends React.Component {
this.handleShareLocalInstance(selectedInstance);
}
}).catch(() => {
- this.setState({ isShareLocalInstanceModalOpen: false });
+ this.setState({
+ isShareLocalInstanceModalOpen: false,
+ isShareButtonDisabled: false,
+ });
this.calloutRef.current.sendCallout({
type: 'error',
@@ -556,6 +564,13 @@ class ViewInstance extends React.Component {
});
}
+ handleCloseUnlinkModal = () => {
+ this.setState({
+ isUnlinkAuthoritiesModalOpen: false,
+ isShareButtonDisabled: false,
+ });
+ }
+
toggleCopyrightModal = () => {
this.setState(prevState => ({ isCopyrightModalOpened: !prevState.isCopyrightModalOpened }));
};
@@ -960,7 +975,10 @@ class ViewInstance extends React.Component {
updateLocation,
canUseSingleRecordImport,
} = this.props;
- const { linkedAuthoritiesLength } = this.state;
+ const {
+ linkedAuthoritiesLength,
+ isShareButtonDisabled,
+ } = this.state;
const ci = makeConnectedInstance(this.props, stripes.logger);
const instance = ci.instance();
@@ -1044,6 +1062,7 @@ class ViewInstance extends React.Component {
confirmLabel={}
onCancel={() => this.setState({ isShareLocalInstanceModalOpen: false })}
onConfirm={this.checkIfHasLinkedAuthorities}
+ isConfirmButtonDisabled={isShareButtonDisabled}
/>
}
message={}
confirmLabel={}
- onCancel={() => this.setState({ isUnlinkAuthoritiesModalOpen: false })}
+ onCancel={this.handleCloseUnlinkModal}
onConfirm={() => this.handleShareLocalInstance(instance)}
/>