refactor: minor refactorings of #7876

This commit is contained in:
Torkel Ödegaard 2017-03-20 11:18:29 +01:00
parent 737c29ec8c
commit 6f324cd794
3 changed files with 12 additions and 21 deletions

View File

@ -10,6 +10,7 @@ export class OrgUsersCtrl {
users: any; users: any;
pendingInvites: any; pendingInvites: any;
editor: any; editor: any;
showInviteUI: boolean;
/** @ngInject */ /** @ngInject */
constructor(private $scope, private $http, private backendSrv) { constructor(private $scope, private $http, private backendSrv) {
@ -17,10 +18,10 @@ export class OrgUsersCtrl {
loginOrEmail: '', loginOrEmail: '',
role: 'Viewer', role: 'Viewer',
}; };
this.get(); this.get();
this.editor = { index: 0 }; this.editor = { index: 0 };
this.showInviteUI = config.disableLoginForm === false;
$scope.disableInvites = config.disableLoginForm;
} }
get() { get() {
@ -52,17 +53,13 @@ export class OrgUsersCtrl {
removeUserConfirmed(user) { removeUserConfirmed(user) {
this.backendSrv.delete('/api/org/users/' + user.userId) this.backendSrv.delete('/api/org/users/' + user.userId)
.then(() => { .then(this.get.bind(this));
this.get();
});
} }
revokeInvite(invite, evt) { revokeInvite(invite, evt) {
evt.stopPropagation(); evt.stopPropagation();
this.backendSrv.patch('/api/org/invites/' + invite.code + '/revoke') this.backendSrv.patch('/api/org/invites/' + invite.code + '/revoke')
.then(() => { .then(this.get.bind(this));
this.get();
});
} }
copyInviteToClipboard(evt) { copyInviteToClipboard(evt) {
@ -71,13 +68,11 @@ export class OrgUsersCtrl {
openInviteModal() { openInviteModal() {
var modalScope = this.$scope.$new(); var modalScope = this.$scope.$new();
modalScope.invitesSent = () => { modalScope.invitesSent = this.get.bind(this);
this.get();
};
var src = !this.$scope.disableInvites var src = this.showInviteUI
? 'public/app/features/org/partials/invite.html' ? 'public/app/features/org/partials/invite.html'
: 'public/app/features/org/partials/addUser.html'; : 'public/app/features/org/partials/add_user.html';
this.$scope.appEvent('show-modal', { this.$scope.appEvent('show-modal', {
src: src, src: src,

View File

@ -6,13 +6,9 @@
<h1>Organization users</h1> <h1>Organization users</h1>
<div class="page-header-tabs"> <div class="page-header-tabs">
<button class="btn btn-success" ng-click="ctrl.openInviteModal()" ng-show="!disableInvites"> <button class="btn btn-success" ng-click="ctrl.openInviteModal()">
<i class="fa fa-plus"></i> <i class="fa fa-plus"></i>
Add or Invite Add <span ng-show="ctrl.showInviteUI"> or Invite</span>
</button>
<button class="btn btn-success" ng-click="ctrl.openInviteModal()" ng-show="!!disableInvites">
<i class="fa fa-plus"></i>
Add
</button> </button>
<ul class="gf-tabs"> <ul class="gf-tabs">
@ -21,7 +17,7 @@
Users ({{ctrl.users.length}}) Users ({{ctrl.users.length}})
</a> </a>
</li> </li>
<li class="gf-tabs-item" ng-show="!disableInvites"> <li class="gf-tabs-item" ng-show="ctrl.showInviteUI">
<a class="gf-tabs-link" ng-click="ctrl.editor.index = 1" ng-class="{active: ctrl.editor.index === 1}"> <a class="gf-tabs-link" ng-click="ctrl.editor.index = 1" ng-class="{active: ctrl.editor.index === 1}">
Pending Invitations ({{ctrl.pendingInvites.length}}) Pending Invitations ({{ctrl.pendingInvites.length}})
</a> </a>
@ -56,7 +52,7 @@
</table> </table>
</div> </div>
<div ng-if="ctrl.editor.index === 1 && !disableInvites"> <div ng-if="ctrl.editor.index === 1 && ctrl.showInviteUI">
<table class="filter-table form-inline"> <table class="filter-table form-inline">
<thead> <thead>
<tr> <tr>