Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIIN-2647: Share instance when there are no linked MARC Authorities (follow-up) #2337

Merged
merged 14 commits into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/ViewInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -526,12 +526,18 @@ class ViewInstance extends React.Component {
});
}

checkIfHasLinkedAuthorities = (instance = {}) => {
const authorityIds = getLinkedAuthorityIds(instance).join(' or ');
checkIfHasLinkedAuthorities = () => {
const { selectedInstance } = this.props;
const authorityIds = getLinkedAuthorityIds(selectedInstance);

if (isEmpty(authorityIds)) {
this.handleShareLocalInstance(selectedInstance);
return;
}

this.props.mutator.authorities.GET({
params: {
query: `id==(${authorityIds})`,
query: `id==(${authorityIds.join(' or ')})`,
}
}).then(({ authorities }) => {
const localAuthorities = authorities.filter(authority => !authority.source.startsWith(CONSORTIUM_PREFIX));
Expand All @@ -543,7 +549,7 @@ class ViewInstance extends React.Component {
isUnlinkAuthoritiesModalOpen: true,
});
} else {
this.handleShareLocalInstance(instance);
this.handleShareLocalInstance(selectedInstance);
}
});
}
Expand Down Expand Up @@ -1027,7 +1033,7 @@ class ViewInstance extends React.Component {
message={<FormattedMessage id="ui-inventory.shareLocalInstance.modal.message" values={{ instanceTitle: instance?.title }} />}
confirmLabel={<FormattedMessage id="ui-inventory.shareLocalInstance.modal.confirmButton" />}
onCancel={() => this.setState({ isShareLocalInstanceModalOpen: false })}
onConfirm={() => this.checkIfHasLinkedAuthorities(instance)}
onConfirm={this.checkIfHasLinkedAuthorities}
/>

<ConfirmationModal
Expand Down
Loading