Skip to content

Commit 5962bcb

Browse files
committed
Do not show create org link when allow_org_create is set to false, Fixes grafana#2135
1 parent b39f8fb commit 5962bcb

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

pkg/api/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ func Register(r *macaron.Macaron) {
2626
// authed views
2727
r.Get("/profile/", reqSignedIn, Index)
2828
r.Get("/org/", reqSignedIn, Index)
29+
r.Get("/org/new", reqSignedIn, Index)
2930
r.Get("/datasources/", reqSignedIn, Index)
3031
r.Get("/datasources/edit/*", reqSignedIn, Index)
3132
r.Get("/org/users/", reqSignedIn, Index)

pkg/api/frontendsettings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func getFrontendSettingsMap(c *middleware.Context) (map[string]interface{}, erro
9999
"defaultDatasource": defaultDatasource,
100100
"datasources": datasources,
101101
"appSubUrl": setting.AppSubUrl,
102-
"viewerRoleMode": setting.ViewerRoleMode,
102+
"allowOrgCreate": setting.AllowUserOrgCreate || c.IsGrafanaAdmin,
103103
"buildInfo": map[string]interface{}{
104104
"version": setting.BuildVersion,
105105
"commit": setting.BuildCommit,

pkg/setting/setting.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ var (
7979
AllowUserOrgCreate bool
8080
AutoAssignOrg bool
8181
AutoAssignOrgRole string
82-
ViewerRoleMode string
8382

8483
// Http auth
8584
AdminUser string
@@ -386,7 +385,6 @@ func NewConfigContext(args *CommandLineArgs) {
386385
AllowUserOrgCreate = users.Key("allow_org_create").MustBool(true)
387386
AutoAssignOrg = users.Key("auto_assign_org").MustBool(true)
388387
AutoAssignOrgRole = users.Key("auto_assign_org_role").In("Editor", []string{"Editor", "Admin", "Viewer"})
389-
ViewerRoleMode = users.Key("viewer_role_mode").In("default", []string{"default", "strinct"})
390388

391389
// anonymous access
392390
AnonymousEnabled = Cfg.Section("auth.anonymous").Key("enabled").MustBool(false)

public/app/controllers/sidemenuCtrl.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ function (angular, _, $, config) {
6868
});
6969
});
7070

71-
$scope.orgMenu.push({
72-
text: "New Organization",
73-
icon: "fa fa-fw fa-plus",
74-
href: $scope.getUrl('/org/new')
75-
});
71+
if (config.allowOrgCreate) {
72+
$scope.orgMenu.push({
73+
text: "New Organization",
74+
icon: "fa fa-fw fa-plus",
75+
href: $scope.getUrl('/org/new')
76+
});
77+
}
7678
});
7779
};
7880

0 commit comments

Comments
 (0)