Browse Source

added setting top hide plugins in alpha state

Torkel Ödegaard 7 years ago
parent
commit
565edc1ed3

+ 3 - 0
conf/defaults.ini

@@ -554,3 +554,6 @@ container_name =
 # Options to configure external image rendering server like https://github.com/grafana/grafana-image-renderer
 # Options to configure external image rendering server like https://github.com/grafana/grafana-image-renderer
 server_url =
 server_url =
 callback_url =
 callback_url =
+
+[panels]
+enable_alpha = false

+ 58 - 58
pkg/api/api.go

@@ -22,66 +22,66 @@ func (hs *HTTPServer) registerRoutes() {
 	r := hs.RouteRegister
 	r := hs.RouteRegister
 
 
 	// not logged in views
 	// not logged in views
-	r.Get("/", reqSignedIn, Index)
+	r.Get("/", reqSignedIn, hs.Index)
 	r.Get("/logout", Logout)
 	r.Get("/logout", Logout)
 	r.Post("/login", quota("session"), bind(dtos.LoginCommand{}), Wrap(LoginPost))
 	r.Post("/login", quota("session"), bind(dtos.LoginCommand{}), Wrap(LoginPost))
 	r.Get("/login/:name", quota("session"), OAuthLogin)
 	r.Get("/login/:name", quota("session"), OAuthLogin)
-	r.Get("/login", LoginView)
-	r.Get("/invite/:code", Index)
+	r.Get("/login", hs.LoginView)
+	r.Get("/invite/:code", hs.Index)
 
 
 	// authed views
 	// authed views
-	r.Get("/profile/", reqSignedIn, Index)
-	r.Get("/profile/password", reqSignedIn, Index)
-	r.Get("/profile/switch-org/:id", reqSignedIn, ChangeActiveOrgAndRedirectToHome)
-	r.Get("/org/", reqSignedIn, Index)
-	r.Get("/org/new", reqSignedIn, Index)
-	r.Get("/datasources/", reqSignedIn, Index)
-	r.Get("/datasources/new", reqSignedIn, Index)
-	r.Get("/datasources/edit/*", reqSignedIn, Index)
-	r.Get("/org/users", reqSignedIn, Index)
-	r.Get("/org/users/new", reqSignedIn, Index)
-	r.Get("/org/users/invite", reqSignedIn, Index)
-	r.Get("/org/teams", reqSignedIn, Index)
-	r.Get("/org/teams/*", reqSignedIn, Index)
-	r.Get("/org/apikeys/", reqSignedIn, Index)
-	r.Get("/dashboard/import/", reqSignedIn, Index)
-	r.Get("/configuration", reqGrafanaAdmin, Index)
-	r.Get("/admin", reqGrafanaAdmin, Index)
-	r.Get("/admin/settings", reqGrafanaAdmin, Index)
-	r.Get("/admin/users", reqGrafanaAdmin, Index)
-	r.Get("/admin/users/create", reqGrafanaAdmin, Index)
-	r.Get("/admin/users/edit/:id", reqGrafanaAdmin, Index)
-	r.Get("/admin/orgs", reqGrafanaAdmin, Index)
-	r.Get("/admin/orgs/edit/:id", reqGrafanaAdmin, Index)
-	r.Get("/admin/stats", reqGrafanaAdmin, Index)
-
-	r.Get("/styleguide", reqSignedIn, Index)
-
-	r.Get("/plugins", reqSignedIn, Index)
-	r.Get("/plugins/:id/edit", reqSignedIn, Index)
-	r.Get("/plugins/:id/page/:page", reqSignedIn, Index)
-
-	r.Get("/d/:uid/:slug", reqSignedIn, Index)
-	r.Get("/d/:uid", reqSignedIn, Index)
-	r.Get("/dashboard/db/:slug", reqSignedIn, redirectFromLegacyDashboardURL, Index)
-	r.Get("/dashboard/script/*", reqSignedIn, Index)
-	r.Get("/dashboard-solo/snapshot/*", Index)
-	r.Get("/d-solo/:uid/:slug", reqSignedIn, Index)
-	r.Get("/dashboard-solo/db/:slug", reqSignedIn, redirectFromLegacyDashboardSoloURL, Index)
-	r.Get("/dashboard-solo/script/*", reqSignedIn, Index)
-	r.Get("/import/dashboard", reqSignedIn, Index)
-	r.Get("/dashboards/", reqSignedIn, Index)
-	r.Get("/dashboards/*", reqSignedIn, Index)
-
-	r.Get("/explore", reqEditorRole, Index)
-
-	r.Get("/playlists/", reqSignedIn, Index)
-	r.Get("/playlists/*", reqSignedIn, Index)
-	r.Get("/alerting/", reqSignedIn, Index)
-	r.Get("/alerting/*", reqSignedIn, Index)
+	r.Get("/profile/", reqSignedIn, hs.Index)
+	r.Get("/profile/password", reqSignedIn, hs.Index)
+	r.Get("/profile/switch-org/:id", reqSignedIn, hs.ChangeActiveOrgAndRedirectToHome)
+	r.Get("/org/", reqSignedIn, hs.Index)
+	r.Get("/org/new", reqSignedIn, hs.Index)
+	r.Get("/datasources/", reqSignedIn, hs.Index)
+	r.Get("/datasources/new", reqSignedIn, hs.Index)
+	r.Get("/datasources/edit/*", reqSignedIn, hs.Index)
+	r.Get("/org/users", reqSignedIn, hs.Index)
+	r.Get("/org/users/new", reqSignedIn, hs.Index)
+	r.Get("/org/users/invite", reqSignedIn, hs.Index)
+	r.Get("/org/teams", reqSignedIn, hs.Index)
+	r.Get("/org/teams/*", reqSignedIn, hs.Index)
+	r.Get("/org/apikeys/", reqSignedIn, hs.Index)
+	r.Get("/dashboard/import/", reqSignedIn, hs.Index)
+	r.Get("/configuration", reqGrafanaAdmin, hs.Index)
+	r.Get("/admin", reqGrafanaAdmin, hs.Index)
+	r.Get("/admin/settings", reqGrafanaAdmin, hs.Index)
+	r.Get("/admin/users", reqGrafanaAdmin, hs.Index)
+	r.Get("/admin/users/create", reqGrafanaAdmin, hs.Index)
+	r.Get("/admin/users/edit/:id", reqGrafanaAdmin, hs.Index)
+	r.Get("/admin/orgs", reqGrafanaAdmin, hs.Index)
+	r.Get("/admin/orgs/edit/:id", reqGrafanaAdmin, hs.Index)
+	r.Get("/admin/stats", reqGrafanaAdmin, hs.Index)
+
+	r.Get("/styleguide", reqSignedIn, hs.Index)
+
+	r.Get("/plugins", reqSignedIn, hs.Index)
+	r.Get("/plugins/:id/edit", reqSignedIn, hs.Index)
+	r.Get("/plugins/:id/page/:page", reqSignedIn, hs.Index)
+
+	r.Get("/d/:uid/:slug", reqSignedIn, hs.Index)
+	r.Get("/d/:uid", reqSignedIn, hs.Index)
+	r.Get("/dashboard/db/:slug", reqSignedIn, redirectFromLegacyDashboardURL, hs.Index)
+	r.Get("/dashboard/script/*", reqSignedIn, hs.Index)
+	r.Get("/dashboard-solo/snapshot/*", hs.Index)
+	r.Get("/d-solo/:uid/:slug", reqSignedIn, hs.Index)
+	r.Get("/dashboard-solo/db/:slug", reqSignedIn, redirectFromLegacyDashboardSoloURL, hs.Index)
+	r.Get("/dashboard-solo/script/*", reqSignedIn, hs.Index)
+	r.Get("/import/dashboard", reqSignedIn, hs.Index)
+	r.Get("/dashboards/", reqSignedIn, hs.Index)
+	r.Get("/dashboards/*", reqSignedIn, hs.Index)
+
+	r.Get("/explore", reqEditorRole, hs.Index)
+
+	r.Get("/playlists/", reqSignedIn, hs.Index)
+	r.Get("/playlists/*", reqSignedIn, hs.Index)
+	r.Get("/alerting/", reqSignedIn, hs.Index)
+	r.Get("/alerting/*", reqSignedIn, hs.Index)
 
 
 	// sign up
 	// sign up
-	r.Get("/signup", Index)
+	r.Get("/signup", hs.Index)
 	r.Get("/api/user/signup/options", Wrap(GetSignUpOptions))
 	r.Get("/api/user/signup/options", Wrap(GetSignUpOptions))
 	r.Post("/api/user/signup", quota("user"), bind(dtos.SignUpForm{}), Wrap(SignUp))
 	r.Post("/api/user/signup", quota("user"), bind(dtos.SignUpForm{}), Wrap(SignUp))
 	r.Post("/api/user/signup/step2", bind(dtos.SignUpStep2Form{}), Wrap(SignUpStep2))
 	r.Post("/api/user/signup/step2", bind(dtos.SignUpStep2Form{}), Wrap(SignUpStep2))
@@ -91,15 +91,15 @@ func (hs *HTTPServer) registerRoutes() {
 	r.Post("/api/user/invite/complete", bind(dtos.CompleteInviteForm{}), Wrap(CompleteInvite))
 	r.Post("/api/user/invite/complete", bind(dtos.CompleteInviteForm{}), Wrap(CompleteInvite))
 
 
 	// reset password
 	// reset password
-	r.Get("/user/password/send-reset-email", Index)
-	r.Get("/user/password/reset", Index)
+	r.Get("/user/password/send-reset-email", hs.Index)
+	r.Get("/user/password/reset", hs.Index)
 
 
 	r.Post("/api/user/password/send-reset-email", bind(dtos.SendResetPasswordEmailForm{}), Wrap(SendResetPasswordEmail))
 	r.Post("/api/user/password/send-reset-email", bind(dtos.SendResetPasswordEmailForm{}), Wrap(SendResetPasswordEmail))
 	r.Post("/api/user/password/reset", bind(dtos.ResetUserPasswordForm{}), Wrap(ResetPassword))
 	r.Post("/api/user/password/reset", bind(dtos.ResetUserPasswordForm{}), Wrap(ResetPassword))
 
 
 	// dashboard snapshots
 	// dashboard snapshots
-	r.Get("/dashboard/snapshot/*", Index)
-	r.Get("/dashboard/snapshots/", reqSignedIn, Index)
+	r.Get("/dashboard/snapshot/*", hs.Index)
+	r.Get("/dashboard/snapshots/", reqSignedIn, hs.Index)
 
 
 	// api for dashboard snapshots
 	// api for dashboard snapshots
 	r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot)
 	r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot)
@@ -251,7 +251,7 @@ func (hs *HTTPServer) registerRoutes() {
 			pluginRoute.Post("/:pluginId/settings", bind(m.UpdatePluginSettingCmd{}), Wrap(UpdatePluginSetting))
 			pluginRoute.Post("/:pluginId/settings", bind(m.UpdatePluginSettingCmd{}), Wrap(UpdatePluginSetting))
 		}, reqOrgAdmin)
 		}, reqOrgAdmin)
 
 
-		apiRoute.Get("/frontend/settings/", GetFrontendSettings)
+		apiRoute.Get("/frontend/settings/", hs.GetFrontendSettings)
 		apiRoute.Any("/datasources/proxy/:id/*", reqSignedIn, hs.ProxyDataSourceRequest)
 		apiRoute.Any("/datasources/proxy/:id/*", reqSignedIn, hs.ProxyDataSourceRequest)
 		apiRoute.Any("/datasources/proxy/:id", reqSignedIn, hs.ProxyDataSourceRequest)
 		apiRoute.Any("/datasources/proxy/:id", reqSignedIn, hs.ProxyDataSourceRequest)
 
 

+ 7 - 3
pkg/api/frontendsettings.go

@@ -11,7 +11,7 @@ import (
 	"github.com/grafana/grafana/pkg/util"
 	"github.com/grafana/grafana/pkg/util"
 )
 )
 
 
-func getFrontendSettingsMap(c *m.ReqContext) (map[string]interface{}, error) {
+func (hs *HTTPServer) getFrontendSettingsMap(c *m.ReqContext) (map[string]interface{}, error) {
 	orgDataSources := make([]*m.DataSource, 0)
 	orgDataSources := make([]*m.DataSource, 0)
 
 
 	if c.OrgId != 0 {
 	if c.OrgId != 0 {
@@ -120,6 +120,10 @@ func getFrontendSettingsMap(c *m.ReqContext) (map[string]interface{}, error) {
 
 
 	panels := map[string]interface{}{}
 	panels := map[string]interface{}{}
 	for _, panel := range enabledPlugins.Panels {
 	for _, panel := range enabledPlugins.Panels {
+		if panel.State == "alpha" && !hs.Cfg.EnableAlphaPanels {
+			continue
+		}
+
 		panels[panel.Id] = map[string]interface{}{
 		panels[panel.Id] = map[string]interface{}{
 			"module":       panel.Module,
 			"module":       panel.Module,
 			"baseUrl":      panel.BaseUrl,
 			"baseUrl":      panel.BaseUrl,
@@ -183,8 +187,8 @@ func getPanelSort(id string) int {
 	return sort
 	return sort
 }
 }
 
 
-func GetFrontendSettings(c *m.ReqContext) {
-	settings, err := getFrontendSettingsMap(c)
+func (hs *HTTPServer) GetFrontendSettings(c *m.ReqContext) {
+	settings, err := hs.getFrontendSettingsMap(c)
 	if err != nil {
 	if err != nil {
 		c.JsonApiErr(400, "Failed to get frontend settings", err)
 		c.JsonApiErr(400, "Failed to get frontend settings", err)
 		return
 		return

+ 1 - 1
pkg/api/http_server.go

@@ -184,7 +184,7 @@ func (hs *HTTPServer) applyRoutes() {
 	// then custom app proxy routes
 	// then custom app proxy routes
 	hs.initAppPluginRoutes(hs.macaron)
 	hs.initAppPluginRoutes(hs.macaron)
 	// lastly not found route
 	// lastly not found route
-	hs.macaron.NotFound(NotFoundHandler)
+	hs.macaron.NotFound(hs.NotFoundHandler)
 }
 }
 
 
 func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {
 func (hs *HTTPServer) addMiddlewaresAndStaticRoutes() {

+ 6 - 6
pkg/api/index.go

@@ -17,8 +17,8 @@ const (
 	darkName  = "dark"
 	darkName  = "dark"
 )
 )
 
 
-func setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, error) {
-	settings, err := getFrontendSettingsMap(c)
+func (hs *HTTPServer) setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, error) {
+	settings, err := hs.getFrontendSettingsMap(c)
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
@@ -353,8 +353,8 @@ func setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, error) {
 	return &data, nil
 	return &data, nil
 }
 }
 
 
-func Index(c *m.ReqContext) {
-	data, err := setIndexViewData(c)
+func (hs *HTTPServer) Index(c *m.ReqContext) {
+	data, err := hs.setIndexViewData(c)
 	if err != nil {
 	if err != nil {
 		c.Handle(500, "Failed to get settings", err)
 		c.Handle(500, "Failed to get settings", err)
 		return
 		return
@@ -362,13 +362,13 @@ func Index(c *m.ReqContext) {
 	c.HTML(200, "index", data)
 	c.HTML(200, "index", data)
 }
 }
 
 
-func NotFoundHandler(c *m.ReqContext) {
+func (hs *HTTPServer) NotFoundHandler(c *m.ReqContext) {
 	if c.IsApiRequest() {
 	if c.IsApiRequest() {
 		c.JsonApiErr(404, "Not found", nil)
 		c.JsonApiErr(404, "Not found", nil)
 		return
 		return
 	}
 	}
 
 
-	data, err := setIndexViewData(c)
+	data, err := hs.setIndexViewData(c)
 	if err != nil {
 	if err != nil {
 		c.Handle(500, "Failed to get settings", err)
 		c.Handle(500, "Failed to get settings", err)
 		return
 		return

+ 2 - 2
pkg/api/login.go

@@ -17,8 +17,8 @@ const (
 	ViewIndex = "index"
 	ViewIndex = "index"
 )
 )
 
 
-func LoginView(c *m.ReqContext) {
-	viewData, err := setIndexViewData(c)
+func (hs *HTTPServer) LoginView(c *m.ReqContext) {
+	viewData, err := hs.setIndexViewData(c)
 	if err != nil {
 	if err != nil {
 		c.Handle(500, "Failed to get settings", err)
 		c.Handle(500, "Failed to get settings", err)
 		return
 		return

+ 3 - 3
pkg/api/user.go

@@ -177,17 +177,17 @@ func UserSetUsingOrg(c *m.ReqContext) Response {
 }
 }
 
 
 // GET /profile/switch-org/:id
 // GET /profile/switch-org/:id
-func ChangeActiveOrgAndRedirectToHome(c *m.ReqContext) {
+func (hs *HTTPServer) ChangeActiveOrgAndRedirectToHome(c *m.ReqContext) {
 	orgID := c.ParamsInt64(":id")
 	orgID := c.ParamsInt64(":id")
 
 
 	if !validateUsingOrg(c.UserId, orgID) {
 	if !validateUsingOrg(c.UserId, orgID) {
-		NotFoundHandler(c)
+		hs.NotFoundHandler(c)
 	}
 	}
 
 
 	cmd := m.SetUsingOrgCommand{UserId: c.UserId, OrgId: orgID}
 	cmd := m.SetUsingOrgCommand{UserId: c.UserId, OrgId: orgID}
 
 
 	if err := bus.Dispatch(&cmd); err != nil {
 	if err := bus.Dispatch(&cmd); err != nil {
-		NotFoundHandler(c)
+		hs.NotFoundHandler(c)
 	}
 	}
 
 
 	c.Redirect(setting.AppSubUrl + "/")
 	c.Redirect(setting.AppSubUrl + "/")

+ 5 - 0
pkg/setting/setting.go

@@ -209,6 +209,8 @@ type Cfg struct {
 	TempDataLifetime time.Duration
 	TempDataLifetime time.Duration
 
 
 	MetricsEndpointEnabled bool
 	MetricsEndpointEnabled bool
+
+	EnableAlphaPanels bool
 }
 }
 
 
 type CommandLineArgs struct {
 type CommandLineArgs struct {
@@ -688,6 +690,9 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
 	explore := iniFile.Section("explore")
 	explore := iniFile.Section("explore")
 	ExploreEnabled = explore.Key("enabled").MustBool(false)
 	ExploreEnabled = explore.Key("enabled").MustBool(false)
 
 
+	panels := iniFile.Section("panels")
+	cfg.EnableAlphaPanels = panels.Key("enable_alpha").MustBool(false)
+
 	cfg.readSessionConfig()
 	cfg.readSessionConfig()
 	cfg.readSmtpSettings()
 	cfg.readSmtpSettings()
 	cfg.readQuotaSettings()
 	cfg.readQuotaSettings()

+ 0 - 0
public/app/plugins/panel/text2/img/icn-text-panel.svg → public/app/plugins/panel/graph2/img/icn-text-panel.svg


+ 9 - 3
public/app/plugins/panel/graph2/module.tsx

@@ -1,7 +1,7 @@
 import React, { PureComponent } from 'react';
 import React, { PureComponent } from 'react';
 import { PanelProps } from 'app/features/dashboard/dashgrid/DataPanel';
 import { PanelProps } from 'app/features/dashboard/dashgrid/DataPanel';
 
 
-export class ReactTestPanel extends PureComponent<PanelProps> {
+export class Graph2 extends PureComponent<PanelProps> {
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
   }
   }
@@ -14,8 +14,14 @@ export class ReactTestPanel extends PureComponent<PanelProps> {
       value = data[0].value;
       value = data[0].value;
     }
     }
 
 
-    return <h2>Graph Panel! {value}</h2>;
+    return <h2>Text Panel {value}</h2>;
   }
   }
 }
 }
 
 
-export { ReactTestPanel as PanelComponent };
+export class TextOptions extends PureComponent<any> {
+  render() {
+    return <p>Text2 Options component</p>;
+  }
+}
+
+export { Graph2 as PanelComponent, TextOptions as PanelOptions };

+ 2 - 2
public/app/plugins/panel/graph2/plugin.json

@@ -9,8 +9,8 @@
       "url": "https://grafana.com"
       "url": "https://grafana.com"
     },
     },
     "logos": {
     "logos": {
-      "small": "img/icn-graph-panel.svg",
-      "large": "img/icn-graph-panel.svg"
+      "small": "img/icn-text-panel.svg",
+      "large": "img/icn-text-panel.svg"
     }
     }
   }
   }
 }
 }

+ 0 - 0
public/app/plugins/panel/graph2/img/icn-graph-panel.svg → public/app/plugins/panel/text2/img/icn-graph-panel.svg


+ 3 - 9
public/app/plugins/panel/text2/module.tsx

@@ -1,7 +1,7 @@
 import React, { PureComponent } from 'react';
 import React, { PureComponent } from 'react';
 import { PanelProps } from 'app/features/dashboard/dashgrid/DataPanel';
 import { PanelProps } from 'app/features/dashboard/dashgrid/DataPanel';
 
 
-export class ReactTestPanel extends PureComponent<PanelProps> {
+export class Text2 extends PureComponent<PanelProps> {
   constructor(props) {
   constructor(props) {
     super(props);
     super(props);
   }
   }
@@ -14,14 +14,8 @@ export class ReactTestPanel extends PureComponent<PanelProps> {
       value = data[0].value;
       value = data[0].value;
     }
     }
 
 
-    return <h2>Text Panel {value}</h2>;
+    return <h2>Graph Panel! {value}</h2>;
   }
   }
 }
 }
 
 
-export class TextOptions extends PureComponent<any> {
-  render() {
-    return <p>Text2 Options component</p>;
-  }
-}
-
-export { ReactTestPanel as PanelComponent, TextOptions as PanelOptions };
+export { Text2 as PanelComponent };

+ 5 - 3
public/app/plugins/panel/text2/plugin.json

@@ -1,16 +1,18 @@
 {
 {
   "type": "panel",
   "type": "panel",
-  "name": "Text2",
+  "name": "Text v2",
   "id": "text2",
   "id": "text2",
 
 
+  "state": "alpha",
+
   "info": {
   "info": {
     "author": {
     "author": {
       "name": "Grafana Project",
       "name": "Grafana Project",
       "url": "https://grafana.com"
       "url": "https://grafana.com"
     },
     },
     "logos": {
     "logos": {
-      "small": "img/icn-text-panel.svg",
-      "large": "img/icn-text-panel.svg"
+      "small": "img/icn-graph-panel.svg",
+      "large": "img/icn-graph-panel.svg"
     }
     }
   }
   }
 }
 }