FEATURE: Make plugin compatible with redesigned user messages (#399)
This commit is contained in:
parent
889df32cc6
commit
feca27b6bd
|
@ -1,6 +1,8 @@
|
|||
export default {
|
||||
resource: "user.userPrivateMessages",
|
||||
map() {
|
||||
this.route("assigned");
|
||||
this.route("assigned", { path: "/assigned" }, function () {
|
||||
this.route("index", { path: "/" });
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
import I18n from "I18n";
|
||||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
|
||||
export default {
|
||||
name: "assign-extend-user-messages",
|
||||
|
||||
initialize(container) {
|
||||
withPluginApi("1.5.0", (api) => {
|
||||
const currentUser = container.lookup("service:current-user");
|
||||
|
||||
if (currentUser?.can_assign && api.addUserMessagesNavigationDropdownRow) {
|
||||
api.addUserMessagesNavigationDropdownRow(
|
||||
"userPrivateMessages.assigned",
|
||||
I18n.t("discourse_assign.assigned"),
|
||||
"user-plus"
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
<UserNav::MessagesSecondaryNav>
|
||||
<li class="messages-assigned-latest">
|
||||
<LinkTo @route="userPrivateMessages.assigned.index">
|
||||
{{d-icon "envelope"}}
|
||||
<span>{{i18n "categories.latest"}}</span>
|
||||
</LinkTo>
|
||||
</li>
|
||||
</UserNav::MessagesSecondaryNav>
|
||||
|
||||
{{outlet}}
|
|
@ -0,0 +1,62 @@
|
|||
import I18n from "I18n";
|
||||
import {
|
||||
acceptance,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||
import AssignedTopics from "../fixtures/assigned-topics-fixtures";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import { test } from "qunit";
|
||||
|
||||
acceptance("User Private Messages | Discourse Assign", function (needs) {
|
||||
needs.user({
|
||||
can_assign: true,
|
||||
});
|
||||
|
||||
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
|
||||
|
||||
needs.pretender((server, helper) => {
|
||||
const assignments = cloneJSON(
|
||||
AssignedTopics["/topics/messages-assigned/eviltrout.json"]
|
||||
);
|
||||
|
||||
server.get("/topics/private-messages-assigned/eviltrout.json", () =>
|
||||
helper.response(assignments)
|
||||
);
|
||||
});
|
||||
|
||||
test("viewing assigned messages", async function (assert) {
|
||||
await visit("/u/eviltrout/messages");
|
||||
await click(".assigned-messages a");
|
||||
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
"/u/eviltrout/messages/assigned",
|
||||
"transitioned to the assigned page"
|
||||
);
|
||||
});
|
||||
|
||||
test("viewing assigned messages when redesigned user page nav has been enabled", async function (assert) {
|
||||
updateCurrentUser({ redesigned_user_page_nav_enabled: true });
|
||||
|
||||
await visit("/u/eviltrout/messages");
|
||||
|
||||
const messagesDropdown = selectKit(".user-nav-messages-dropdown");
|
||||
|
||||
await messagesDropdown.expand();
|
||||
await messagesDropdown.selectRowByName(I18n.t("discourse_assign.assigned"));
|
||||
|
||||
assert.strictEqual(
|
||||
currentURL(),
|
||||
"/u/eviltrout/messages/assigned",
|
||||
"transitioned to the assigned page"
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
messagesDropdown.header().name(),
|
||||
I18n.t("discourse_assign.assigned"),
|
||||
"assigned messages is selected in the dropdown"
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue