A platform for community discussion. Free, open, simple.
FEATURE: Tags get a dedicated settings page (#39057)
Natalie Tay5f0d95e1f11a
diff --git a/app/assets/stylesheets/common/base/tagging.scss b/app/assets/stylesheets/common/base/tagging.scssindex bfc936fe881..672a9ff0b10 100644--- a/app/assets/stylesheets/common/base/tagging.scss+++ b/app/assets/stylesheets/common/base/tagging.scss@@ -354,103 +354,6 @@}}-section.tag-info {- display: flex;- flex-direction: column;- gap: 1em;- margin: 1em 0;- padding: 2em;- border: 1px solid var(--content-border-color);-- .edit-tag-wrapper {- display: flex;- flex-direction: column;-- #edit-name,- #edit-description {- width: 100%;- margin-bottom: 0.5em;- }-- #edit-description {- height: 120px;- }-- .edit-controls {- display: flex;- gap: 0.5em;- }- }-- .tag-name-wrapper {- display: flex;- font-size: var(--font-up-4);- align-items: baseline;-- button {- font-size: var(--font-down-1);-- .d-icon {- color: var(--primary-high);- }-- .discourse-no-touch & {- &:hover {- background: transparent;- }- }- }-- .edit-tag {- color: var(--primary-high);- font-size: var(--font-down-2);- margin-left: 0.5em;- }- }-- .tag-description-wrapper {- display: flex;- font-size: var(--font-up-1);- }-- .tag-box {- display: flex;- align-items: center;- margin-bottom: 0.25em;-- a {- margin-left: 0.5em;- }- }-- .tag-actions {- display: flex;- flex-wrap: wrap;- gap: 0.5em;- }-- .tag-associations:empty {- display: none;- }-- .add-synonyms {- &__controls {- display: flex;- gap: 0.5em;- }- }-- .tag-list {- margin: 0.5em 0 0;- padding: 0;- border: none;-- a {- color: var(--primary-medium);- }- }-}-.tag-navigation {.mini-tag-chooser.tags-intersection-chooser {margin: 0 0.5em 0 0;diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex 06505f80451..a4c2a99fc23 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2778,7 +2778,6 @@ en:fake_upcoming_change: "This is a fake upcoming change for testing purposes. No need to translate this string."floating_dismiss_topics_on_mobile: "Shows a floating 'Dismiss...' button on mobile for the topic list for easier access and to free up space in the top of the topic list"rename_faq_to_guidelines: "This change renames the FAQ page to Guidelines. The FAQ page will still be available at /faq. The 'faq url' setting works as before."- experimental_tag_settings_page: "Enable a dedicated settings page for tags at /tag/:slug/:id/edit."enable_simplified_category_creation: "Enables a simplified category creation flow with fewer options and a cleaner interface."enable_custom_splash_screen: "Allows customizing the loading splash screen with your own SVG image. Upload an image via the 'splash screen image' setting. Warning: This may negatively impact LCP scores and Google indexing."modernize_foundation_theme: "This change introduces design modifcations to the Foundation theme in Discourse."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex 5068341c962..56a4d8260cd 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -4261,10 +4261,6 @@ experimental:impact: "feature,all_members"status: "beta"learn_more_url: "https://meta.discourse.org/t/-/395099"- experimental_tag_settings_page:- default: false- client: true- area: "experimental"enable_form_templates:client: truedefault: falsediff --git a/frontend/discourse/app/adapters/tag-info.js b/frontend/discourse/app/adapters/tag-info.jsdeleted file mode 100644index 0e8659342dd..00000000000--- a/frontend/discourse/app/adapters/tag-info.js+++ /dev/null@@ -1,7 +0,0 @@-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/components/d-navigation.gjs b/frontend/discourse/app/components/d-navigation.gjsindex 682b47234b4..723cb9fb336 100644--- a/frontend/discourse/app/components/d-navigation.gjs+++ b/frontend/discourse/app/components/d-navigation.gjs@@ -33,10 +33,6 @@ export default class DNavigation extends Component {@setting("fixed_category_positions") fixedCategoryPositions;- get canEditTags() {- return this.currentUser?.canEditTags;- }-get createTopicLabel() {const defaultKey = "topic.create";@@ -124,14 +120,6 @@ export default class DNavigation extends Component {return this.category?.can_edit;}- @computed("additionalTags", "category", "tag.name")- get showToggleInfo() {- if (this.siteSettings.experimental_tag_settings_page) {- return this.currentUser;- }- return !this.additionalTags && !this.category && this.tag?.name !== "none";- }-@computed("filterType","category",@@ -197,11 +185,6 @@ export default class DNavigation extends Component {this.createTopic();}- @action- clickTagInfo() {- this.toggleInfo();- }-<template><BreadCrumbs@categories={{this.categories}}@@ -277,23 +260,9 @@ export default class DNavigation extends Component {{{/if}}{{#if this.tag}}- {{#if this.showToggleInfo}}- {{#if this.siteSettings.experimental_tag_settings_page}}- <TagInfoButton- @tag={{this.tag}}- @currentUser={{this.currentUser}}- />- {{else}}- <DButton- @icon={{if this.canEditTags "wrench" "circle-info"}}- @ariaLabel={{if this.canEditTags "tagging.edit" "tagging.info"}}- @title={{if this.canEditTags "tagging.edit" "tagging.info"}}- @action={{this.clickTagInfo}}- id="show-tag-info"- class="btn-default"- />- {{/if}}- {{/if}}+ {{#unless this.additionalTags}}+ <TagInfoButton @tag={{this.tag}} @currentUser={{this.currentUser}} />+ {{/unless}}{{/if}}<PluginOutletdiff --git a/frontend/discourse/app/components/discovery/layout.gjs b/frontend/discourse/app/components/discovery/layout.gjsindex f9200f868eb..b170a0b7435 100644--- a/frontend/discourse/app/components/discovery/layout.gjs+++ b/frontend/discourse/app/components/discovery/layout.gjs@@ -47,11 +47,7 @@ export default class Layout extends Component {<PluginOutlet@name="discovery-list-controls-above"@connectorTagName="div"- @outletArgs={{lazyHash- toggleTagInfo=@toggleTagInfo- }}+ @outletArgs={{lazyHash [email protected] [email protected]}}/><div class="list-controls"><PluginOutletdiff --git a/frontend/discourse/app/components/discovery/navigation.gjs b/frontend/discourse/app/components/discovery/navigation.gjsindex 74143bd53e4..863e2c2a065 100644--- a/frontend/discourse/app/components/discovery/navigation.gjs+++ b/frontend/discourse/app/components/discovery/navigation.gjs@@ -149,7 +149,6 @@ export default class DiscoveryNavigation extends Component {@canBulkSelect={{@canBulkSelect}}@bulkSelectHelper={{@bulkSelectHelper}}@skipCategoriesNavItem={{this.skipCategoriesNavItem}}- @toggleInfo={{@toggleTagInfo}}@tagNotification={{@tagNotification}}@model={{@model}}@showDismissRead={{@showDismissRead}}diff --git a/frontend/discourse/app/components/tag-info-button.gjs b/frontend/discourse/app/components/tag-info-button.gjsindex 761ebac2fc9..dc64c3de569 100644--- a/frontend/discourse/app/components/tag-info-button.gjs+++ b/frontend/discourse/app/components/tag-info-button.gjs@@ -1,114 +1,35 @@import Component from "@glimmer/component";-import { tracked } from "@glimmer/tracking";import { action } from "@ember/object";-import didInsert from "@ember/render-modifiers/modifiers/did-insert";-import didUpdate from "@ember/render-modifiers/modifiers/did-update";import { service } from "@ember/service";import DButton from "discourse/components/d-button";-import DTooltip from "discourse/float-kit/components/d-tooltip";-import discourseTags from "discourse/helpers/discourse-tags";-import { popupAjaxError } from "discourse/lib/ajax-error";-import { i18n } from "discourse-i18n";export default class TagInfoButton extends Component {- @service store;@service router;- @tracked tagInfo = null;- @tracked loading = false;-get canEditTags() {return this.args.currentUser?.canEditTags;}- get hasSynonyms() {- return this.tagInfo?.synonyms?.length > 0;- }-- get showButton() {- if (this.canEditTags) {- return true;- }- return this.hasSynonyms;- }-- @action- async loadTagInfo() {- if (this.canEditTags) {- return;- }-- const tag = this.args.tag;- if (!tag) {- return;- }-- const tagId = String(tag.id || tag.name);-- if (this._lastTagId !== tagId) {- this.tagInfo = null;- this._lastTagId = tagId;- }-- if (this.loading || this.tagInfo) {- return;- }-- this.loading = true;-- const findArgs = tag.id || tag.name;-- try {- this.tagInfo = await this.store.find("tag-info", findArgs);- } catch (error) {- popupAjaxError(error);- } finally {- this.loading = false;- }- }-@actionhandleClick() {- if (this.canEditTags) {- this.router.transitionTo(- "tag.edit.tab",- this.args.tag.slug,- this.args.tag.id,- "general"- );- }+ this.router.transitionTo(+ "tag.edit.tab",+ this.args.tag.slug,+ this.args.tag.id,+ "general"+ );}<template>- <div {{didInsert this.loadTagInfo}} {{didUpdate this.loadTagInfo @tag}}>- {{#if this.canEditTags}}- <DButton- @icon="wrench"- @ariaLabel="tagging.edit"- @title="tagging.edit"- @action={{this.handleClick}}- id="show-tag-info"- class="btn-default"- />- {{else if this.hasSynonyms}}- <DTooltip @identifier="tag-synonyms-tooltip">- <:trigger>- <DButton- @icon="circle-info"- @ariaLabel="tagging.info"- @title="tagging.info"- id="show-tag-info"- class="btn-default"- />- </:trigger>- <:content>- <div class="tag-synonyms-tooltip">- {{i18n "tagging.synonyms_inline" base_tag_name=this.tagInfo.name}}- {{discourseTags null tags=this.tagInfo.synonyms}}- </div>- </:content>- </DTooltip>- {{/if}}- </div>+ {{#if this.canEditTags}}+ <DButton+ @icon="wrench"+ @ariaLabel="tagging.edit"+ @title="tagging.edit"+ @action={{this.handleClick}}+ id="show-tag-info"+ class="btn-default"+ />+ {{/if}}</template>}diff --git a/frontend/discourse/app/components/tag-info.gjs b/frontend/discourse/app/components/tag-info.gjsdeleted file mode 100644index e14da42d504..00000000000--- a/frontend/discourse/app/components/tag-info.gjs+++ /dev/null@@ -1,483 +0,0 @@-import Component from "@glimmer/component";-import { tracked } from "@glimmer/tracking";-import { Textarea } from "@ember/component";-import { array, fn } from "@ember/helper";-import { on } from "@ember/modifier";-import { action } from "@ember/object";-import { LinkTo } from "@ember/routing";-import { service } from "@ember/service";-import { trustHTML } from "@ember/template";-import { isEmpty } from "@ember/utils";-import DButton from "discourse/components/d-button";-import PluginOutlet from "discourse/components/plugin-outlet";-import TextField from "discourse/components/text-field";-import basePath from "discourse/helpers/base-path";-import categoryLink from "discourse/helpers/category-link";-import icon from "discourse/helpers/d-icon";-import discourseTag from "discourse/helpers/discourse-tag";-import helperFn from "discourse/helpers/helper-fn";-import lazyHash from "discourse/helpers/lazy-hash";-import withEventValue from "discourse/helpers/with-event-value";-import { ajax } from "discourse/lib/ajax";-import { popupAjaxError } from "discourse/lib/ajax-error";-import { removeValueFromArray } from "discourse/lib/array-tools";-import TagChooser from "discourse/select-kit/components/tag-chooser";-import { i18n } from "discourse-i18n";--export default class TagInfo extends Component {- @service currentUser;- @service dialog;- @service router;- @service site;- @service siteSettings;- @service store;-- @tracked tagInfo;- @tracked newSynonyms;- @tracked newTagName;- @tracked descriptionWithNewLines;- @tracked loading = false;- @tracked showEditControls = false;- @tracked editing = false;- newTagDescription;-- updateTagInfo = helperFn(() => {- this.loadTagInfo();- });-- get canAdminTag() {- return this.currentUser.staff;- }-- get canEditTags() {- return this.currentUser.canEditTags;- }-- get editSynonymsMode() {- return this.canEditTags && this.showEditControls;- }-- get useSettingsPage() {- return this.siteSettings.experimental_tag_settings_page;- }-- get tagGroupsInfo() {- return i18n("tagging.tag_groups_info", {- count: this.tagInfo?.tag_group_names?.length,- tag_groups: this.tagInfo?.tag_group_names?.join(", "),- });- }-- get categoriesInfo() {- return i18n("tagging.category_restrictions", {- count: this.tagInfo?.categories?.length,- });- }-- get synonyms() {- return this.tagInfo?.synonyms;- }-- get nothingToShow() {- return (- isEmpty(this.tagInfo?.tag_group_names) &&- isEmpty(this.tagInfo?.categories) &&- isEmpty(this.synonyms)- );- }-- get showSave() {- const filterRegexp = new RegExp(this.site.tags_filter_regexp, "g");- return this.newTagName?.replace(filterRegexp, "").trim()?.length > 0;- }-- @action- async loadTagInfo() {- this.loading = true;-- try {- const result = await this.store.find(- "tag-info",- this.args.tag.id || this.args.tag.name- );-- this.tagInfo = result;- this.tagInfo.synonyms = result.synonyms.map((s) =>- this.store.createRecord("tag", s)- );- } catch (e) {- this.tagInfo = null;- popupAjaxError(e);- } finally {- this.loading = false;- }- }-- @action- edit(event) {- event?.preventDefault();-- this.descriptionWithNewLines = this.tagInfo.description?.replaceAll(- "<br>",- "\n"- );- this.editing = true;- this.newTagName = this.args.tag.name;- this.newTagDescription = this.tagInfo.description;- }-- @action- async unlinkSynonym(synonym, event) {- event?.preventDefault();-- try {- await ajax(`/tag/${this.tagInfo.id}/synonyms/${synonym.id}.json`, {- type: "DELETE",- });- removeValueFromArray(this.synonyms, synonym);- } catch (e) {- popupAjaxError(e);- }- }-- @action- deleteSynonym(tag, event) {- event?.preventDefault();-- this.dialog.yesNoConfirm({- message: i18n("tagging.delete_synonym_confirm", {- tag_name: tag.text,- }),- didConfirm: () => {- return tag- .destroyRecord()- .then(() => removeValueFromArray(this.synonyms, tag))- .catch(popupAjaxError);- },- });- }-- @action- toggleEditControls() {- this.showEditControls = !this.showEditControls;- }-- @action- cancelEditing() {- this.editing = false;- }-- @action- async finishedEditing() {- const oldTagName = this.args.tag.name;- this.newTagDescription = this.newTagDescription?.replaceAll("\n", "<br>");-- try {- const result = await this.args.tag.update({- slug: this.args.tag.slug,- name: this.newTagName,- description: this.newTagDescription,- });-- this.editing = false;-- if (result.responseJson.tag) {- const updatedTag = result.responseJson.tag;-- this.tagInfo.name = updatedTag.name;- this.tagInfo.slug = updatedTag.slug;- this.tagInfo.description = this.newTagDescription;-- if (oldTagName !== updatedTag.name) {- const slugForUrl = updatedTag.slug || `${updatedTag.id}-tag`;- this.router.transitionTo("tag.show", slugForUrl, updatedTag.id);- }- }- } catch (e) {- popupAjaxError(e);- }- }-- @action- deleteTag() {- const numTopics = this.args.list?.topic_list?.tags?.[0]?.topic_count || 0;-- let confirmText =- numTopics === 0- ? i18n("tagging.delete_confirm_no_topics")- : i18n("tagging.delete_confirm", { count: numTopics });-- if (this.synonyms?.length > 0) {- confirmText +=- " " +- i18n("tagging.delete_confirm_synonyms", {- count: this.synonyms.length,- });- }-- this.dialog.deleteConfirm({- message: confirmText,- didConfirm: async () => {- try {- await this.args.tag.destroyRecord();- this.router.transitionTo("tags.index");- } catch {- this.dialog.alert(i18n("generic_error"));- }- },- });- }-- @action- addSynonyms() {- this.dialog.confirm({- message: i18n("tagging.add_synonyms_explanation", {- count: this.newSynonyms.length,- tag_name: this.tagInfo.name,- }),- didConfirm: async () => {- const id = this.tagInfo.id;- try {- const response = await ajax(`/tag/${id}/synonyms.json`, {- type: "POST",- data: {- tags: this.newSynonyms.map((t) =>- typeof t.id === "number"- ? { id: t.id, name: t.name }- : { name: t.name }- ),- },- });-- if (response.success) {- this.newSynonyms = null;- this.loadTagInfo();- } else if (response.failed_tags) {- this.dialog.alert(- i18n("tagging.add_synonyms_failed", {- tag_names: Object.keys(response.failed_tags).join(", "),- })- );- } else {- this.dialog.alert(i18n("generic_error"));- }- } catch (e) {- popupAjaxError(e);- }- },- });- }-- <template>- {{this.updateTagInfo}}-- <section class="tag-info">- {{#if this.loading}}- <div>{{i18n "loading"}}</div>- {{else if this.tagInfo}}- <div class="tag-name">- {{#if this.editing}}- <div class="edit-tag-wrapper">- <TextField- @id="edit-name"- @value={{readonly this.tagInfo.name}}- @maxlength={{this.siteSettings.max_tag_length}}- @input={{withEventValue (fn (mut this.newTagName))}}- @autofocus="true"- />-- <Textarea- {{on- "input"- (withEventValue (fn (mut this.newTagDescription)))- }}- @value={{this.descriptionWithNewLines}}- placeholder={{i18n "tagging.description"}}- maxlength={{1000}}- autofocus="true"- id="edit-description"- />-- <div class="edit-controls">- {{#if this.showSave}}- <DButton- @action={{this.finishedEditing}}- @icon="check"- @ariaLabel="tagging.save"- class="btn-primary submit-edit"- />- {{/if}}- <DButton- @action={{this.cancelEditing}}- @icon="xmark"- @ariaLabel="cancel"- class="btn-default cancel-edit"- />- </div>- </div>- {{else}}- <div class="tag-name-wrapper">- {{discourseTag this.tagInfo.name tagName="div"}}- {{#if this.canEditTags}}- {{#if this.useSettingsPage}}- <LinkTo- @route="tag.edit.tab"- @models={{array- this.tagInfo.slug- this.tagInfo.id- "general"- }}- title={{i18n "tagging.edit_tag"}}- class="edit-tag"- >{{icon "gear"}}</LinkTo>- {{else}}- <a- {{on "click" this.edit}}- href- title={{i18n "tagging.edit_tag"}}- class="edit-tag"- >{{icon "pencil"}}</a>- {{/if}}- {{/if}}- </div>- {{#if this.tagInfo.description}}- <div class="tag-description-wrapper">- <span>{{trustHTML this.tagInfo.description}}</span>- </div>- {{/if}}- {{/if}}- </div>-- <div class="tag-associations">- {{#if this.tagInfo.tag_group_names}}- {{this.tagGroupsInfo}}- {{/if}}-- {{#if this.tagInfo.categories}}- {{this.categoriesInfo}}- <br />- {{#each this.tagInfo.categories as |category|}}- {{categoryLink category}}- {{/each}}- {{/if}}-- {{#if this.nothingToShow}}- {{#if this.tagInfo.category_restricted}}- {{i18n "tagging.category_restricted"}}- {{else}}- {{trustHTML (i18n "tagging.default_info")}}- {{#if this.canAdminTag}}- {{trustHTML (i18n "tagging.staff_info" basePath=(basePath))}}- {{/if}}- {{/if}}- {{/if}}- </div>-- {{#if this.synonyms}}- <div class="synonyms-list">- <h3>{{i18n "tagging.synonyms"}}</h3>-- <div>{{trustHTML- (i18n- "tagging.synonyms_description" base_tag_name=this.tagInfo.name- )- }}</div>-- <div class="tag-list">- {{#each this.synonyms as |tag|}}- <div class="tag-box">- {{discourseTag tag.name pmOnly=tag.pmOnly tagName="div"}}- {{#if this.editSynonymsMode}}- <a- {{on "click" (fn this.unlinkSynonym tag)}}- href- class="unlink-synonym"- >- {{icon "link-slash" title="tagging.remove_synonym"}}- </a>- {{#if this.canAdminTag}}- <a- {{on "click" (fn this.deleteSynonym tag)}}- href- class="delete-synonym"- >- {{icon "trash-can" title="tagging.delete_tag"}}- </a>- {{/if}}- {{/if}}- </div>- {{/each}}- </div>- </div>- {{/if}}-- {{#if this.editSynonymsMode}}- <section class="add-synonyms field">- <label for="add-synonyms">- {{i18n "tagging.add_synonyms_label"}}- </label>- <div class="add-synonyms__controls">- <TagChooser- @id="add-synonyms"- @tags={{this.newSynonyms}}- @blockedTags={{array this.tagInfo.name}}- @everyTag={{true}}- @excludeSynonyms={{true}}- @excludeHasSynonyms={{true}}- @unlimitedTagCount={{true}}- @allowCreate={{true}}- />- {{#if this.newSynonyms}}- <DButton- @action={{this.addSynonyms}}- @disabled={{this.addSynonymsDisabled}}- @icon="check"- class="ok"- />- {{/if}}- </div>- </section>- {{/if}}-- {{#if this.canEditTags}}- <PluginOutlet- @name="tag-custom-settings"- @outletArgs={{lazyHash tag=this.tagInfo}}- @connectorTagName="section"- />-- <div class="tag-actions">- {{#if this.useSettingsPage}}- <LinkTo- @route="tag.edit.tab"- @models={{array this.tagInfo.slug this.tagInfo.id "general"}}- class="btn btn-default"- >- {{icon "gear"}}- {{i18n "tagging.settings"}}- </LinkTo>- {{else}}- <DButton- @action={{this.toggleEditControls}}- @icon="gear"- @label="tagging.edit_synonyms"- id="edit-synonyms"- class="btn-default"- />- {{/if}}- {{#if this.canAdminTag}}- <DButton- @action={{this.deleteTag}}- @icon="trash-can"- @label="tagging.delete_tag"- id="delete-tag"- class="btn-danger delete-tag"- />- {{/if}}- </div>- {{/if}}- {{/if}}-- </section>- </template>-}diff --git a/frontend/discourse/app/controllers/discovery/list.js b/frontend/discourse/app/controllers/discovery/list.jsindex 7e611c1eeff..f759a6f615a 100644--- a/frontend/discourse/app/controllers/discovery/list.js+++ b/frontend/discourse/app/controllers/discovery/list.js@@ -212,11 +212,6 @@ export default class DiscoveryListController extends Controller {this.model.list.updateNewListSubsetParam(subset);}- @action- toggleTagInfo() {- this.toggleProperty("showTagInfo");- }-@actiondismissRead(dismissTopics) {const operationType = dismissTopics ? "topics" : "posts";diff --git a/frontend/discourse/app/models/tag-info.js b/frontend/discourse/app/models/tag-info.jsdeleted file mode 100644index fdb09390af9..00000000000--- a/frontend/discourse/app/models/tag-info.js+++ /dev/null@@ -1,18 +0,0 @@-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/app/routes/tag/edit.js b/frontend/discourse/app/routes/tag/edit.jsindex c18f54dab20..b64627d529a 100644--- a/frontend/discourse/app/routes/tag/edit.js+++ b/frontend/discourse/app/routes/tag/edit.js@@ -4,20 +4,10 @@ import { i18n } from "discourse-i18n";export default class TagEditRoute extends DiscourseRoute {@service router;- @service siteSettings;@service store;@service currentUser;beforeModel() {- if (!this.siteSettings.experimental_tag_settings_page) {- const params = this.paramsFor("tag.edit");- return this.router.replaceWith(- "tag.show",- params.tag_slug,- params.tag_id- );- }-if (!this.currentUser?.canEditTags) {const params = this.paramsFor("tag.edit");return this.router.replaceWith(diff --git a/frontend/discourse/app/templates/discovery/list.gjs b/frontend/discourse/app/templates/discovery/list.gjsindex a55ec0b3f93..b60823e5c32 100644--- a/frontend/discourse/app/templates/discovery/list.gjs+++ b/frontend/discourse/app/templates/discovery/list.gjs@@ -2,15 +2,12 @@ import CategoriesDisplay from "discourse/components/discovery/categories-displayimport Layout from "discourse/components/discovery/layout";import Navigation from "discourse/components/discovery/navigation";import Topics from "discourse/components/discovery/topics";-import TagInfo from "discourse/components/tag-info";-import { and } from "discourse/truth-helpers";import { i18n } from "discourse-i18n";export default <template><Layout@model={{@controller.model}}@createTopicDisabled={{@controller.createTopicDisabled}}- @toggleTagInfo={{@controller.toggleTagInfo}}@listClass="--topic-list"><:navigation>@@ -25,7 +22,6 @@ export default <template>@createTopic={{@controller.createTopic}}@createTopicDisabled={{@controller.createTopicDisabled}}@canCreateTopicOnTag={{@controller.model.canCreateTopicOnTag}}- @toggleTagInfo={{@controller.toggleTagInfo}}@tagNotification={{@controller.model.tagNotification}}@model={{@controller.model.list}}@showDismissRead={{@controller.showDismissRead}}@@ -43,14 +39,6 @@ export default <template>@loadMore={{@controller.model.subcategoryList.loadMore}}/>{{/if}}- {{#unless @controller.siteSettings.experimental_tag_settings_page}}- {{#if (and @controller.model.tag @controller.showTagInfo)}}- <TagInfo- @tag={{@controller.model.tag}}- @list={{@controller.model.list}}- />- {{/if}}- {{/unless}}</:header><:list>diff --git a/frontend/discourse/tests/acceptance/tags-test.js b/frontend/discourse/tests/acceptance/tags-test.jsindex c673456bfb3..27fa1eb2da0 100644--- a/frontend/discourse/tests/acceptance/tags-test.js+++ b/frontend/discourse/tests/acceptance/tags-test.js@@ -1,4 +1,4 @@-import { click, currentURL, fillIn, visit } from "@ember/test-helpers";+import { click, currentURL, visit } from "@ember/test-helpers";import { test } from "qunit";import { withPluginApi } from "discourse/lib/plugin-api";import formKit from "discourse/tests/helpers/form-kit-helper";@@ -7,7 +7,6 @@ import {queryAll,updateCurrentUser,} from "discourse/tests/helpers/qunit-helpers";-import selectKit from "discourse/tests/helpers/select-kit-helper";import { i18n } from "discourse-i18n";acceptance("Tags", function (needs) {@@ -368,72 +367,6 @@ acceptance("Tag info", function (needs) {}));- server.get("/tag/13/notifications.json", () =>- helper.response({- tag_notification: {- id: 13,- name: "happy-monkey",- notification_level: 1,- },- })- );-- server.get("/tag/13/l/latest.json", () =>- helper.response({- users: [],- primary_groups: [],- topic_list: {- can_create_topic: true,- draft: null,- draft_key: "new_topic",- draft_sequence: 1,- per_page: 30,- tags: [- {- id: 13,- name: "happy-monkey",- slug: "happy-monkey",- topic_count: 1,- },- ],- topics: [],- },- })- );-- server.get("/tag/14/notifications.json", () =>- helper.response({- tag_notification: {- id: 14,- name: "happy-monkey2",- notification_level: 1,- },- })- );-- server.get("/tag/14/l/latest.json", () =>- helper.response({- users: [],- primary_groups: [],- topic_list: {- can_create_topic: true,- draft: null,- draft_key: "new_topic",- draft_sequence: 1,- per_page: 30,- tags: [- {- id: 14,- name: "happy-monkey2",- slug: "happy-monkey2",- topic_count: 1,- },- ],- topics: [],- },- })- );-["/tags/c/faq/4/planters/12/l/latest.json","/tags/c/feature/2/planters/12/l/latest.json",@@ -522,146 +455,6 @@ acceptance("Tag info", function (needs) {],});});- server.put("/tag/13.json", (request) => {- const data = helper.parsePostData(request.requestBody);- // ID stays the same when renaming - use 13 (original tag ID)- return helper.response({- tag: { id: 13, name: data.tag.name, slug: data.tag.name },- });- });-- server.get("/tag/13/info.json", () => {- return helper.response({- tag_info: {- id: 13,- name: "happy-monkey",- slug: "happy-monkey",- description: "happy monkey description",- topic_count: 1,- staff: false,- synonyms: [],- tag_group_names: [],- category_ids: [],- },- categories: [],- });- });-- server.get("/tag/13/l/latest.json", () =>- helper.response({- users: [],- primary_groups: [],- topic_list: {- topics: [],- tags: [{ id: 13, name: "happy-monkey", slug: "happy-monkey" }],- },- })- );-- server.delete("/tag/12/synonyms/22.json", () =>- helper.response({ success: true })- );-- server.get("/tags/filter/search", () =>- helper.response({- results: [- { id: "monkey", name: "monkey", count: 1 },- { id: "not-monkey", name: "not-monkey", count: 1 },- { id: "happy-monkey", name: "happy-monkey", count: 1 },- ],- })- );- });-- test("tag info can show synonyms", async function (assert) {- updateCurrentUser({ moderator: false, admin: false });-- await visit("/tag/planters/12");- assert.dom("#show-tag-info").exists();-- await click("#show-tag-info");- assert.dom(".tag-info .tag-name").exists("show tag");- assert- .dom(".tag-info .tag-associations")- .includesText("Gardening", "show tag group names");- assert- .dom(".tag-info .synonyms-list .tag-box")- .exists({ count: 2 }, "shows the synonyms");- assert.dom(".tag-info .badge-category").exists("show the category");- assert.dom("#rename-tag").doesNotExist("can't rename tag");- assert.dom("#edit-synonyms").doesNotExist("can't edit synonyms");- assert.dom("#delete-tag").doesNotExist("can't delete tag");- });-- test("tag info hides only current tag in synonyms dropdown", async function (assert) {- updateCurrentUser({ moderator: false, admin: true, can_edit_tags: true });-- await visit("/tag/happy-monkey/13");- assert.dom("#show-tag-info").exists();-- await click("#show-tag-info");- assert.dom(".tag-info .tag-name").exists("show tag");-- await click("#edit-synonyms");-- const addSynonymsDropdown = selectKit("#add-synonyms");- await addSynonymsDropdown.expand();-- assert.deepEqual(- Array.from(addSynonymsDropdown.rows()).map((r) => {- return r.dataset.value;- }),- ["monkey", "not-monkey"]- );- });-- test("edit tag is showing input for name and description", async function (assert) {- updateCurrentUser({ moderator: false, admin: true, can_edit_tags: true });-- await visit("/tag/happy-monkey/13");- assert.dom("#show-tag-info").exists();-- await click("#show-tag-info");- assert.dom(".tag-info .tag-name").exists("show tag");-- await click(".edit-tag");- assert- .dom("#edit-name")- .hasValue("happy-monkey", "displays original tag name");- assert- .dom("#edit-description")- .hasValue(- "happy monkey description",- "displays original tag description"- );-- await fillIn("#edit-description", "new description");- await click(".submit-edit");- assert.strictEqual(- currentURL(),- "/tag/happy-monkey/13",- "doesn't change URL"- );-- await click(".edit-tag");- await fillIn("#edit-name", "happy-monkey2");- await click(".submit-edit");- assert.strictEqual(- currentURL(),- "/tag/happy-monkey2/13",- "changes URL to new tag path"- );- });-- test("tag info hides when tag filter removed", async function (assert) {- await visit("/tag/happy-monkey/13");-- await click("#show-tag-info");- assert.dom(".tag-info .tag-name").exists();-- await visit("/latest");-- assert.dom(".tag-info").doesNotExist("tag info is not shown on homepage");});test("can filter tags page by category", async function (assert) {@@ -731,31 +524,6 @@ acceptance("Tag info", function (needs) {assert.strictEqual(currentURL(), "/tags/c/feature/2/planters/12/l/hot");});- test("admin can manage tags", async function (assert) {- updateCurrentUser({ moderator: false, admin: true, can_edit_tags: true });-- await visit("/tag/planters/12");- assert.dom("#show-tag-info").exists();-- await click("#show-tag-info");- assert.dom(".edit-tag").exists("can rename tag");- assert.dom("#edit-synonyms").exists("can edit synonyms");- assert.dom("#delete-tag").exists("can delete tag");-- await click("#edit-synonyms");- assert- .dom(".unlink-synonym")- .isVisible({ count: 2 }, "unlink UI is visible");- assert- .dom(".delete-synonym")- .isVisible({ count: 2 }, "delete UI is visible");-- await click(".unlink-synonym:nth-of-type(1)");- assert- .dom(".tag-info .synonyms-list .tag-box")- .exists({ count: 1 }, "removed a synonym");- });-test("composer will not set tags if user cannot create them", async function (assert) {await visit("/tag/planters/12");await click("#create-topic");@@ -924,9 +692,6 @@ acceptance("Tag separator customization", function (needs) {acceptance("Tag settings page", function (needs) {needs.user();- needs.settings({- experimental_tag_settings_page: true,- });needs.pretender((server, helper) => {server.get("/tag/100/notifications.json", () =>helper.response({@@ -1097,84 +862,3 @@ acceptance("Tag settings page", function (needs) {.hasText("test-synonym", "shows existing synonym");});});--acceptance("Tag settings page - disabled", function (needs) {- needs.user();- needs.settings({- experimental_tag_settings_page: false,- });- needs.pretender((server, helper) => {- server.get("/tag/100/notifications.json", () =>- helper.response({- tag_notification: {- id: 100,- name: "test-tag",- notification_level: 1,- },- })- );-- server.get("/tag/100/l/latest.json", () =>- helper.response({- users: [],- primary_groups: [],- topic_list: {- can_create_topic: true,- draft: null,- draft_key: "new_topic",- draft_sequence: 1,- per_page: 30,- tags: [- {- id: 100,- name: "test-tag",- slug: "test-tag",- topic_count: 5,- },- ],- topics: [],- },- })- );-- server.get("/tag/100/info.json", () =>- helper.response({- tag_info: {- id: 100,- name: "test-tag",- slug: "test-tag",- description: "test description",- topic_count: 5,- staff: false,- synonyms: [],- tag_group_names: [],- category_ids: [],- },- categories: [],- })- );- });-- test("shows pencil icon for inline editing when setting disabled", async function (assert) {- updateCurrentUser({ moderator: false, admin: true, can_edit_tags: true });-- await visit("/tag/test-tag/100");- await click("#show-tag-info");-- assert- .dom(".tag-info .tag-name-wrapper .edit-tag")- .exists("edit icon exists");- assert- .dom(".tag-info .tag-name-wrapper .edit-tag .d-icon-pencil")- .exists("shows pencil icon for inline editing");- });-- test("shows edit synonyms button when setting disabled", async function (assert) {- updateCurrentUser({ moderator: false, admin: true, can_edit_tags: true });-- await visit("/tag/test-tag/100");- await click("#show-tag-info");-- assert.dom("#edit-synonyms").exists("edit synonyms button exists");- });-});diff --git a/frontend/discourse/tests/helpers/create-pretender.js b/frontend/discourse/tests/helpers/create-pretender.jsindex 76e0f2adf6c..62fc50687f4 100644--- a/frontend/discourse/tests/helpers/create-pretender.js+++ b/frontend/discourse/tests/helpers/create-pretender.js@@ -221,6 +221,22 @@ export function applyDefaultHandlers() {});});+ pretender.get("/tag/:tag_id/info.json", (request) => {+ return response({+ tag_info: {+ id: parseInt(request.params.tag_id, 10) || request.params.tag_id,+ name: request.params.tag_id,+ slug: request.params.tag_id,+ topic_count: 0,+ staff: false,+ synonyms: [],+ tag_group_names: [],+ category_ids: [],+ },+ categories: [],+ });+ });+pretender.delete("/bookmarks/:id", () => response({}));pretender.get("/tags/filter/search", (request) => {diff --git a/spec/system/page_objects/pages/tag.rb b/spec/system/page_objects/pages/tag.rbindex 3831ff20e51..559995c883a 100644--- a/spec/system/page_objects/pages/tag.rb+++ b/spec/system/page_objects/pages/tag.rb@@ -16,80 +16,14 @@ module PageObjectshas_css?("#show-tag-info")end- def edit_synonyms_btn- find("#edit-synonyms")- end-- def add_synonym_btn- find(".add-synonyms .ok")- end-- def confirm_synonym_btn- find(".dialog-footer .btn-primary")- end-- def open_edit_tag- find(".tag-name-wrapper .edit-tag").click- end-- def fill_tag_name(new_name)- find("#edit-name").fill_in(with: new_name)- end-- def fill_tag_description(new_description)- find("#edit-description").fill_in(with: new_description)- end-- def save_edit- find(".edit-controls .submit-edit").click- end-- def cancel_edit- find(".edit-controls .cancel-edit").click- end-- def delete_tag- find(".delete-tag").click+ def has_no_tag_info_btn?+ has_no_css?("#show-tag-info")enddef has_no_tag?(name)has_no_css?(".tag-box", text: name)end- def add_synonyms_dropdown- PageObjects::Components::SelectKit.new("#add-synonyms")- end-- def search_tags(query)- add_synonyms_dropdown.search(query)- end-- def select_tag(value: nil, index: nil, name: nil)- if value- add_synonyms_dropdown.select_row_by_value(value)- elsif name- add_synonyms_dropdown.select_row_by_name(name)- elsif index- add_synonyms_dropdown.select_row_by_index(index)- end- end-- def tag_box(tag)- find(".tag-box div[data-tag-name='#{tag}']")- end-- def tag_info- find(".tag-info")- end-- def tag_name_within_tag_info- tag_info.find(".tag-name-wrapper .discourse-tag").text- end-- def tag_description_within_tag_info- tag_info.find(".tag-description-wrapper").text- end-def tags_dropdownPageObjects::Components::SelectKit.new(".select-kit.tag-drop")enddiff --git a/spec/system/tag_settings_spec.rb b/spec/system/tag_settings_spec.rbindex 61de794d3a5..547f13a4908 100644--- a/spec/system/tag_settings_spec.rb+++ b/spec/system/tag_settings_spec.rb@@ -18,9 +18,7 @@ describe "Tag Settings" doSiteSetting.edit_tags_allowed_groups = "1|2|14"end- context "when experimental_tag_settings_page is enabled" do- before { SiteSetting.experimental_tag_settings_page = true }-+ context "when using the tag settings page" doit "loads the tag edit page for tags with empty slugs" dotag_1.update_column(:slug, "")sign_in(admin)@@ -49,7 +47,7 @@ describe "Tag Settings" dosign_in(user)tags_page.visit_tag(tag_1)- expect(tags_page).to have_tag_info_btn+ expect(tags_page).to have_no_tag_info_btnvisit("/tag/#{tag_1.slug}/#{tag_1.id}/edit/general")expect(page).to have_current_path("/tag/#{tag_1.slug}/#{tag_1.id}")end@@ -107,125 +105,41 @@ describe "Tag Settings" doendend- context "when experimental_tag_settings_page is disabled" do- before { SiteSetting.experimental_tag_settings_page = false }-- context "when signed in as admin" do- before { sign_in(admin) }-- it "allows the admin to edit a tag name and description, and delete the tag" do- tags_page.visit_tag(tag_1)- tags_page.tag_info_btn.click- tags_page.open_edit_tag-- tags_page.fill_tag_name("ux")- tags_page.fill_tag_description("new description")- tags_page.save_edit- expect(tags_page.tag_info).to have_content("ux")- expect(tags_page.tag_info).to have_content("new description")-- tags_page.delete_tag- expect(dialog).to be_open- dialog.click_danger- expect(tags_page).to have_no_tag("design")- end-- it "does not error when editing a tag name to something then reverting back to the original name" do- tags_page.visit_tag(tag_1)- tags_page.tag_info_btn.click- tags_page.open_edit_tag- tags_page.fill_tag_name("ux")- tags_page.save_edit- expect(tags_page.tag_info).to have_content("ux")- tags_page.open_edit_tag- tags_page.fill_tag_name("design")- tags_page.save_edit- expect(tags_page.tag_info).to have_content("design")- end-- it "allows adding tags as synonyms" do- tags_page.visit_tag(tag_1)- tags_page.tag_info_btn.click- tags_page.edit_synonyms_btn.click-- tags_page.select_tag(index: 0)- tags_page.search_tags("kittehs")- tags_page.select_tag(value: "kittehs")- tags_page.add_synonym_btn.click-- expect(tags_page.confirm_synonym_btn).to be_visible- tags_page.confirm_synonym_btn.click-- expect(tags_page.tag_box(tag_2.name)).to be_visible- expect(tags_page.tag_box("kittehs")).to be_visible- end- end-- context "when signed in as a user allowed to edit tags" do- before { sign_in(trust_level_4) }+ context "when navigating to a synonym tag" do+ fab!(:target_tag) { Fabricate(:tag, name: "broccoli") }+ fab!(:synonym_tag) { Fabricate(:tag, name: "cauliflower", target_tag:) }+ fab!(:target_tagged_topic) { Fabricate(:topic, tags: [target_tag]) }- it "allows the user to edit a tag name and description, but cannot delete the tag" do- tags_page.visit_tag(tag_1)- tags_page.tag_info_btn.click- tags_page.open_edit_tag+ let(:topic_list) { PageObjects::Components::TopicList.new }- tags_page.fill_tag_name("ux")- tags_page.fill_tag_description("new description")- tags_page.save_edit- expect(tags_page.tag_info).to have_content("ux")- expect(tags_page.tag_info).to have_content("new description")-- expect(tags_page.tag_info).to have_no_css(".delete-tag")- end- end+ it "redirects to the target tag" do+ tags_page.visit_tag(tag_2)- context "when signed in as a regular user" do- before { sign_in(user) }+ tags_page.tags_dropdown.expand+ tags_page.tags_dropdown.search(synonym_tag.name)+ tags_page.tags_dropdown.select_row_by_name(synonym_tag.name)- it "does not allow the user to edit or delete the tag" do- tags_page.visit_tag(tag_1)- tags_page.tag_info_btn.click- expect(tags_page.tag_info).to have_no_css(".edit-tag")- expect(tags_page.tag_info).to have_no_css(".delete-tag")- end+ expect(topic_list).to have_topic(target_tagged_topic)+ expect(page).to have_current_path("/tag/#{target_tag.name}/#{target_tag.id}")+ expect(tags_page.tags_dropdown).to have_selected_name(target_tag.name)end- context "when navigating to a synonym tag" do- fab!(:target_tag) { Fabricate(:tag, name: "broccoli") }- fab!(:synonym_tag) { Fabricate(:tag, name: "cauliflower", target_tag:) }- fab!(:target_tagged_topic) { Fabricate(:topic, tags: [target_tag]) }-- let(:topic_list) { PageObjects::Components::TopicList.new }-- it "redirects to the target tag" do- tags_page.visit_tag(tag_2)-- tags_page.tags_dropdown.expand- tags_page.tags_dropdown.search(synonym_tag.name)- tags_page.tags_dropdown.select_row_by_name(synonym_tag.name)-- expect(topic_list).to have_topic(target_tagged_topic)- expect(page).to have_current_path("/tag/#{target_tag.name}/#{target_tag.id}")- expect(tags_page.tags_dropdown).to have_selected_name(target_tag.name)- end-- it "redirects to the target tag when within a category" do- category = Fabricate(:category)- target_tagged_topic.update!(category: category)+ it "redirects to the target tag when within a category" do+ category = Fabricate(:category)+ target_tagged_topic.update!(category: category)- page.visit("/tags/c/#{category.slug}/#{category.id}/#{tag_2.name}")- expect(page).to have_css(".tag-drop")+ page.visit("/tags/c/#{category.slug}/#{category.id}/#{tag_2.name}")+ expect(page).to have_css(".tag-drop")- tags_page.tags_dropdown.expand- tags_page.tags_dropdown.search(synonym_tag.name)- tags_page.tags_dropdown.select_row_by_name(synonym_tag.name)+ tags_page.tags_dropdown.expand+ tags_page.tags_dropdown.search(synonym_tag.name)+ tags_page.tags_dropdown.select_row_by_name(synonym_tag.name)- expect(topic_list).to have_topic(target_tagged_topic)- expect(page).to have_current_path(- "/tags/c/#{category.slug}/#{category.id}/#{target_tag.name}/#{target_tag.id}",- )- expect(tags_page.tags_dropdown).to have_selected_name(target_tag.name)- end+ expect(topic_list).to have_topic(target_tagged_topic)+ expect(page).to have_current_path(+ "/tags/c/#{category.slug}/#{category.id}/#{target_tag.name}/#{target_tag.id}",+ )+ expect(tags_page.tags_dropdown).to have_selected_name(target_tag.name)endendenddiff --git a/spec/system/tag_view_spec.rb b/spec/system/tag_view_spec.rbdeleted file mode 100644index 0a7fa2e3c9d..00000000000--- a/spec/system/tag_view_spec.rb+++ /dev/null@@ -1,31 +0,0 @@-# frozen_string_literal: true--describe "Tag view" do- fab!(:tag_1) { Fabricate(:tag, name: "design") }- fab!(:tag_2) { Fabricate(:tag, name: "art") }- fab!(:topic) { Fabricate(:topic, tags: [tag_2]) }- fab!(:current_user, :admin)-- let(:tags_page) { PageObjects::Pages::Tag.new }- let(:topic_list) { PageObjects::Components::TopicList.new }-- before { sign_in(current_user) }-- describe "the tag info section" do- context "when navigating to another tag" do- it "shows the details of the new tag" do- tags_page.visit_tag(tag_1)-- tags_page.tag_info_btn.click- expect(tags_page.tag_name_within_tag_info).to eq(tag_1.name)-- tags_page.tags_dropdown.expand- tags_page.tags_dropdown.search(tag_2.name)- tags_page.tags_dropdown.select_row_by_name(tag_2.name)-- expect(topic_list).to have_topic(topic)- expect(tags_page.tag_name_within_tag_info).to eq(tag_2.name)- end- end- end-end