diff --git a/packages/grafana-runtime/src/config.ts b/packages/grafana-runtime/src/config.ts index b734f57ddb0..9f9d3ccc4c1 100644 --- a/packages/grafana-runtime/src/config.ts +++ b/packages/grafana-runtime/src/config.ts @@ -7,6 +7,7 @@ export interface BuildInfo { commit: string; isEnterprise: boolean; // deprecated: use licenseInfo.hasLicense instead env: string; + edition: string; latestVersion: string; hasUpdate: boolean; } @@ -21,6 +22,8 @@ interface FeatureToggles { interface LicenseInfo { hasLicense: boolean; expiry: number; + licenseUrl: string; + stateInfo: string; } export class GrafanaBootConfig { diff --git a/pkg/api/frontendsettings.go b/pkg/api/frontendsettings.go index 6dd6025f26c..4ed9de27172 100644 --- a/pkg/api/frontendsettings.go +++ b/pkg/api/frontendsettings.go @@ -194,6 +194,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *m.ReqContext) (map[string]interf "version": setting.BuildVersion, "commit": setting.BuildCommit, "buildstamp": setting.BuildStamp, + "edition": hs.License.Edition(), "latestVersion": plugins.GrafanaLatestVersion, "hasUpdate": plugins.GrafanaHasUpdate, "env": setting.Env, @@ -202,6 +203,8 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *m.ReqContext) (map[string]interf "licenseInfo": map[string]interface{}{ "hasLicense": hs.License.HasLicense(), "expiry": hs.License.Expiry(), + "stateInfo": hs.License.StateInfo(), + "licenseUrl": hs.License.LicenseURL(c.SignedInUser), }, "featureToggles": hs.Cfg.FeatureToggles, } diff --git a/pkg/api/index.go b/pkg/api/index.go index 240aa8db782..69c53e17120 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -357,7 +357,7 @@ func (hs *HTTPServer) setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, er Children: []*dtos.NavLink{}, }) - hs.HooksService.RunIndexDataHooks(&data) + hs.HooksService.RunIndexDataHooks(&data, c) sort.SliceStable(data.NavTree, func(i, j int) bool { return data.NavTree[i].SortWeight < data.NavTree[j].SortWeight diff --git a/pkg/models/licensing.go b/pkg/models/licensing.go index 21d62a2546d..a1440de5f6d 100644 --- a/pkg/models/licensing.go +++ b/pkg/models/licensing.go @@ -9,4 +9,11 @@ type Licensing interface { // Expiry returns the unix epoch timestamp when the license expires, or 0 if no valid license is provided Expiry() int64 + + // Return edition + Edition() string + + LicenseURL(user *SignedInUser) string + + StateInfo() string } diff --git a/pkg/services/hooks/hooks.go b/pkg/services/hooks/hooks.go index c51650cf6c9..384ffd3367d 100644 --- a/pkg/services/hooks/hooks.go +++ b/pkg/services/hooks/hooks.go @@ -2,10 +2,11 @@ package hooks import ( "github.com/grafana/grafana/pkg/api/dtos" + "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/registry" ) -type IndexDataHook func(indexData *dtos.IndexViewData) +type IndexDataHook func(indexData *dtos.IndexViewData, req *models.ReqContext) type HooksService struct { indexDataHooks []IndexDataHook @@ -23,8 +24,8 @@ func (srv *HooksService) AddIndexDataHook(hook IndexDataHook) { srv.indexDataHooks = append(srv.indexDataHooks, hook) } -func (srv *HooksService) RunIndexDataHooks(indexData *dtos.IndexViewData) { +func (srv *HooksService) RunIndexDataHooks(indexData *dtos.IndexViewData, req *models.ReqContext) { for _, hook := range srv.indexDataHooks { - hook(indexData) + hook(indexData, req) } } diff --git a/pkg/services/licensing/oss.go b/pkg/services/licensing/oss.go index c60cda6dfd1..d644a192994 100644 --- a/pkg/services/licensing/oss.go +++ b/pkg/services/licensing/oss.go @@ -2,6 +2,7 @@ package licensing import ( "github.com/grafana/grafana/pkg/api/dtos" + "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/services/hooks" "github.com/grafana/grafana/pkg/setting" ) @@ -19,14 +20,30 @@ func (*OSSLicensingService) Expiry() int64 { return 0 } +func (*OSSLicensingService) Edition() string { + return "Open Source" +} + +func (*OSSLicensingService) StateInfo() string { + return "" +} + +func (l *OSSLicensingService) LicenseURL(user *models.SignedInUser) string { + if user.IsGrafanaAdmin { + return l.Cfg.AppSubUrl + "/admin/upgrading" + } + + return "https://grafana.com/products/enterprise/?utm_source=grafana_footer" +} + func (l *OSSLicensingService) Init() error { - l.HooksService.AddIndexDataHook(func(indexData *dtos.IndexViewData) { + l.HooksService.AddIndexDataHook(func(indexData *dtos.IndexViewData, req *models.ReqContext) { for _, node := range indexData.NavTree { if node.Id == "admin" { node.Children = append(node.Children, &dtos.NavLink{ Text: "Upgrade", Id: "upgrading", - Url: l.Cfg.AppSubUrl + "/admin/upgrading", + Url: l.LicenseURL(req.SignedInUser), Icon: "fa fa-fw fa-unlock-alt", }) } diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 370bdb060cc..19181be84e1 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -36,11 +36,10 @@ const ( ) const ( - DEV = "development" - PROD = "production" - TEST = "test" - APP_NAME = "Grafana" - APP_NAME_ENTERPRISE = "Grafana Enterprise" + DEV = "development" + PROD = "production" + TEST = "test" + APP_NAME = "Grafana" ) var ( @@ -619,9 +618,6 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { Raw = cfg.Raw ApplicationName = APP_NAME - if IsEnterprise { - ApplicationName = APP_NAME_ENTERPRISE - } Env, err = valueAsString(iniFile.Section(""), "app_mode", "development") if err != nil { diff --git a/public/app/core/components/Footer/Footer.tsx b/public/app/core/components/Footer/Footer.tsx index 6b706f32f16..1d70febf7f9 100644 --- a/public/app/core/components/Footer/Footer.tsx +++ b/public/app/core/components/Footer/Footer.tsx @@ -5,7 +5,7 @@ export interface FooterLink { text: string; icon?: string; url?: string; - target: string; + target?: string; } export let getFooterLinks = (): FooterLink[] => { @@ -17,7 +17,7 @@ export let getFooterLinks = (): FooterLink[] => { target: '_blank', }, { - text: 'Support & Enterprise', + text: 'Support', icon: 'fa fa-support', url: 'https://grafana.com/products/enterprise/?utm_source=grafana_footer', target: '_blank', @@ -32,15 +32,12 @@ export let getFooterLinks = (): FooterLink[] => { }; export let getVersionLinks = (): FooterLink[] => { - const { buildInfo } = config; + const { buildInfo, licenseInfo } = config; + const links: FooterLink[] = []; + const stateInfo = licenseInfo.stateInfo ? ` (${licenseInfo.stateInfo})` : ''; - const links: FooterLink[] = [ - { - text: `Grafana v${buildInfo.version} (commit: ${buildInfo.commit})`, - url: 'https://grafana.com', - target: '_blank', - }, - ]; + links.push({ text: `${buildInfo.edition}${stateInfo}`, url: licenseInfo.licenseUrl }); + links.push({ text: `v${buildInfo.version} (${buildInfo.commit})` }); if (buildInfo.hasUpdate) { links.push({ diff --git a/public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap b/public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap index 262d8a1c373..730af343513 100644 --- a/public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap +++ b/public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap @@ -180,7 +180,7 @@ exports[`ServerStats Should render table with stats 1`] = ` className="fa fa-support" /> - Support & Enterprise + Support
  • @@ -198,13 +198,22 @@ exports[`ServerStats Should render table with stats 1`] = `
  • - Grafana vv1.0 (commit: 1) + undefined + +
  • +
  • + + + + vv1.0 (1)