DEV: Remove old user menu related code

This commit is contained in:
Keegan George 2023-05-01 09:32:17 -07:00
parent ba47a238ac
commit 9b4fc3275f
No known key found for this signature in database
GPG Key ID: 91B40E38537AC000
4 changed files with 5 additions and 139 deletions

View File

@ -658,24 +658,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;

View File

@ -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")
);
});
});

View File

@ -199,9 +199,9 @@ 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({ can_assign: false });
needs.settings({
assign_enabled: true,
});
@ -215,9 +215,9 @@ 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({ can_assign: true });
needs.settings({
assign_enabled: false,
});
@ -230,9 +230,8 @@ acceptance(
}
);
acceptance("Discourse Assign | experimental user menu", function (needs) {
acceptance("Discourse Assign | user menu", function (needs) {
needs.user({
redesigned_user_menu_enabled: true,
can_assign: true,
grouped_unread_notifications: {
34: 173, // assigned notification type

View File

@ -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"
);
});
}
);