Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
3fabbbff
Unverified
Commit
3fabbbff
authored
Jan 27, 2020
by
Emil Tullstedt
Committed by
GitHub
Jan 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Footer: Display Grafana edition (#21717)
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
parent
84ef0ebb
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
60 additions
and
27 deletions
+60
-27
packages/grafana-runtime/src/config.ts
+3
-0
pkg/api/frontendsettings.go
+3
-0
pkg/api/index.go
+1
-1
pkg/models/licensing.go
+7
-0
pkg/services/hooks/hooks.go
+4
-3
pkg/services/licensing/oss.go
+19
-2
pkg/setting/setting.go
+4
-8
public/app/core/components/Footer/Footer.tsx
+7
-10
public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap
+12
-3
No files found.
packages/grafana-runtime/src/config.ts
View file @
3fabbbff
...
...
@@ -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
{
...
...
pkg/api/frontendsettings.go
View file @
3fabbbff
...
...
@@ -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
,
}
...
...
pkg/api/index.go
View file @
3fabbbff
...
...
@@ -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
...
...
pkg/models/licensing.go
View file @
3fabbbff
...
...
@@ -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
}
pkg/services/hooks/hooks.go
View file @
3fabbbff
...
...
@@ -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
)
}
}
pkg/services/licensing/oss.go
View file @
3fabbbff
...
...
@@ -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"
,
})
}
...
...
pkg/setting/setting.go
View file @
3fabbbff
...
...
@@ -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
{
...
...
public/app/core/components/Footer/Footer.tsx
View file @
3fabbbff
...
...
@@ -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
({
...
...
public/app/features/admin/__snapshots__/ServerStats.test.tsx.snap
View file @
3fabbbff
...
...
@@ -180,7 +180,7 @@ exports[`ServerStats Should render table with stats 1`] = `
className="fa fa-support"
/>
Support
& Enterprise
Support
</a>
</li>
<li>
...
...
@@ -198,13 +198,22 @@ exports[`ServerStats Should render table with stats 1`] = `
</li>
<li>
<a
href="https://grafana.com"
rel="noopener"
target="_blank"
>
<i />
Grafana vv1.0 (commit: 1)
undefined
</a>
</li>
<li>
<a
rel="noopener"
target="_blank"
>
<i />
vv1.0 (1)
</a>
</li>
</ul>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment