Skip to content

Commit

Permalink
refactor: minor refactorings of grafana#7876
Browse files Browse the repository at this point in the history
  • Loading branch information
torkelo committed Mar 20, 2017
1 parent 737c29e commit 6f324cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
21 changes: 8 additions & 13 deletions public/app/features/org/org_users_ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ export class OrgUsersCtrl {
users: any;
pendingInvites: any;
editor: any;
showInviteUI: boolean;

/** @ngInject */
constructor(private $scope, private $http, private backendSrv) {
this.user = {
loginOrEmail: '',
role: 'Viewer',
};

this.get();
this.editor = { index: 0 };

$scope.disableInvites = config.disableLoginForm;
this.showInviteUI = config.disableLoginForm === false;
}

get() {
Expand Down Expand Up @@ -52,17 +53,13 @@ export class OrgUsersCtrl {

removeUserConfirmed(user) {
this.backendSrv.delete('/api/org/users/' + user.userId)
.then(() => {
this.get();
});
.then(this.get.bind(this));
}

revokeInvite(invite, evt) {
evt.stopPropagation();
this.backendSrv.patch('/api/org/invites/' + invite.code + '/revoke')
.then(() => {
this.get();
});
.then(this.get.bind(this));
}

copyInviteToClipboard(evt) {
Expand All @@ -71,13 +68,11 @@ export class OrgUsersCtrl {

openInviteModal() {
var modalScope = this.$scope.$new();
modalScope.invitesSent = () => {
this.get();
};
modalScope.invitesSent = this.get.bind(this);

var src = !this.$scope.disableInvites
var src = this.showInviteUI
? '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', {
src: src,
Expand Down
12 changes: 4 additions & 8 deletions public/app/features/org/partials/orgUsers.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
<h1>Organization users</h1>

<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>
Add or Invite
</button>
<button class="btn btn-success" ng-click="ctrl.openInviteModal()" ng-show="!!disableInvites">
<i class="fa fa-plus"></i>
Add
Add <span ng-show="ctrl.showInviteUI"> or Invite</span>
</button>

<ul class="gf-tabs">
Expand All @@ -21,7 +17,7 @@ <h1>Organization users</h1>
Users ({{ctrl.users.length}})
</a>
</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}">
Pending Invitations ({{ctrl.pendingInvites.length}})
</a>
Expand Down Expand Up @@ -56,7 +52,7 @@ <h1>Organization users</h1>
</table>
</div>

<div ng-if="ctrl.editor.index === 1 && !disableInvites">
<div ng-if="ctrl.editor.index === 1 && ctrl.showInviteUI">
<table class="filter-table form-inline">
<thead>
<tr>
Expand Down

0 comments on commit 6f324cd

Please sign in to comment.