mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 16:32:15 +08:00
remove grafana specific config from package (#44866)
This commit is contained in:
@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ func (hs *HTTPServer) getAppLinks(c *models.ReqContext) ([]*dtos.NavLink, error)
|
|||||||
appLink := &dtos.NavLink{
|
appLink := &dtos.NavLink{
|
||||||
Text: plugin.Name,
|
Text: plugin.Name,
|
||||||
Id: "plugin-page-" + plugin.ID,
|
Id: "plugin-page-" + plugin.ID,
|
||||||
Url: plugin.DefaultNavURL,
|
Url: path.Join(hs.Cfg.AppSubURL, plugin.DefaultNavURL),
|
||||||
Img: plugin.Info.Logos.Small,
|
Img: plugin.Info.Logos.Small,
|
||||||
SortWeight: dtos.WeightPlugin,
|
SortWeight: dtos.WeightPlugin,
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@ -73,7 +74,7 @@ func (hs *HTTPServer) GetPluginList(c *models.ReqContext) response.Response {
|
|||||||
Category: pluginDef.Category,
|
Category: pluginDef.Category,
|
||||||
Info: pluginDef.Info,
|
Info: pluginDef.Info,
|
||||||
Dependencies: pluginDef.Dependencies,
|
Dependencies: pluginDef.Dependencies,
|
||||||
DefaultNavUrl: pluginDef.DefaultNavURL,
|
DefaultNavUrl: path.Join(hs.Cfg.AppSubURL, pluginDef.DefaultNavURL),
|
||||||
State: pluginDef.State,
|
State: pluginDef.State,
|
||||||
Signature: pluginDef.Signature,
|
Signature: pluginDef.Signature,
|
||||||
SignatureType: pluginDef.SignatureType,
|
SignatureType: pluginDef.SignatureType,
|
||||||
@ -129,7 +130,7 @@ func (hs *HTTPServer) GetPluginSettingByID(c *models.ReqContext) response.Respon
|
|||||||
Includes: plugin.Includes,
|
Includes: plugin.Includes,
|
||||||
BaseUrl: plugin.BaseURL,
|
BaseUrl: plugin.BaseURL,
|
||||||
Module: plugin.Module,
|
Module: plugin.Module,
|
||||||
DefaultNavUrl: plugin.DefaultNavURL,
|
DefaultNavUrl: path.Join(hs.Cfg.AppSubURL, plugin.DefaultNavURL),
|
||||||
State: plugin.State,
|
State: plugin.State,
|
||||||
Signature: plugin.Signature,
|
Signature: plugin.Signature,
|
||||||
SignatureType: plugin.SignatureType,
|
SignatureType: plugin.SignatureType,
|
||||||
|
@ -24,7 +24,6 @@ type Cfg struct {
|
|||||||
CheckForUpdates bool
|
CheckForUpdates bool
|
||||||
|
|
||||||
BuildVersion string // TODO Remove
|
BuildVersion string // TODO Remove
|
||||||
AppSubURL string // TODO Remove
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCfg() *Cfg {
|
func NewCfg() *Cfg {
|
||||||
@ -51,7 +50,6 @@ func FromGrafanaCfg(grafanaCfg *setting.Cfg) *Cfg {
|
|||||||
cfg.CheckForUpdates = grafanaCfg.CheckForUpdates
|
cfg.CheckForUpdates = grafanaCfg.CheckForUpdates
|
||||||
|
|
||||||
cfg.BuildVersion = grafanaCfg.BuildVersion
|
cfg.BuildVersion = grafanaCfg.BuildVersion
|
||||||
cfg.AppSubURL = grafanaCfg.AppSubURL
|
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ func (l *Loader) loadPlugins(ctx context.Context, class plugins.Class, pluginJSO
|
|||||||
}
|
}
|
||||||
|
|
||||||
if plugin.IsApp() {
|
if plugin.IsApp() {
|
||||||
setDefaultNavURL(plugin, l.cfg.AppSubURL)
|
setDefaultNavURL(plugin)
|
||||||
}
|
}
|
||||||
|
|
||||||
if plugin.Parent != nil && plugin.Parent.IsApp() {
|
if plugin.Parent != nil && plugin.Parent.IsApp() {
|
||||||
@ -255,17 +255,22 @@ func setImages(p *plugins.Plugin) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDefaultNavURL(p *plugins.Plugin, appSubURL string) {
|
func setDefaultNavURL(p *plugins.Plugin) {
|
||||||
// slugify pages
|
// slugify pages
|
||||||
for _, include := range p.Includes {
|
for _, include := range p.Includes {
|
||||||
if include.Slug == "" {
|
if include.Slug == "" {
|
||||||
include.Slug = slug.Make(include.Name)
|
include.Slug = slug.Make(include.Name)
|
||||||
}
|
}
|
||||||
if include.Type == "page" && include.DefaultNav {
|
|
||||||
p.DefaultNavURL = appSubURL + "/plugins/" + p.ID + "/page/" + include.Slug
|
if !include.DefaultNav {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
if include.Type == "dashboard" && include.DefaultNav {
|
|
||||||
p.DefaultNavURL = appSubURL + "/dashboard/db/" + include.Slug
|
if include.Type == "page" {
|
||||||
|
p.DefaultNavURL = path.Join("/plugins/", p.ID, "/page/", include.Slug)
|
||||||
|
}
|
||||||
|
if include.Type == "dashboard" {
|
||||||
|
p.DefaultNavURL = path.Join("/dashboard/db/", include.Slug)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ func (p PluginDTO) SupportsStreaming() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p PluginDTO) IsApp() bool {
|
func (p PluginDTO) IsApp() bool {
|
||||||
return p.Type == "app"
|
return p.Type == App
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p PluginDTO) IsCorePlugin() bool {
|
func (p PluginDTO) IsCorePlugin() bool {
|
||||||
|
Reference in New Issue
Block a user