Skip to content

Commit

Permalink
FIX: Check if plugin disabled globally prior to extending JS
Browse files Browse the repository at this point in the history
  • Loading branch information
nbianca authored and SamSaffron committed Nov 22, 2018
1 parent 1f938c3 commit 16afd2c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
Expand Up @@ -141,8 +141,7 @@ function initialize(api) {
api.addUserMenuGlyph(widget => {
if (
widget.currentUser &&
widget.currentUser.get("staff") &&
widget.siteSettings.assign_enabled
widget.currentUser.get("staff")
) {
return {
label: "discourse_assign.assigned",
Expand Down Expand Up @@ -217,6 +216,10 @@ function initialize(api) {
export default {
name: "extend-for-assign",
initialize(container) {
const siteSettings = container.lookup("site-settings:main");
if (!siteSettings.assign_enabled) {
return;
}
withPluginApi("0.8.11", api => initialize(api, container));
withPluginApi("0.8.13", api => modifySelectKit(api, container));
}
Expand Down
31 changes: 31 additions & 0 deletions test/javascripts/acceptance/assign-test.js.es6
@@ -0,0 +1,31 @@
import { acceptance } from "helpers/qunit-helpers";

acceptance("Assign (mobile)", {
loggedIn: true,
mobileView: true,
settings: { assign_enabled: true },
});

QUnit.test("Footer dropdown contains button", async assert => {
const menu = selectKit(".topic-footer-mobile-dropdown");

await visit("/t/internationalization-localization/280");
await menu.expand();

assert.ok(menu.rowByValue("assign").exists());
});

acceptance("Assign (mobile & disabled)", {
loggedIn: true,
mobileView: true,
settings: { assign_enabled: false },
});

QUnit.test("Footer dropdown does not contain button", async assert => {
const menu = selectKit(".topic-footer-mobile-dropdown");

await visit("/t/internationalization-localization/280");
await menu.expand();

assert.notOk(menu.rowByValue("assign").exists());
});

0 comments on commit 16afd2c

Please sign in to comment.