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

ENH Confirm user wishes to delete link #188

Merged
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions client/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ if (typeof(ss) === 'undefined' || typeof(ss.i18n) === 'undefined') {
} else {
ss.i18n.addDictionary('en', {
"LinkField.SAVE_SUCCESS": "Saved link",
"LinkField.CONFIRM_ARCHIVE": "Archived link",
"LinkField.CONFIRM_DELETE": "Deleted link",
"LinkField.ARCHIVE_CONFIRM": "Are you sure you want to archive this link?",
"LinkField.DELETE_CONFIRM": "Are you sure you want to delete this link?",
"LinkField.ARCHIVE_SUCCESS": "Archived link",
"LinkField.DELETE_SUCCESS": "Deleted link",
"LinkField.ARCHIVE_ERROR": "Failed to archive link",
"LinkField.DELETE_ERROR": "Failed to delete link",
"LinkField.ADD_LINK": "Add Link",
Expand Down
6 changes: 4 additions & 2 deletions client/lang/src/en.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"LinkField.SAVE_SUCCESS": "Saved link",
"LinkField.CONFIRM_ARCHIVE": "Archived link",
"LinkField.CONFIRM_DELETE": "Deleted link",
"LinkField.ARCHIVE_CONFIRM": "Are you sure you want to archive this link?",
"LinkField.DELETE_CONFIRM": "Are you sure you want to delete this link?",
"LinkField.ARCHIVE_SUCCESS": "Archived link",
"LinkField.DELETE_SUCCESS": "Deleted link",
"LinkField.ARCHIVE_ERROR": "Failed to archive link",
"LinkField.DELETE_ERROR": "Failed to delete link",
"LinkField.ADD_LINK": "Add Link",
Expand Down
12 changes: 9 additions & 3 deletions client/src/components/LinkField/LinkField.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,22 @@ const LinkField = ({
/**
* Update the component when the 'Delete' button in the LinkPicker is clicked
*/
const onDelete = (linkID) => {
const onDelete = (linkID, deleteType) => {
const versionState = data[linkID]?.versionState || '';
const isVersioned = ['draft', 'modified', 'published'].includes(versionState);
const deleteText = isVersioned
? i18n._t('LinkField.ARCHIVE_CONFIRM', 'Are you sure you want to archive this link?')
: i18n._t('LinkField.DELETE_CONFIRM', 'Are you sure you want to delete this link?');
if (!window.confirm(deleteText)) {
return;
}
let endpoint = joinUrlPaths(Config.getSection(section).form.linkForm.deleteUrl, linkID.toString());
const parsedURL = url.parse(endpoint);
const parsedQs = qs.parse(parsedURL.query);
parsedQs.ownerID = ownerID;
parsedQs.ownerClass = ownerClass;
parsedQs.ownerRelation = ownerRelation;
endpoint = url.format({ ...parsedURL, search: qs.stringify(parsedQs)});
const versionState = data[linkID]?.versionState || '';
const isVersioned = ['draft', 'modified', 'published'].includes(versionState);
const successText = isVersioned
? i18n._t('LinkField.ARCHIVE_SUCCESS', 'Archived link')
: i18n._t('LinkField.DELETE_SUCCESS', 'Deleted link');
Expand Down
Loading