FIX: show group filter only when user is logged in and groups are present (#14578)

This commit is contained in:
Arpit Jalan 2021-10-12 19:46:39 +05:30 committed by GitHub
parent b44119cdb2
commit d2f9108470
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 19 deletions

View File

@ -3,7 +3,7 @@ import Group from "discourse/models/group";
import { action } from "@ember/object";
import discourseDebounce from "discourse-common/lib/debounce";
import showModal from "discourse/lib/show-modal";
import { equal } from "@ember/object/computed";
import { and, equal } from "@ember/object/computed";
import { longDate } from "discourse/lib/formatter";
import { observes } from "discourse-common/utils/decorators";
@ -19,8 +19,9 @@ export default Controller.extend({
exclude_usernames: null,
isLoading: false,
columns: null,
groupsOptions: null,
groupOptions: null,
params: null,
showGroupFilter: and("currentUser", "groupOptions"),
showTimeRead: equal("period", "all"),
@ -66,15 +67,17 @@ export default Controller.extend({
},
loadGroups() {
return Group.findAll({ ignore_automatic: true }).then((groups) => {
const groupOptions = groups.map((group) => {
return {
name: group.full_name || group.name,
id: group.name,
};
if (this.currentUser) {
return Group.findAll({ ignore_automatic: true }).then((groups) => {
const groupOptions = groups.map((group) => {
return {
name: group.full_name || group.name,
id: group.name,
};
});
this.set("groupOptions", groupOptions);
});
this.set("groupOptions", groupOptions);
});
}
},
@action

View File

@ -25,15 +25,17 @@
placeholderKey="directory.filter_name"
class="filter-name no-blur"
}}
{{combo-box
class="directory-group-selector"
value=group
content=groupOptions
onChange=(action groupChanged)
options=(hash
none="directory.group.all"
)
}}
{{#if showGroupFilter}}
{{combo-box
class="directory-group-selector"
value=group
content=groupOptions
onChange=(action groupChanged)
options=(hash
none="directory.group.all"
)
}}
{{/if}}
{{#if currentUser.staff}}
{{d-button
icon="wrench"