mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 17:43:35 -06:00
* NewIA: Plugin nav config * progress * Progress * Things are working * Add monitoring node * Add alerts and incidents * added experiment with standalone page * Refactoring by adding a type for navtree root * First test working * More tests * more tests * Progress on richer config and sorting * Sort weight working * Path config * Improving logic for not including admin or cfg nodes, making it the last step so that enterprise can add admin nodes without having to worry about the section not existing * fixed index routes * removed file * Fixes * Fixing tests * Fixing more tests and adding support for weight config * Updates * Remove unused fake * More fixes * Minor tweak * Minor fix * Can now control position using sortweight even when existing items have no sortweight * Added tests for frontend standalone page logic * more tests * Remove unused fake and fixed lint issue * Moving reading settings to navtree impl package * remove nav_id setting prefix * Remove old test file * Fix trailing newline * Fixed bug with adding nil node * fixing lint issue * remove some code we have to rethink * move read settings to PrivideService and switch to util.SplitString
70 lines
1.6 KiB
Go
70 lines
1.6 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/services/navtree"
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
const (
|
|
openSource = "Open Source"
|
|
)
|
|
|
|
type OSSLicensingService struct {
|
|
Cfg *setting.Cfg
|
|
HooksService *hooks.HooksService
|
|
}
|
|
|
|
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) EnabledFeatures() map[string]bool {
|
|
return map[string]bool{}
|
|
}
|
|
|
|
func (*OSSLicensingService) FeatureEnabled(feature string) 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) {
|
|
if adminNode := indexData.NavTree.FindById(navtree.NavIDAdmin); adminNode != nil {
|
|
adminNode.Children = append(adminNode.Children, &navtree.NavLink{
|
|
Text: "Stats and license",
|
|
Id: "upgrading",
|
|
Url: l.LicenseURL(req.IsGrafanaAdmin),
|
|
Icon: "unlock",
|
|
})
|
|
}
|
|
})
|
|
|
|
return l
|
|
}
|