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:
@@ -152,11 +152,15 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
hideVersion := hs.Cfg.AnonymousHideVersion && !c.IsSignedIn
|
||||
version := setting.BuildVersion
|
||||
commit := setting.BuildCommit
|
||||
commitShort := getShortCommitHash(setting.BuildCommit, 10)
|
||||
buildstamp := setting.BuildStamp
|
||||
versionString := fmt.Sprintf(`%s v%s (%s)`, setting.ApplicationName, version, commitShort)
|
||||
|
||||
if hideVersion {
|
||||
version = ""
|
||||
versionString = setting.ApplicationName
|
||||
commit = ""
|
||||
commitShort = ""
|
||||
buildstamp = 0
|
||||
}
|
||||
|
||||
@@ -226,7 +230,9 @@ func (hs *HTTPServer) getFrontendSettings(c *contextmodel.ReqContext) (*dtos.Fro
|
||||
BuildInfo: dtos.FrontendSettingsBuildInfoDTO{
|
||||
HideVersion: hideVersion,
|
||||
Version: version,
|
||||
VersionString: versionString,
|
||||
Commit: commit,
|
||||
CommitShort: commitShort,
|
||||
Buildstamp: buildstamp,
|
||||
Edition: hs.License.Edition(),
|
||||
LatestVersion: hs.grafanaUpdateChecker.LatestVersion(),
|
||||
@@ -367,6 +373,13 @@ func isSupportBundlesEnabled(hs *HTTPServer) bool {
|
||||
return hs.Cfg.SectionWithEnvOverrides("support_bundles").Key("enabled").MustBool(true)
|
||||
}
|
||||
|
||||
func getShortCommitHash(commitHash string, maxLength int) string {
|
||||
if len(commitHash) > maxLength {
|
||||
return commitHash[:maxLength]
|
||||
}
|
||||
return commitHash
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) getFSDataSources(c *contextmodel.ReqContext, availablePlugins AvailablePlugins) (map[string]plugins.DataSourceDTO, error) {
|
||||
orgDataSources := make([]*datasources.DataSource, 0)
|
||||
if c.SignedInUser.GetOrgID() != 0 {
|
||||
|
||||
Reference in New Issue
Block a user