A platform for community discussion. Free, open, simple.
DEV: Restore tag-info model for frontend (#39101)
Natalie Tay860a7acea3df
diff --git a/frontend/discourse/app/adapters/tag-info.js b/frontend/discourse/app/adapters/tag-info.jsnew file mode 100644index 00000000000..0e8659342dd--- /dev/null+++ b/frontend/discourse/app/adapters/tag-info.js@@ -0,0 +1,7 @@+import RESTAdapter from "discourse/adapters/rest";++export default class TagInfoAdapter extends RESTAdapter {+ pathFor(store, type, id) {+ return `/tag/${id}/info.json`;+ }+}diff --git a/frontend/discourse/app/models/tag-info.js b/frontend/discourse/app/models/tag-info.jsnew file mode 100644index 00000000000..fdb09390af9--- /dev/null+++ b/frontend/discourse/app/models/tag-info.js@@ -0,0 +1,18 @@+import { tracked } from "@glimmer/tracking";+import { autoTrackedArray } from "discourse/lib/tracked-tools";+import RestModel from "discourse/models/rest";++export default class TagInfo extends RestModel {+ @tracked category_restricted;+ @tracked description;+ @tracked id;+ @tracked name;+ @tracked slug;+ @tracked staff;+ @tracked topic_count;++ @autoTrackedArray categories;+ @autoTrackedArray localizations;+ @autoTrackedArray synonyms;+ @autoTrackedArray tag_group_names;+}diff --git a/frontend/discourse/tests/unit/models/tag-info-test.js b/frontend/discourse/tests/unit/models/tag-info-test.jsnew file mode 100644index 00000000000..c7d4d7cad50--- /dev/null+++ b/frontend/discourse/tests/unit/models/tag-info-test.js@@ -0,0 +1,18 @@+import { getOwner } from "@ember/owner";+import { setupTest } from "ember-qunit";+import { module, test } from "qunit";++module("Unit | Model | tag-info", function (hooks) {+ setupTest(hooks);++ hooks.beforeEach(function () {+ this.store = getOwner(this).lookup("service:store");+ });++ test("store.find fetches tag info via /tag/:id/info.json", async function (assert) {+ const result = await this.store.find("tag-info", 123);++ assert.strictEqual(result.id, 123);+ assert.strictEqual(result.name, "123");+ });+});