A platform for community discussion. Free, open, simple.
UX: warn about consequences of group deletion (#20030)
Krisdfffb439331b
diff --git a/app/assets/javascripts/discourse/app/components/dialog-messages/group-delete.hbs b/app/assets/javascripts/discourse/app/components/dialog-messages/group-delete.hbsindex 40e56d0fb87..b6d45b96cb0 100644--- a/app/assets/javascripts/discourse/app/components/dialog-messages/group-delete.hbs+++ b/app/assets/javascripts/discourse/app/components/dialog-messages/group-delete.hbs@@ -1 +1,20 @@-{{i18n "admin.groups.delete_with_messages_confirm" [email protected]_count}}\ No newline at end of file+{{#if @model.members.length}}+ <p>+ {{d-icon "users"}}+ {{i18n "admin.groups.delete_details" [email protected]}}+ </p>+{{/if}}+{{#if @model.message_count}}+ <p>+ {{d-icon "envelope"}}+ {{i18n+ "admin.groups.delete_with_messages_confirm"+ [email protected]_count+ }}+ </p>+{{/if}}++<p>+ {{d-icon "exclamation-triangle"}}+ {{i18n "admin.groups.delete_warning"}}+</p>\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/controllers/group.js b/app/assets/javascripts/discourse/app/controllers/group.jsindex f49b1bcb902..589dd13b8dc 100644--- a/app/assets/javascripts/discourse/app/controllers/group.js+++ b/app/assets/javascripts/discourse/app/controllers/group.js@@ -138,16 +138,10 @@ export default Controller.extend({this.set("destroying", true);const model = this.model;- const title = I18n.t("admin.groups.delete_confirm");- let bodyComponent = null;-- if (model.has_messages && model.message_count > 0) {- bodyComponent = GroupDeleteDialog;- }this.dialog.deleteConfirm({- title,- bodyComponent,+ title: I18n.t("admin.groups.delete_confirm", { group: model.name }),+ bodyComponent: GroupDeleteDialog,bodyComponentModel: model,didConfirm: () => {modeldiff --git a/app/assets/javascripts/discourse/tests/acceptance/group-test.js b/app/assets/javascripts/discourse/tests/acceptance/group-test.jsindex 445e4033503..7ed19df395a 100644--- a/app/assets/javascripts/discourse/tests/acceptance/group-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/group-test.js@@ -275,7 +275,7 @@ acceptance("Group - Authenticated", function (needs) {await click(".group-details-button button.btn-danger");assert.strictEqual(- query(".dialog-body").textContent.trim(),+ query(".dialog-body p:nth-of-type(2)").textContent.trim(),I18n.t("admin.groups.delete_with_messages_confirm", {count: 2,}),diff --git a/app/assets/javascripts/discourse/tests/integration/components/dialog-holder-test.js b/app/assets/javascripts/discourse/tests/integration/components/dialog-holder-test.jsindex ba63247dcee..8ce7b0a997a 100644--- a/app/assets/javascripts/discourse/tests/integration/components/dialog-holder-test.js+++ b/app/assets/javascripts/discourse/tests/integration/components/dialog-holder-test.js@@ -426,7 +426,7 @@ module("Integration | Component | dialog-holder", function (hooks) {await settled();assert.strictEqual(- query(".dialog-body").innerText.trim(),+ query(".dialog-body p:first-child").innerText.trim(),I18n.t("admin.groups.delete_with_messages_confirm", {count: message_count,}),diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 2ca32248732..d2994b371f1 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -4616,10 +4616,14 @@ en:about: "Edit your group membership and names here"group_members: "Group members"delete: "Delete"- delete_confirm: "Are you sure you want to delete this group?"+ delete_confirm: "Are you sure you want to delete %{group}?"+ delete_details:+ one: "%{count} person will lose access to this group"+ other: "%{count} people will lose access to this group"delete_with_messages_confirm:- one: "Deleting this group will cause %{count} message to be orphaned, group members will no longer have access to it."- other: "Deleting this group will cause %{count} messages to be orphaned, group members will no longer have access to them."+ one: "%{count} message will become inaccessible to group members"+ other: "%{count} messages will become inaccessible to group members"+ delete_warning: "Deleted groups can not be recovered"delete_failed: "Unable to delete group. If this is an automatic group, it cannot be destroyed."delete_automatic_group: This is an automatic group and cannot be deleted.delete_owner_confirm: "Remove owner privilege for '%{username}'?"