diff --git a/public/app/core/components/user_group_picker.ts b/public/app/core/components/user_group_picker.ts
index d3b9b2f8ef4..05f2c016f40 100644
--- a/public/app/core/components/user_group_picker.ts
+++ b/public/app/core/components/user_group_picker.ts
@@ -4,66 +4,38 @@ import _ from 'lodash';
const template = `
+
`;
export class UserGroupPickerCtrl {
- userGroupSegment: any;
- userGroupId: number;
- debouncedSearchUserGroups: any;
+ group: any;
+ userGroupPicked: any;
+ debouncedSearchGroups: any;
/** @ngInject */
constructor(private backendSrv, private $scope, $sce, private uiSegmentSrv) {
- this.debouncedSearchUserGroups = _.debounce(this.searchUserGroups, 500, {'leading': true, 'trailing': false});
- this.resetUserGroupSegment();
+ this.debouncedSearchGroups = _.debounce(this.searchGroups, 500, {'leading': true, 'trailing': false});
+ this.reset();
}
- resetUserGroupSegment() {
- this.userGroupId = null;
-
- const userGroupSegment = this.uiSegmentSrv.newSegment({
- value: 'Choose',
- selectMode: true,
- fake: true,
- cssClass: 'gf-size-auto'
- });
-
- if (!this.userGroupSegment) {
- this.userGroupSegment = userGroupSegment;
- } else {
- this.userGroupSegment.value = userGroupSegment.value;
- this.userGroupSegment.html = userGroupSegment.html;
- this.userGroupSegment.value = userGroupSegment.value;
- }
+ reset() {
+ this.group = {text: 'Choose', value: null};
}
- userGroupIdChanged(newVal) {
- if (!newVal) {
- this.resetUserGroupSegment();
- }
- }
-
- searchUserGroups(query: string) {
+ searchGroups(query: string) {
return Promise.resolve(this.backendSrv.get('/api/user-groups/search?perpage=10&page=1&query=' + query).then(result => {
- return _.map(result.userGroups, ug => { return this.uiSegmentSrv.newSegment(ug.name); });
+ return _.map(result.userGroups, ug => {
+ return {text: ug.name, value: ug};
+ });
}));
}
- onChange() {
- this.backendSrv.get('/api/user-groups/search?perpage=10&page=1&query=' + this.userGroupSegment.value)
- .then(result => {
- if (!result) {
- return;
- }
-
- result.userGroups.forEach(ug => {
- if (ug.name === this.userGroupSegment.value) {
- this.userGroupId = ug.id;
- }
- });
- });
+ onChange(option) {
+ this.userGroupPicked({$group: option.value});
}
}
@@ -75,11 +47,11 @@ export function userGroupPicker() {
bindToController: true,
controllerAs: 'ctrl',
scope: {
- userGroupId: '=',
+ userGroupPicked: '&',
},
link: function(scope, elem, attrs, ctrl) {
- scope.$watch("ctrl.userGroupId", (newVal, oldVal) => {
- ctrl.userGroupIdChanged(newVal);
+ scope.$on("user-group-picker-reset", () => {
+ ctrl.reset();
});
}
};
diff --git a/public/app/features/dashboard/acl/acl.html b/public/app/features/dashboard/acl/acl.html
index 02727459a38..78c8b6d52e2 100644
--- a/public/app/features/dashboard/acl/acl.html
+++ b/public/app/features/dashboard/acl/acl.html
@@ -31,7 +31,7 @@
|
- No permission, will only accessable by admins.
+ No permissions. Will only be accessible by admins.
|
@@ -41,25 +41,14 @@