浏览代码

Roles: New user role that replaces the old role behavior, Closes #2088

Torkel Ödegaard 10 年之前
父节点
当前提交
ff3843bc7f
共有 5 个文件被更改,包括 11 次插入9 次删除
  1. 1 0
      CHANGELOG.md
  2. 1 1
      pkg/api/dashboard.go
  3. 5 4
      pkg/models/org_user.go
  4. 3 3
      public/app/features/org/partials/orgUsers.html
  5. 1 1
      public/app/services/contextSrv.js

+ 1 - 0
CHANGELOG.md

@@ -9,6 +9,7 @@
 
 
 **User or Organization admin**
 **User or Organization admin**
 - [Issue #1899](https://github.com/grafana/grafana/issues/1899). Organization: You can now update the organization user role directly (without removing and readding the organization user).
 - [Issue #1899](https://github.com/grafana/grafana/issues/1899). Organization: You can now update the organization user role directly (without removing and readding the organization user).
+- [Issue #2088](https://github.com/grafana/grafana/issues/2088). Roles: New user role `Read Only Editor` that replaces the old `Viewer` role behavior
 
 
 **Backend**
 **Backend**
 - [Issue #1905](https://github.com/grafana/grafana/issues/1905). Github OAuth: You can now configure a Github team membership requirement, thx @dewski
 - [Issue #1905](https://github.com/grafana/grafana/issues/1905). Github OAuth: You can now configure a Github team membership requirement, thx @dewski

+ 1 - 1
pkg/api/dashboard.go

@@ -55,7 +55,7 @@ func GetDashboard(c *middleware.Context) {
 			Type:      m.DashTypeDB,
 			Type:      m.DashTypeDB,
 			CanStar:   c.IsSignedIn,
 			CanStar:   c.IsSignedIn,
 			CanSave:   c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR,
 			CanSave:   c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR,
-			CanEdit:   c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR,
+			CanEdit:   c.OrgRole == m.ROLE_ADMIN || c.OrgRole == m.ROLE_EDITOR || c.OrgRole == m.ROLE_READ_ONLY_EDITOR,
 		},
 		},
 	}
 	}
 
 

+ 5 - 4
pkg/models/org_user.go

@@ -15,13 +15,14 @@ var (
 type RoleType string
 type RoleType string
 
 
 const (
 const (
-	ROLE_VIEWER RoleType = "Viewer"
-	ROLE_EDITOR RoleType = "Editor"
-	ROLE_ADMIN  RoleType = "Admin"
+	ROLE_VIEWER           RoleType = "Viewer"
+	ROLE_EDITOR           RoleType = "Editor"
+	ROLE_READ_ONLY_EDITOR RoleType = "Read Only Editor"
+	ROLE_ADMIN            RoleType = "Admin"
 )
 )
 
 
 func (r RoleType) IsValid() bool {
 func (r RoleType) IsValid() bool {
-	return r == ROLE_VIEWER || r == ROLE_ADMIN || r == ROLE_EDITOR
+	return r == ROLE_VIEWER || r == ROLE_ADMIN || r == ROLE_EDITOR || r == ROLE_READ_ONLY_EDITOR
 }
 }
 
 
 type OrgUser struct {
 type OrgUser struct {

+ 3 - 3
public/app/features/org/partials/orgUsers.html

@@ -12,7 +12,7 @@
 		<form name="form">
 		<form name="form">
 			<div class="tight-form">
 			<div class="tight-form">
 				<ul class="tight-form-list">
 				<ul class="tight-form-list">
-					<li class="tight-form-item" style="width: 160px">
+					<li class="tight-form-item" style="width: 127px">
 						<strong>Username or Email</strong>
 						<strong>Username or Email</strong>
 					</li>
 					</li>
 					<li>
 					<li>
@@ -22,7 +22,7 @@
 						role
 						role
 					</li>
 					</li>
 					<li>
 					<li>
-						<select type="text" ng-model="user.role" class="input-small tight-form-input" ng-options="f for f in ['Viewer', 'Editor', 'Admin']">
+						<select type="text" ng-model="user.role" class="input-medium tight-form-input" ng-options="f for f in ['Viewer', 'Editor', 'Read Only Editor', 'Admin']">
 						</select>
 						</select>
 					</li>
 					</li>
 					<li>
 					<li>
@@ -46,7 +46,7 @@
 				<td>{{user.login}}</td>
 				<td>{{user.login}}</td>
 				<td>{{user.email}}</td>
 				<td>{{user.email}}</td>
 				<td>
 				<td>
-					<select type="text" ng-model="user.role" class="input-small" ng-options="f for f in ['Viewer', 'Editor', 'Admin']" ng-change="updateOrgUser(user)">
+					<select type="text" ng-model="user.role" class="input-medium" ng-options="f for f in ['Viewer', 'Editor', 'Read Only Editor', 'Admin']" ng-change="updateOrgUser(user)">
 					</select>
 					</select>
 				</td>
 				</td>
 				<td style="width: 1%">
 				<td style="width: 1%">

+ 1 - 1
public/app/services/contextSrv.js

@@ -60,6 +60,6 @@ function (angular, _, store, config) {
       store.set('grafana.sidemenu', false);
       store.set('grafana.sidemenu', false);
     }
     }
 
 
-    this.isEditor = this.hasRole('Editor') || this.hasRole('Admin') || this.hasRole('Read Only Editor');
+    this.isEditor = this.hasRole('Editor') || this.hasRole('Admin');
   });
   });
 });
 });