Admin: Add promotional page for Grafana Enterprise (#21422)

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
Emil Tullstedt
2020-01-15 14:50:44 +01:00
committed by GitHub
co-authored by Torkel Ödegaard
parent 32f055111c
commit 29687903f8
16 changed files with 493 additions and 27 deletions
+6 -5
View File
@@ -4,6 +4,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"github.com/grafana/grafana/pkg/services/licensing"
"io/ioutil"
"net/http"
"net/http/httptest"
@@ -83,7 +84,7 @@ func TestLoginErrorCookieApiEndpoint(t *testing.T) {
sc := setupScenarioContext("/login")
hs := &HTTPServer{
Cfg: setting.NewCfg(),
License: models.OSSLicensingService{},
License: &licensing.OSSLicensingService{},
}
sc.defaultHandler = Wrap(func(w http.ResponseWriter, c *models.ReqContext) {
@@ -133,7 +134,7 @@ func TestLoginViewRedirect(t *testing.T) {
sc := setupScenarioContext("/login")
hs := &HTTPServer{
Cfg: setting.NewCfg(),
License: models.OSSLicensingService{},
License: &licensing.OSSLicensingService{},
}
hs.Cfg.CookieSecure = true
@@ -247,7 +248,7 @@ func TestLoginPostRedirect(t *testing.T) {
hs := &HTTPServer{
log: &FakeLogger{},
Cfg: setting.NewCfg(),
License: models.OSSLicensingService{},
License: &licensing.OSSLicensingService{},
AuthTokenService: auth.NewFakeUserAuthTokenService(),
}
hs.Cfg.CookieSecure = true
@@ -350,7 +351,7 @@ func TestLoginOAuthRedirect(t *testing.T) {
sc := setupScenarioContext("/login")
hs := &HTTPServer{
Cfg: setting.NewCfg(),
License: models.OSSLicensingService{},
License: &licensing.OSSLicensingService{},
}
sc.defaultHandler = Wrap(func(c *models.ReqContext) {
@@ -408,7 +409,7 @@ func setupAuthProxyLoginTest(enableLoginToken bool) *scenarioContext {
sc := setupScenarioContext("/login")
hs := &HTTPServer{
Cfg: setting.NewCfg(),
License: models.OSSLicensingService{},
License: &licensing.OSSLicensingService{},
AuthTokenService: auth.NewFakeUserAuthTokenService(),
log: log.New("hello"),
}
+2 -2
View File
@@ -6,8 +6,8 @@ import (
_ "github.com/crewjam/saml"
_ "github.com/gobwas/glob"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/registry"
"github.com/grafana/grafana/pkg/services/licensing"
_ "github.com/jung-kurt/gofpdf"
_ "github.com/linkedin/goavro/v2"
_ "github.com/pkg/errors"
@@ -18,7 +18,7 @@ import (
)
func init() {
registry.RegisterService(&models.OSSLicensingService{})
registry.RegisterService(&licensing.OSSLicensingService{})
}
var IsEnterprise bool = false
+2 -1
View File
@@ -2,6 +2,7 @@ package usagestats
import (
"bytes"
"github.com/grafana/grafana/pkg/services/licensing"
"io/ioutil"
"runtime"
"sync"
@@ -25,7 +26,7 @@ func TestMetrics(t *testing.T) {
uss := &UsageStatsService{
Bus: bus.New(),
SQLStore: sqlstore.InitTestDB(t),
License: models.OSSLicensingService{},
License: &licensing.OSSLicensingService{},
}
var getSystemStatsQuery *models.GetSystemStatsQuery
-18
View File
@@ -10,21 +10,3 @@ type Licensing interface {
// Expiry returns the unix epoch timestamp when the license expires, or 0 if no valid license is provided
Expiry() int64
}
type OSSLicensingService struct{}
func (OSSLicensingService) HasLicense() bool {
return false
}
func (OSSLicensingService) Expiry() int64 {
return 0
}
func (OSSLicensingService) Init() error {
return nil
}
func (OSSLicensingService) HasValidLicense() bool {
return false
}
+41
View File
@@ -0,0 +1,41 @@
package licensing
import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/services/hooks"
"github.com/grafana/grafana/pkg/setting"
)
type OSSLicensingService struct {
Cfg *setting.Cfg `inject:""`
HooksService *hooks.HooksService `inject:""`
}
func (*OSSLicensingService) HasLicense() bool {
return false
}
func (*OSSLicensingService) Expiry() int64 {
return 0
}
func (l *OSSLicensingService) Init() error {
l.HooksService.AddIndexDataHook(func(indexData *dtos.IndexViewData) {
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",
Icon: "fa fa-fw fa-unlock-alt",
})
}
}
})
return nil
}
func (*OSSLicensingService) HasValidLicense() bool {
return false
}