UX: add confirmation when adding tag synonyms

The new confirmation modal explains that adding a tag as a synonym to
another tag will change all topics to replace the synonyms with the
base tag.
This commit is contained in:
Neil Lalonde 2020-01-22 12:35:03 -05:00
parent 9e8ee90774
commit b63d146128
2 changed files with 33 additions and 20 deletions
app/assets/javascripts/discourse/components
config/locales

@ -98,20 +98,28 @@ export default Component.extend({
}, },
addSynonyms() { addSynonyms() {
bootbox.confirm(
I18n.t("tagging.add_synonyms_explanation", {
count: this.newSynonyms.length,
tag_name: this.tagInfo.name
}),
result => {
if (!result) return;
ajax(`/tag/${this.tagInfo.name}/synonyms`, { ajax(`/tag/${this.tagInfo.name}/synonyms`, {
type: "POST", type: "POST",
data: { data: {
synonyms: this.newSynonyms synonyms: this.newSynonyms
} }
}) })
.then(result => { .then(response => {
if (result.success) { if (response.success) {
this.set("newSynonyms", null); this.set("newSynonyms", null);
this.loadTagInfo(); this.loadTagInfo();
} else if (result.failed_tags) { } else if (response.failed_tags) {
bootbox.alert( bootbox.alert(
I18n.t("tagging.add_synonyms_failed", { I18n.t("tagging.add_synonyms_failed", {
tag_names: Object.keys(result.failed_tags).join(", ") tag_names: Object.keys(response.failed_tags).join(", ")
}) })
); );
} else { } else {
@ -120,5 +128,7 @@ export default Component.extend({
}) })
.catch(popupAjaxError); .catch(popupAjaxError);
} }
);
}
} }
}); });

@ -3107,6 +3107,9 @@ en:
edit_synonyms: "Manage Synonyms" edit_synonyms: "Manage Synonyms"
add_synonyms_label: "Add synonyms:" add_synonyms_label: "Add synonyms:"
add_synonyms: "Add" add_synonyms: "Add"
add_synonyms_explanation:
one: "Any place that currently uses this tag will be changed to use <b>%{tag_name}</b> instead. Are you sure you want to make this change?"
other: "Any place that currently uses these tags will be changed to use <b>%{tag_name}</b> instead. Are you sure you want to make this change?"
add_synonyms_failed: "The following tags couldn't be added as synonyms: <b>%{tag_names}</b>. Ensure they don't have synonyms and aren't synonyms of another tag." add_synonyms_failed: "The following tags couldn't be added as synonyms: <b>%{tag_names}</b>. Ensure they don't have synonyms and aren't synonyms of another tag."
remove_synonym: "Remove Synonym" remove_synonym: "Remove Synonym"
delete_synonym_confirm: 'Are you sure you want to delete the synonym "%{tag_name}"?' delete_synonym_confirm: 'Are you sure you want to delete the synonym "%{tag_name}"?'