mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 19:30:36 -06:00
52220b2470
* refactor licenseURL function to use context and export permission evaluation fction * remove provisioning file * refactor licenseURL to take in a bool to avoid circular dependencies * remove function for appending nav link, as it was only used once and move the function to create admin node * better argument names * create a function for permission checking * extend permission checking when displaying server stats * enable the use of enterprise access control actions when evaluating permissions * import ordering * move licensing FGAC action definitions to models package to allow access from oss * move evaluatePermissions for routes to context serve * change permission evaluator to take in more permissions * move licensing FGAC actions again to appease wire * avoid index out of bounds issue in case no children are passed in when creating server admin node * simplify syntax for permission checking Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.com> * update loading state for server stats * linting * more linting * fix test * fix a frontend test * update "licensing.reports:read" action naming * UI doesn't allow reading only licensing reports and not the rest of licensing info Co-authored-by: Alex Khomenko <Clarity-89@users.noreply.github.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(showAdminLicensingPage bool) string {
|
|
if showAdminLicensingPage {
|
|
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.IsGrafanaAdmin),
|
|
Icon: "unlock",
|
|
})
|
|
}
|
|
}
|
|
})
|
|
return l
|
|
}
|