浏览代码

Do not show create org link when allow_org_create is set to false, Fixes #2135

Torkel Ödegaard 10 年之前
父节点
当前提交
5962bcbc6c
共有 4 个文件被更改,包括 9 次插入8 次删除
  1. 1 0
      pkg/api/api.go
  2. 1 1
      pkg/api/frontendsettings.go
  3. 0 2
      pkg/setting/setting.go
  4. 7 5
      public/app/controllers/sidemenuCtrl.js

+ 1 - 0
pkg/api/api.go

@@ -26,6 +26,7 @@ func Register(r *macaron.Macaron) {
 	// authed views
 	r.Get("/profile/", reqSignedIn, Index)
 	r.Get("/org/", reqSignedIn, Index)
+	r.Get("/org/new", reqSignedIn, Index)
 	r.Get("/datasources/", reqSignedIn, Index)
 	r.Get("/datasources/edit/*", reqSignedIn, Index)
 	r.Get("/org/users/", reqSignedIn, Index)

+ 1 - 1
pkg/api/frontendsettings.go

@@ -99,7 +99,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
 		"defaultDatasource": defaultDatasource,
 		"datasources":       datasources,
 		"appSubUrl":         setting.AppSubUrl,
-		"viewerRoleMode":    setting.ViewerRoleMode,
+		"allowOrgCreate":    setting.AllowUserOrgCreate || c.IsGrafanaAdmin,
 		"buildInfo": map[string]interface{}{
 			"version":    setting.BuildVersion,
 			"commit":     setting.BuildCommit,

+ 0 - 2
pkg/setting/setting.go

@@ -79,7 +79,6 @@ var (
 	AllowUserOrgCreate bool
 	AutoAssignOrg      bool
 	AutoAssignOrgRole  string
-	ViewerRoleMode     string
 
 	// Http auth
 	AdminUser     string
@@ -386,7 +385,6 @@ func NewConfigContext(args *CommandLineArgs) {
 	AllowUserOrgCreate = users.Key("allow_org_create").MustBool(true)
 	AutoAssignOrg = users.Key("auto_assign_org").MustBool(true)
 	AutoAssignOrgRole = users.Key("auto_assign_org_role").In("Editor", []string{"Editor", "Admin", "Viewer"})
-	ViewerRoleMode = users.Key("viewer_role_mode").In("default", []string{"default", "strinct"})
 
 	// anonymous access
 	AnonymousEnabled = Cfg.Section("auth.anonymous").Key("enabled").MustBool(false)

+ 7 - 5
public/app/controllers/sidemenuCtrl.js

@@ -68,11 +68,13 @@ function (angular, _, $, config) {
           });
         });
 
-        $scope.orgMenu.push({
-          text: "New Organization",
-          icon: "fa fa-fw fa-plus",
-          href: $scope.getUrl('/org/new')
-        });
+        if (config.allowOrgCreate) {
+          $scope.orgMenu.push({
+            text: "New Organization",
+            icon: "fa fa-fw fa-plus",
+            href: $scope.getUrl('/org/new')
+          });
+        }
       });
     };