Torkel Ödegaard 8 лет назад
Родитель
Сommit
6f324cd794

+ 8 - 13
public/app/features/org/org_users_ctrl.ts

@@ -10,6 +10,7 @@ export class OrgUsersCtrl {
   users: any;
   pendingInvites: any;
   editor: any;
+  showInviteUI: boolean;
 
   /** @ngInject */
   constructor(private $scope, private $http, private backendSrv) {
@@ -17,10 +18,10 @@ export class OrgUsersCtrl {
       loginOrEmail: '',
       role: 'Viewer',
     };
+
     this.get();
     this.editor = { index: 0 };
-
-    $scope.disableInvites = config.disableLoginForm;
+    this.showInviteUI = config.disableLoginForm === false;
   }
 
   get() {
@@ -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) {
@@ -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,

+ 0 - 0
public/app/features/org/partials/addUser.html → public/app/features/org/partials/add_user.html


+ 4 - 8
public/app/features/org/partials/orgUsers.html

@@ -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">
@@ -21,7 +17,7 @@
 						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>
@@ -56,7 +52,7 @@
 		</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>