Skip to content

Commit

Permalink
UIIN-2647: Reduce the depth
Browse files Browse the repository at this point in the history
  • Loading branch information
OleksandrHladchenko1 committed Nov 7, 2023
1 parent e1409d1 commit 783ae49
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/ViewInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,27 +531,28 @@ class ViewInstance extends React.Component {
const { selectedInstance } = this.props;
const authorityIds = getLinkedAuthorityIds(selectedInstance);

if (!isEmpty(authorityIds)) {
this.props.mutator.authorities.GET({
params: {
query: `id==(${authorityIds.join(' or ')})`,
}
}).then(({ authorities }) => {
const localAuthorities = authorities.filter(authority => !authority.source.startsWith(CONSORTIUM_PREFIX));

if (localAuthorities.length) {
this.setState({
linkedAuthoritiesLength: localAuthorities.length,
isShareLocalInstanceModalOpen: false,
isUnlinkAuthoritiesModalOpen: true,
});
} else {
this.handleShareLocalInstance(selectedInstance);
}
});
} else {
if (isEmpty(authorityIds)) {
this.handleShareLocalInstance(selectedInstance);
return;
}

this.props.mutator.authorities.GET({
params: {
query: `id==(${authorityIds.join(' or ')})`,
}
}).then(({ authorities }) => {
const localAuthorities = authorities.filter(authority => !authority.source.startsWith(CONSORTIUM_PREFIX));

if (localAuthorities.length) {
this.setState({
linkedAuthoritiesLength: localAuthorities.length,
isShareLocalInstanceModalOpen: false,
isUnlinkAuthoritiesModalOpen: true,
});
} else {
this.handleShareLocalInstance(selectedInstance);
}
});
}

toggleCopyrightModal = () => {
Expand Down

0 comments on commit 783ae49

Please sign in to comment.