A platform for community discussion. Free, open, simple.
FIX: assign URL to group was pointing to topic, not group (#36477)
Régis Hanol731fc8143dcd
diff --git a/plugins/discourse-assign/assets/javascripts/discourse/components/assigned-to-first-post.gjs b/plugins/discourse-assign/assets/javascripts/discourse/components/assigned-to-first-post.gjsindex 5a91ae2bb8c..4854d8130c9 100644--- a/plugins/discourse-assign/assets/javascripts/discourse/components/assigned-to-first-post.gjs+++ b/plugins/discourse-assign/assets/javascripts/discourse/components/assigned-to-first-post.gjs@@ -4,7 +4,11 @@ import { htmlSafe } from "@ember/template";import icon from "discourse/helpers/d-icon";import { bind } from "discourse/lib/decorators";import { i18n } from "discourse-i18n";-import { assignedToGroupPath, assignedToUserPath } from "../lib/url";+import {+ assignedToGroupPath,+ assignedToPostPath,+ assignedToUserPath,+} from "../lib/url";export default class AssignedToFirstPost extends Component {@service siteSettings;@@ -31,13 +35,11 @@ export default class AssignedToFirstPost extends Component {}return Object.keys(this.indirectlyAssignedTo).map((postId) => {- const postNumber = this.indirectlyAssignedTo[postId].post_number;-return {postId,assignee: this.indirectlyAssignedTo[postId].assigned_to,- postNumber,- url: `${this.args.post.topic.url}/${postNumber}`,+ postNumber: this.indirectlyAssignedTo[postId].post_number,+ url: assignedToPostPath(postId),};});}diff --git a/plugins/discourse-assign/assets/javascripts/discourse/initializers/extend-for-assigns.js b/plugins/discourse-assign/assets/javascripts/discourse/initializers/extend-for-assigns.jsindex cfd964aee38..e178ca2db37 100644--- a/plugins/discourse-assign/assets/javascripts/discourse/initializers/extend-for-assigns.js+++ b/plugins/discourse-assign/assets/javascripts/discourse/initializers/extend-for-assigns.js@@ -15,7 +15,11 @@ import BulkActionsAssignUser from "../components/bulk-actions/bulk-assign-user";import EditTopicAssignments from "../components/modal/edit-topic-assignments";import PostAssignmentsDisplay from "../components/post-assignments-display";import TopicLevelAssignMenu from "../components/topic-level-assign-menu";-import { assignedToGroupPath, assignedToUserPath } from "../lib/url";+import {+ assignedToGroupPath,+ assignedToPostPath,+ assignedToUserPath,+} from "../lib/url";import { extendTopicModel } from "../models/topic";const DEPENDENT_KEYS = [@@ -395,9 +399,11 @@ function initialize(api) {const createTagHtml = ({ assignee, note }) => {let assignedPath;if (assignee.assignedToPostId) {- assignedPath = `/p/${assignee.assignedToPostId}`;+ assignedPath = assignedToPostPath(assignee.assignedToPostId);+ } else if (assignee.username) {+ assignedPath = assignedToUserPath(assignee);} else {- assignedPath = `/t/${topic.id}`;+ assignedPath = assignedToGroupPath(assignee);}const icon = iconHTML(assignee.username ? "user-plus" : "group-plus");@@ -409,9 +415,7 @@ function initialize(api) {const tagName = params.tagName || "a";const href =- tagName === "a"- ? `href="${getURL(assignedPath)}" data-auto-route="true"`- : "";+ tagName === "a" ? `href="${assignedPath}" data-auto-route="true"` : "";return `<${tagName} class="assigned-to discourse-tag simple" ${href}>${icon}<span title="${escapeExpression(notediff --git a/plugins/discourse-assign/assets/javascripts/discourse/lib/url.js b/plugins/discourse-assign/assets/javascripts/discourse/lib/url.jsindex 208cecf0f06..80478b110e8 100644--- a/plugins/discourse-assign/assets/javascripts/discourse/lib/url.js+++ b/plugins/discourse-assign/assets/javascripts/discourse/lib/url.js@@ -17,3 +17,7 @@ export function assignedToUserPath(assignedToUser) {export function assignedToGroupPath(assignedToGroup) {return getURL(`/g/${assignedToGroup.name}/assigned/everyone`);}++export function assignedToPostPath(postId) {+ return getURL(`/p/${postId}`);+}diff --git a/plugins/discourse-assign/test/javascripts/acceptance/assigned-topic-test.js b/plugins/discourse-assign/test/javascripts/acceptance/assigned-topic-test.jsindex cf91d2145f5..1b47298d526 100644--- a/plugins/discourse-assign/test/javascripts/acceptance/assigned-topic-test.js+++ b/plugins/discourse-assign/test/javascripts/acceptance/assigned-topic-test.js@@ -113,8 +113,11 @@ acceptance(`Discourse Assign | Assigned topic`, function (needs) {assert.dom("#post_1 .assigned-to svg.d-icon-user-plus").exists();assert.dom("#post_1 .assigned-to a[href='/']").exists();assert- .dom(".discourse-tags .assigned-to[href='/t/28830'] span")+ .dom(".discourse-tags .assigned-to[href='/'] span").hasAttribute("title", "Shark Doododooo", "shows topic assign notes");+ assert+ .dom(".discourse-tags .assigned-to[href='/']")+ .exists("header tag links to the user's assigned page");assert.dom(".discourse-tags .assigned-to[href='/p/2'] span").hasAttribute(@@ -144,6 +147,11 @@ acceptance(`Discourse Assign | Assigned topic`, function (needs) {assert.dom("#post_1 .assigned-to a[href='/g/Developers/assigned/everyone']").exists();+ assert+ .dom(+ ".discourse-tags .assigned-to[href='/g/Developers/assigned/everyone']"+ )+ .exists("header tag links to the group's assigned page");assert.dom("#topic-footer-dropdown-reassign").exists("shows reassign dropdown at the bottom of the topic");