FIX: Fix delete button for Tag Groups. (#6965)

FIX: Fix delete button for Tag Groups. (#6965)

diff --git a/app/assets/javascripts/discourse/models/tag-group.js.es6 b/app/assets/javascripts/discourse/models/tag-group.js.es6
index 4d85f65..4c46aa6 100644
--- a/app/assets/javascripts/discourse/models/tag-group.js.es6
+++ b/app/assets/javascripts/discourse/models/tag-group.js.es6
@@ -9,6 +9,11 @@ export default RestModel.extend({
     return saving || Ember.isEmpty(name) || Ember.isEmpty(tagNames);
   },
 
+  @computed("id")
+  disableDelete(id) {
+    return !parseInt(id);
+  },
+
   @computed("permissions")
   permissionName: {
     get(permissions) {
diff --git a/app/assets/javascripts/discourse/templates/tag-groups-show.hbs b/app/assets/javascripts/discourse/templates/tag-groups-show.hbs
index 65e1b8e..6e28918 100644
--- a/app/assets/javascripts/discourse/templates/tag-groups-show.hbs
+++ b/app/assets/javascripts/discourse/templates/tag-groups-show.hbs
@@ -44,6 +44,6 @@
   </section>
 
   <button {{action "save"}} disabled={{model.disableSave}} class='btn btn-default'>{{i18n 'tagging.groups.save'}}</button>
-  <button {{action "destroy"}} disabled={{model.disableSave}} class='btn btn-danger'>{{d-icon "far-trash-alt"}} {{i18n 'tagging.groups.delete'}}</button>
+  <button {{action "destroy"}} disabled={{model.disableDelete}} class='btn btn-danger'>{{d-icon "far-trash-alt"}} {{i18n 'tagging.groups.delete'}}</button>
   <span class="saving {{unless model.savingStatus 'hidden'}}">{{model.savingStatus}}</span>
 </div>
diff --git a/test/javascripts/acceptance/tag-groups-test.js.es6 b/test/javascripts/acceptance/tag-groups-test.js.es6
new file mode 100644
index 0000000..95556f0
--- /dev/null
+++ b/test/javascripts/acceptance/tag-groups-test.js.es6
@@ -0,0 +1,36 @@
+import { acceptance } from "helpers/qunit-helpers";
+
+acceptance("Tag Groups", {
+  loggedIn: true,
+  settings: { tagging_enabled: true },
+  pretend(server, helper) {
+    server.post("/tag_groups", () => {
+      return helper.response({
+        tag_group: {
+          id: 42,
+          name: "test tag group",
+          tag_names: ["monkey"],
+          parent_tag_name: [],
+          one_per_topic: false,
+          permissions: { everyone: 1 }
+        }
+      });
+    });
+  }
+});
+
+QUnit.test("tag groups can be saved and deleted", async assert => {
+  const tags = selectKit(".tag-chooser");
+
+  await visit("/tag_groups");
+  await click(".content-list .btn");
+
+  await fillIn(".tag-group-content h1 input", "test tag group");
+  await tags.expand();
+  await tags.selectRowByValue("monkey");
+
+  await click(".tag-group-content .btn.btn-default");
+
+  await click(".tag-chooser .choice:first");
+  assert.ok(!find(".tag-group-content .btn.btn-danger")[0].disabled);
+});

GitHub sha: e0e91fad