mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fixes #30144 Co-authored-by: dsotirakis <sotirakis.dim@gmail.com> Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Co-authored-by: Ida Furjesova <ida.furjesova@grafana.com> Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com> Co-authored-by: Will Browne <wbrowne@users.noreply.github.com> Co-authored-by: Leon Sorokin <leeoniya@gmail.com> Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com> Co-authored-by: spinillos <selenepinillos@gmail.com> Co-authored-by: Karl Persson <kalle.persson@grafana.com> Co-authored-by: Leonard Gram <leo@xlson.com>
70 lines
1.5 KiB
Go
70 lines
1.5 KiB
Go
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"
|
|
)
|
|
|
|
const (
|
|
openSource = "Open Source"
|
|
)
|
|
|
|
type OSSLicensingService struct {
|
|
Cfg *setting.Cfg
|
|
HooksService *hooks.HooksService
|
|
}
|
|
|
|
func (*OSSLicensingService) HasLicense() bool {
|
|
return false
|
|
}
|
|
|
|
func (*OSSLicensingService) Expiry() int64 {
|
|
return 0
|
|
}
|
|
|
|
func (*OSSLicensingService) Edition() string {
|
|
return openSource
|
|
}
|
|
|
|
func (*OSSLicensingService) StateInfo() string {
|
|
return ""
|
|
}
|
|
|
|
func (*OSSLicensingService) ContentDeliveryPrefix() string {
|
|
return "grafana-oss"
|
|
}
|
|
|
|
func (l *OSSLicensingService) LicenseURL(user *models.SignedInUser) string {
|
|
if user.IsGrafanaAdmin {
|
|
return l.Cfg.AppSubURL + "/admin/upgrading"
|
|
}
|
|
|
|
return "https://grafana.com/oss/grafana?utm_source=grafana_footer"
|
|
}
|
|
|
|
func (*OSSLicensingService) HasValidLicense() bool {
|
|
return false
|
|
}
|
|
|
|
func ProvideService(cfg *setting.Cfg, hooksService *hooks.HooksService) *OSSLicensingService {
|
|
l := &OSSLicensingService{
|
|
Cfg: cfg,
|
|
HooksService: hooksService,
|
|
}
|
|
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: "Stats and license",
|
|
Id: "upgrading",
|
|
Url: l.LicenseURL(req.SignedInUser),
|
|
Icon: "unlock",
|
|
})
|
|
}
|
|
}
|
|
})
|
|
return l
|
|
}
|