mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Whitelabelling: Override version in UI from config (#84392)
* Unify how the version is shown in the UI * use versionString in dashboard help bundles * fix lint * remove comment * fix test types * make test less flakey
This commit is contained in:
@@ -127,6 +127,14 @@ func Sort(nodes []*NavLink) {
|
||||
}
|
||||
}
|
||||
|
||||
func (root *NavTreeRoot) ApplyHelpVersion(version string) {
|
||||
helpNode := root.FindById("help")
|
||||
|
||||
if helpNode != nil {
|
||||
helpNode.SubTitle = version
|
||||
}
|
||||
}
|
||||
|
||||
func (root *NavTreeRoot) ApplyAdminIA() {
|
||||
orgAdminNode := root.FindById(NavIDCfg)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package navtreeimpl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/dtos"
|
||||
@@ -188,25 +187,11 @@ func isSupportBundlesEnabled(s *ServiceImpl) bool {
|
||||
return s.cfg.SectionWithEnvOverrides("support_bundles").Key("enabled").MustBool(true)
|
||||
}
|
||||
|
||||
// don't need to show the full commit hash in the UI
|
||||
// let's substring to 10 chars like local git does automatically
|
||||
func getShortCommitHash(commitHash string, maxLength int) string {
|
||||
if len(commitHash) > maxLength {
|
||||
return commitHash[:maxLength]
|
||||
}
|
||||
return commitHash
|
||||
}
|
||||
|
||||
func (s *ServiceImpl) addHelpLinks(treeRoot *navtree.NavTreeRoot, c *contextmodel.ReqContext) {
|
||||
if s.cfg.HelpEnabled {
|
||||
helpVersion := fmt.Sprintf(`%s v%s (%s)`, setting.ApplicationName, setting.BuildVersion, getShortCommitHash(setting.BuildCommit, 10))
|
||||
if s.cfg.AnonymousHideVersion && !c.IsSignedIn {
|
||||
helpVersion = setting.ApplicationName
|
||||
}
|
||||
|
||||
// The version subtitle is set later by NavTree.ApplyHelpVersion
|
||||
helpNode := &navtree.NavLink{
|
||||
Text: "Help",
|
||||
SubTitle: helpVersion,
|
||||
Id: "help",
|
||||
Url: "#",
|
||||
Icon: "question-circle",
|
||||
|
||||
Reference in New Issue
Block a user