diff --git a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js index 323fff9..b6390ea 100644 --- a/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js +++ b/assets/javascripts/discourse-assign/initializers/extend-for-assigns.js @@ -4,7 +4,6 @@ import discourseComputed from "discourse-common/utils/decorators"; import { iconHTML, iconNode } from "discourse-common/lib/icon-library"; import { escapeExpression } from "discourse/lib/utilities"; import { h } from "virtual-dom"; -import { queryRegistry } from "discourse/widgets/widget"; import { getOwner } from "discourse-common/lib/get-owner"; import { htmlSafe } from "@ember/template"; import getURL from "discourse-common/lib/get-url"; @@ -658,24 +657,6 @@ function initialize(api) { } }); - api.addUserMenuGlyph((widget) => { - if (widget.currentUser && widget.currentUser.can_assign) { - const glyph = { - label: "discourse_assign.assigned", - className: "assigned", - icon: "user-plus", - href: `${widget.currentUser.path}/activity/assigned`, - }; - - if (queryRegistry("quick-access-panel")) { - glyph["action"] = "quickAccess"; - glyph["actionParam"] = "assignments"; - } - - return glyph; - } - }); - api.createWidget("assigned-to", { html(attrs) { let { assignedToUser, assignedToGroup, href } = attrs; diff --git a/assets/javascripts/discourse/widgets/assigned-notification-item.js b/assets/javascripts/discourse/widgets/assigned-notification-item.js deleted file mode 100644 index e81ac85..0000000 --- a/assets/javascripts/discourse/widgets/assigned-notification-item.js +++ /dev/null @@ -1,15 +0,0 @@ -import { iconNode } from "discourse-common/lib/icon-library"; -import { DefaultNotificationItem } from "discourse/widgets/default-notification-item"; -import { createWidgetFrom } from "discourse/widgets/widget"; - -createWidgetFrom(DefaultNotificationItem, "assigned-notification-item", { - icon(notificationName, data) { - if (data.message === "discourse_assign.assign_group_notification") { - return iconNode( - `notification.discourse_assign.assign_group_notification` - ); - } - - return iconNode(`notification.${notificationName}`); - }, -}); diff --git a/assets/javascripts/discourse/widgets/quick-access-assignments.js b/assets/javascripts/discourse/widgets/quick-access-assignments.js deleted file mode 100644 index 1328438..0000000 --- a/assets/javascripts/discourse/widgets/quick-access-assignments.js +++ /dev/null @@ -1,75 +0,0 @@ -import RawHtml from "discourse/widgets/raw-html"; -import { iconHTML } from "discourse-common/lib/icon-library"; -import { - createWidget, - createWidgetFrom, - queryRegistry, -} from "discourse/widgets/widget"; -import getURL from "discourse-common/lib/get-url"; -import { postUrl } from "discourse/lib/utilities"; -import { h } from "virtual-dom"; -import I18n from "I18n"; -import { htmlSafe } from "@ember/template"; - -const ICON = "user-plus"; -const GROUP_ICON = "group-plus"; - -createWidget("no-quick-access-assignments", { - html() { - return h("div.empty-state", [ - h("span.empty-state-title", I18n.t("user.no_assignments_title")), - h( - "div.empty-state-body", - new RawHtml({ - html: - "
" + - htmlSafe( - I18n.t("user.no_assignments_body", { - preferencesUrl: getURL("/my/preferences/notifications"), - icon: iconHTML(ICON), - }) - ) + - "
", - }) - ), - ]); - }, -}); - -const QuickAccessPanel = queryRegistry("quick-access-panel"); - -if (QuickAccessPanel) { - createWidgetFrom(QuickAccessPanel, "quick-access-assignments", { - buildKey: () => "quick-access-assignments", - emptyStateWidget: "no-quick-access-assignments", - - showAllHref() { - return `${this.attrs.path}/activity/assigned`; - }, - - findNewItems() { - return this.store - .findFiltered("topicList", { - filter: `topics/messages-assigned/${this.currentUser.username_lower}`, - params: { - exclude_category_ids: [-1], - }, - }) - .then(({ topic_list }) => { - return topic_list.topics; - }); - }, - - itemHtml(assignedTopic) { - return this.attach("quick-access-item", { - icon: assignedTopic.assigned_to_group ? GROUP_ICON : ICON, - href: postUrl( - assignedTopic.slug, - assignedTopic.id, - assignedTopic.last_read_post_number + 1 - ), - escapedContent: assignedTopic.fancy_title, - }); - }, - }); -} diff --git a/test/javascripts/acceptance/assigned-notification-item-test.js b/test/javascripts/acceptance/assigned-notification-item-test.js deleted file mode 100644 index 4510fb4..0000000 --- a/test/javascripts/acceptance/assigned-notification-item-test.js +++ /dev/null @@ -1,73 +0,0 @@ -import { click, visit } from "@ember/test-helpers"; -import { acceptance, query } from "discourse/tests/helpers/qunit-helpers"; -import { test } from "qunit"; - -acceptance("Discourse Assign | Assignment notifications", function (needs) { - needs.user(); - needs.settings({ assign_enabled: true, assigns_user_url_path: "/" }); - - needs.pretender((server, helper) => { - server.get("/notifications", () => - helper.response({ - notifications: [ - { - id: 43, - user_id: 2, - notification_type: 34, - read: false, - high_priority: true, - created_at: "2022-01-01T12:00:00.000Z", - post_number: 1, - topic_id: 43, - fancy_title: "An assigned topic", - slug: "user-assigned-topic", - data: { - message: "discourse_assign.assign_notification", - display_username: "Username", - topic_title: "An assigned topic", - assignment_id: 4, - }, - }, - { - id: 42, - user_id: 2, - notification_type: 34, - read: false, - high_priority: true, - created_at: "2022-01-01T12:00:00.000Z", - post_number: 1, - topic_id: 42, - fancy_title: "A group assigned topic", - slug: "group-assigned-topic", - data: { - message: "discourse_assign.assign_group_notification", - display_username: "Groupname", - topic_title: "A group assigned topic", - assignment_id: 3, - }, - }, - ], - seen_notification_id: 43, - }) - ); - }); - - test("Shows the right icons", async function (assert) { - await visit("/"); - await click("#current-user.header-dropdown-toggle"); - - const userAssignment = query(".quick-access-panel li:nth-child(1) a"); - assert.ok( - userAssignment - .querySelector(".d-icon") - .classList.contains("d-icon-user-plus") - ); - - const groupAssignment = query(".quick-access-panel li:nth-child(2) a"); - assert.ok( - groupAssignment - .querySelector(".d-icon") - .classList.contains("d-icon-group-plus") - ); - }); -}); diff --git a/test/javascripts/acceptance/assigns-tab-user-menu-test.js b/test/javascripts/acceptance/assigns-tab-user-menu-test.js index 01af8d0..08e0446 100644 --- a/test/javascripts/acceptance/assigns-tab-user-menu-test.js +++ b/test/javascripts/acceptance/assigns-tab-user-menu-test.js @@ -199,9 +199,12 @@ const USER_MENU_ASSIGN_RESPONSE = { }; acceptance( - "Discourse Assign | experimental user menu | user cannot assign", + "Discourse Assign | user menu | user cannot assign", function (needs) { - needs.user({ redesigned_user_menu_enabled: true, can_assign: false }); + needs.user({ + redesigned_user_menu_enabled: true, // TODO(@keegan): Remove after site setting is removed in core + can_assign: false, + }); needs.settings({ assign_enabled: true, }); @@ -215,9 +218,12 @@ acceptance( ); acceptance( - "Discourse Assign | experimental user menu | assign_enabled setting is disabled", + "Discourse Assign | user menu | assign_enabled setting is disabled", function (needs) { - needs.user({ redesigned_user_menu_enabled: true, can_assign: true }); + needs.user({ + redesigned_user_menu_enabled: true, // TODO(@keegan): Remove after site setting is removed in core + can_assign: false, + }); needs.settings({ assign_enabled: false, }); @@ -230,9 +236,9 @@ acceptance( } ); -acceptance("Discourse Assign | experimental user menu", function (needs) { +acceptance("Discourse Assign | user menu", function (needs) { needs.user({ - redesigned_user_menu_enabled: true, + redesigned_user_menu_enabled: true, // TODO(@keegan): Remove after site setting is removed in core can_assign: true, grouped_unread_notifications: { 34: 173, // assigned notification type diff --git a/test/javascripts/acceptance/quick-access-assignments-test.js b/test/javascripts/acceptance/quick-access-assignments-test.js deleted file mode 100644 index f4546f7..0000000 --- a/test/javascripts/acceptance/quick-access-assignments-test.js +++ /dev/null @@ -1,42 +0,0 @@ -import { - acceptance, - query, - updateCurrentUser, -} from "discourse/tests/helpers/qunit-helpers"; -import { click, currentURL, visit } from "@ember/test-helpers"; -import AssignedTopics from "../fixtures/assigned-topics-fixtures"; -import { test } from "qunit"; - -acceptance( - "Discourse Assign | Quick access assignments panel", - function (needs) { - needs.user(); - needs.settings({ assign_enabled: true, assigns_user_url_path: "/" }); - - needs.pretender((server, helper) => { - const messagesPath = "/topics/messages-assigned/eviltrout.json"; - const assigns = AssignedTopics[messagesPath]; - server.get(messagesPath, () => helper.response(assigns)); - }); - - test("Quick access assignments panel", async function (assert) { - updateCurrentUser({ can_assign: true }); - - await visit("/"); - await click("#current-user.header-dropdown-toggle"); - - await click(".widget-button.assigned"); - const assignment = query(".quick-access-panel li a"); - - assert.ok(assignment.innerText.includes("Greetings!")); - assert.ok(assignment.href.includes("/t/greetings/10/5")); - - await click(".widget-button.assigned"); - assert.strictEqual( - currentURL(), - "/u/eviltrout/activity/assigned", - "a second click should redirect to the full assignments page" - ); - }); - } -);