mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Footer: Display Grafana edition (#21717)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
parent
84ef0ebb17
commit
3fabbbff4d
@ -7,6 +7,7 @@ export interface BuildInfo {
|
|||||||
commit: string;
|
commit: string;
|
||||||
isEnterprise: boolean; // deprecated: use licenseInfo.hasLicense instead
|
isEnterprise: boolean; // deprecated: use licenseInfo.hasLicense instead
|
||||||
env: string;
|
env: string;
|
||||||
|
edition: string;
|
||||||
latestVersion: string;
|
latestVersion: string;
|
||||||
hasUpdate: boolean;
|
hasUpdate: boolean;
|
||||||
}
|
}
|
||||||
@ -21,6 +22,8 @@ interface FeatureToggles {
|
|||||||
interface LicenseInfo {
|
interface LicenseInfo {
|
||||||
hasLicense: boolean;
|
hasLicense: boolean;
|
||||||
expiry: number;
|
expiry: number;
|
||||||
|
licenseUrl: string;
|
||||||
|
stateInfo: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GrafanaBootConfig {
|
export class GrafanaBootConfig {
|
||||||
|
@ -194,6 +194,7 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *m.ReqContext) (map[string]interf
|
|||||||
"version": setting.BuildVersion,
|
"version": setting.BuildVersion,
|
||||||
"commit": setting.BuildCommit,
|
"commit": setting.BuildCommit,
|
||||||
"buildstamp": setting.BuildStamp,
|
"buildstamp": setting.BuildStamp,
|
||||||
|
"edition": hs.License.Edition(),
|
||||||
"latestVersion": plugins.GrafanaLatestVersion,
|
"latestVersion": plugins.GrafanaLatestVersion,
|
||||||
"hasUpdate": plugins.GrafanaHasUpdate,
|
"hasUpdate": plugins.GrafanaHasUpdate,
|
||||||
"env": setting.Env,
|
"env": setting.Env,
|
||||||
@ -202,6 +203,8 @@ func (hs *HTTPServer) getFrontendSettingsMap(c *m.ReqContext) (map[string]interf
|
|||||||
"licenseInfo": map[string]interface{}{
|
"licenseInfo": map[string]interface{}{
|
||||||
"hasLicense": hs.License.HasLicense(),
|
"hasLicense": hs.License.HasLicense(),
|
||||||
"expiry": hs.License.Expiry(),
|
"expiry": hs.License.Expiry(),
|
||||||
|
"stateInfo": hs.License.StateInfo(),
|
||||||
|
"licenseUrl": hs.License.LicenseURL(c.SignedInUser),
|
||||||
},
|
},
|
||||||
"featureToggles": hs.Cfg.FeatureToggles,
|
"featureToggles": hs.Cfg.FeatureToggles,
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ func (hs *HTTPServer) setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, er
|
|||||||
Children: []*dtos.NavLink{},
|
Children: []*dtos.NavLink{},
|
||||||
})
|
})
|
||||||
|
|
||||||
hs.HooksService.RunIndexDataHooks(&data)
|
hs.HooksService.RunIndexDataHooks(&data, c)
|
||||||
|
|
||||||
sort.SliceStable(data.NavTree, func(i, j int) bool {
|
sort.SliceStable(data.NavTree, func(i, j int) bool {
|
||||||
return data.NavTree[i].SortWeight < data.NavTree[j].SortWeight
|
return data.NavTree[i].SortWeight < data.NavTree[j].SortWeight
|
||||||
|
@ -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 returns the unix epoch timestamp when the license expires, or 0 if no valid license is provided
|
||||||
Expiry() int64
|
Expiry() int64
|
||||||
|
|
||||||
|
// Return edition
|
||||||
|
Edition() string
|
||||||
|
|
||||||
|
LicenseURL(user *SignedInUser) string
|
||||||
|
|
||||||
|
StateInfo() string
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,11 @@ package hooks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/grafana/grafana/pkg/api/dtos"
|
"github.com/grafana/grafana/pkg/api/dtos"
|
||||||
|
"github.com/grafana/grafana/pkg/models"
|
||||||
"github.com/grafana/grafana/pkg/registry"
|
"github.com/grafana/grafana/pkg/registry"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IndexDataHook func(indexData *dtos.IndexViewData)
|
type IndexDataHook func(indexData *dtos.IndexViewData, req *models.ReqContext)
|
||||||
|
|
||||||
type HooksService struct {
|
type HooksService struct {
|
||||||
indexDataHooks []IndexDataHook
|
indexDataHooks []IndexDataHook
|
||||||
@ -23,8 +24,8 @@ func (srv *HooksService) AddIndexDataHook(hook IndexDataHook) {
|
|||||||
srv.indexDataHooks = append(srv.indexDataHooks, hook)
|
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 {
|
for _, hook := range srv.indexDataHooks {
|
||||||
hook(indexData)
|
hook(indexData, req)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package licensing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/grafana/grafana/pkg/api/dtos"
|
"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/services/hooks"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
)
|
)
|
||||||
@ -19,14 +20,30 @@ func (*OSSLicensingService) Expiry() int64 {
|
|||||||
return 0
|
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 {
|
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 {
|
for _, node := range indexData.NavTree {
|
||||||
if node.Id == "admin" {
|
if node.Id == "admin" {
|
||||||
node.Children = append(node.Children, &dtos.NavLink{
|
node.Children = append(node.Children, &dtos.NavLink{
|
||||||
Text: "Upgrade",
|
Text: "Upgrade",
|
||||||
Id: "upgrading",
|
Id: "upgrading",
|
||||||
Url: l.Cfg.AppSubUrl + "/admin/upgrading",
|
Url: l.LicenseURL(req.SignedInUser),
|
||||||
Icon: "fa fa-fw fa-unlock-alt",
|
Icon: "fa fa-fw fa-unlock-alt",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,10 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DEV = "development"
|
DEV = "development"
|
||||||
PROD = "production"
|
PROD = "production"
|
||||||
TEST = "test"
|
TEST = "test"
|
||||||
APP_NAME = "Grafana"
|
APP_NAME = "Grafana"
|
||||||
APP_NAME_ENTERPRISE = "Grafana Enterprise"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -619,9 +618,6 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
|||||||
Raw = cfg.Raw
|
Raw = cfg.Raw
|
||||||
|
|
||||||
ApplicationName = APP_NAME
|
ApplicationName = APP_NAME
|
||||||
if IsEnterprise {
|
|
||||||
ApplicationName = APP_NAME_ENTERPRISE
|
|
||||||
}
|
|
||||||
|
|
||||||
Env, err = valueAsString(iniFile.Section(""), "app_mode", "development")
|
Env, err = valueAsString(iniFile.Section(""), "app_mode", "development")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -5,7 +5,7 @@ export interface FooterLink {
|
|||||||
text: string;
|
text: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
target: string;
|
target?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export let getFooterLinks = (): FooterLink[] => {
|
export let getFooterLinks = (): FooterLink[] => {
|
||||||
@ -17,7 +17,7 @@ export let getFooterLinks = (): FooterLink[] => {
|
|||||||
target: '_blank',
|
target: '_blank',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: 'Support & Enterprise',
|
text: 'Support',
|
||||||
icon: 'fa fa-support',
|
icon: 'fa fa-support',
|
||||||
url: 'https://grafana.com/products/enterprise/?utm_source=grafana_footer',
|
url: 'https://grafana.com/products/enterprise/?utm_source=grafana_footer',
|
||||||
target: '_blank',
|
target: '_blank',
|
||||||
@ -32,15 +32,12 @@ export let getFooterLinks = (): FooterLink[] => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export let getVersionLinks = (): FooterLink[] => {
|
export let getVersionLinks = (): FooterLink[] => {
|
||||||
const { buildInfo } = config;
|
const { buildInfo, licenseInfo } = config;
|
||||||
|
const links: FooterLink[] = [];
|
||||||
|
const stateInfo = licenseInfo.stateInfo ? ` (${licenseInfo.stateInfo})` : '';
|
||||||
|
|
||||||
const links: FooterLink[] = [
|
links.push({ text: `${buildInfo.edition}${stateInfo}`, url: licenseInfo.licenseUrl });
|
||||||
{
|
links.push({ text: `v${buildInfo.version} (${buildInfo.commit})` });
|
||||||
text: `Grafana v${buildInfo.version} (commit: ${buildInfo.commit})`,
|
|
||||||
url: 'https://grafana.com',
|
|
||||||
target: '_blank',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
if (buildInfo.hasUpdate) {
|
if (buildInfo.hasUpdate) {
|
||||||
links.push({
|
links.push({
|
||||||
|
@ -180,7 +180,7 @@ exports[`ServerStats Should render table with stats 1`] = `
|
|||||||
className="fa fa-support"
|
className="fa fa-support"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
Support & Enterprise
|
Support
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
@ -198,13 +198,22 @@ exports[`ServerStats Should render table with stats 1`] = `
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
href="https://grafana.com"
|
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
<i />
|
<i />
|
||||||
|
|
||||||
Grafana vv1.0 (commit: 1)
|
undefined
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
rel="noopener"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
|
<i />
|
||||||
|
|
||||||
|
vv1.0 (1)
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user