mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Pick changes from PR 33811, use UID in dashboard navlinks (#36899)
* pick changes from PR 33811, use UID in dashboard navlinks * use proper spelling for UID * add uid to the plugin schema * Update docs/sources/developers/plugins/plugin.schema.json Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
This commit is contained in:
@@ -62,6 +62,10 @@
|
|||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalItems": false,
|
"additionalItems": false,
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"uid": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Unique identifier of the included resource"
|
||||||
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["dashboard", "page", "panel", "datasource"]
|
"enum": ["dashboard", "page", "panel", "datasource"]
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ func (hs *HTTPServer) getAppLinks(c *models.ReqContext) ([]*dtos.NavLink, error)
|
|||||||
|
|
||||||
if include.Type == "dashboard" && include.AddToNav {
|
if include.Type == "dashboard" && include.AddToNav {
|
||||||
link := &dtos.NavLink{
|
link := &dtos.NavLink{
|
||||||
Url: hs.Cfg.AppSubURL + "/dashboard/db/" + include.Slug,
|
Url: hs.Cfg.AppSubURL + include.GetSlugOrUIDLink(),
|
||||||
Text: include.Name,
|
Text: include.Name,
|
||||||
}
|
}
|
||||||
appLink.Children = append(appLink.Children, link)
|
appLink.Children = append(appLink.Children, link)
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ func (app *AppPlugin) InitApp(panels map[string]*PanelPlugin, dataSources map[st
|
|||||||
app.DefaultNavUrl = cfg.AppSubURL + "/plugins/" + app.Id + "/page/" + include.Slug
|
app.DefaultNavUrl = cfg.AppSubURL + "/plugins/" + app.Id + "/page/" + include.Slug
|
||||||
}
|
}
|
||||||
if include.Type == "dashboard" && include.DefaultNav {
|
if include.Type == "dashboard" && include.DefaultNav {
|
||||||
app.DefaultNavUrl = cfg.AppSubURL + "/dashboard/db/" + include.Slug
|
app.DefaultNavUrl = cfg.AppSubURL + include.GetSlugOrUIDLink()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,10 +95,19 @@ type PluginInclude struct {
|
|||||||
DefaultNav bool `json:"defaultNav"`
|
DefaultNav bool `json:"defaultNav"`
|
||||||
Slug string `json:"slug"`
|
Slug string `json:"slug"`
|
||||||
Icon string `json:"icon"`
|
Icon string `json:"icon"`
|
||||||
|
UID string `json:"uid"`
|
||||||
|
|
||||||
Id string `json:"-"`
|
Id string `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e PluginInclude) GetSlugOrUIDLink() string {
|
||||||
|
if len(e.UID) > 0 {
|
||||||
|
return "/d/" + e.UID
|
||||||
|
} else {
|
||||||
|
return "/dashboard/db/" + e.Slug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type PluginDependencyItem struct {
|
type PluginDependencyItem struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
|
|||||||
Reference in New Issue
Block a user