FIX: Show restricted groups warning when necessary (#16236)
It was displayed for the "everyone" group too, but that was not necessary.
This commit is contained in:
parent
7b5ef41a43
commit
1516dd75f5
|
@ -21,9 +21,38 @@ export default Controller.extend(
|
|||
onShow() {
|
||||
this.set("showNotifyUsers", false);
|
||||
|
||||
if (this.model && this.model.read_restricted) {
|
||||
this.restrictedGroupWarning();
|
||||
this.appEvents.on(
|
||||
"modal:body-shown",
|
||||
this,
|
||||
this.showRestrictedGroupWarning
|
||||
);
|
||||
},
|
||||
|
||||
onClose() {
|
||||
this.appEvents.off(
|
||||
"modal:body-shown",
|
||||
this,
|
||||
this.showRestrictedGroupWarning
|
||||
);
|
||||
},
|
||||
|
||||
showRestrictedGroupWarning() {
|
||||
if (!this.model) {
|
||||
return;
|
||||
}
|
||||
|
||||
Category.reloadBySlugPath(this.model.slug).then((result) => {
|
||||
const groups = result.category.group_permissions.mapBy("group_name");
|
||||
if (groups && !groups.any((x) => x === "everyone")) {
|
||||
this.flash(
|
||||
I18n.t("topic.share.restricted_groups", {
|
||||
count: groups.length,
|
||||
groups: groups.join(", "),
|
||||
}),
|
||||
"warning"
|
||||
);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@discourseComputed("topic.shareUrl")
|
||||
|
@ -111,24 +140,5 @@ export default Controller.extend(
|
|||
topicTitle: this.topic.title,
|
||||
});
|
||||
},
|
||||
|
||||
restrictedGroupWarning() {
|
||||
this.appEvents.on("modal:body-shown", () => {
|
||||
let restrictedGroups;
|
||||
Category.reloadBySlugPath(this.model.slug).then((result) => {
|
||||
restrictedGroups = result.category.group_permissions.map(
|
||||
(g) => g.group_name
|
||||
);
|
||||
|
||||
if (restrictedGroups) {
|
||||
const message = I18n.t("topic.share.restricted_groups", {
|
||||
count: restrictedGroups.length,
|
||||
groupNames: restrictedGroups.join(", "),
|
||||
});
|
||||
this.flash(message, "warning");
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import CategoryFixtures from "discourse/tests/fixtures/category-fixtures";
|
||||
import { click, visit } from "@ember/test-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
|
@ -11,6 +12,12 @@ import { test } from "qunit";
|
|||
acceptance("Share and Invite modal", function (needs) {
|
||||
needs.user();
|
||||
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/c/feature/find_by_slug.json", () =>
|
||||
helper.response(200, CategoryFixtures["/c/1/show.json"])
|
||||
);
|
||||
});
|
||||
|
||||
test("Topic footer button", async function (assert) {
|
||||
await visit("/t/internationalization-localization/280");
|
||||
|
||||
|
|
|
@ -20,10 +20,14 @@ import { skip, test } from "qunit";
|
|||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import topicFixtures from "discourse/tests/fixtures/topic";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
import CategoryFixtures from "discourse/tests/fixtures/category-fixtures";
|
||||
|
||||
acceptance("Topic", function (needs) {
|
||||
needs.user();
|
||||
needs.pretender((server, helper) => {
|
||||
server.get("/c/feature/find_by_slug.json", () => {
|
||||
return helper.response(200, CategoryFixtures["/c/1/show.json"]);
|
||||
});
|
||||
server.put("/posts/398/wiki", () => {
|
||||
return helper.response({});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue