Skip to content

Commit

Permalink
Include details in confirmation message that dataset will no longer b…
Browse files Browse the repository at this point in the history
…e visible to the community (#1152)
  • Loading branch information
dmfalke committed Jul 26, 2024
1 parent 335db83 commit 4e6aa96
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,28 @@ class UserDatasetDetail extends React.Component {
this.props;
const { sharedWith } = userDataset;
const shareCount = !Array.isArray(sharedWith) ? null : sharedWith.length;
const message =
`Are you sure you want to ${
isOwner ? 'delete' : 'remove'
} this ${dataNoun.singular.toLowerCase()}? ` +
(!isOwner || !shareCount

const question = `Are you sure you want to ${
isOwner ? 'delete' : 'remove'
} this ${dataNoun.singular.toLowerCase()}? `;

const visibilityMessage =
userDataset.meta.visibility === 'public'
? 'It will no longer be visible to the community'
: null;

const shareMessage =
!isOwner || !shareCount
? ''
: `${shareCount} collaborator${
shareCount === 1 ? '' : 's'
} you've shared with will lose access.`);
} you've shared with will lose access.`;

const message =
question +
(visibilityMessage && shareMessage
? `${visibilityMessage}, and ${shareMessage}`
: visibilityMessage || shareMessage);

if (window.confirm(message)) {
removeUserDataset(userDataset, baseUrl);
Expand Down

0 comments on commit 4e6aa96

Please sign in to comment.