mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #4361 from bergquist/remove_staticRoot
plugin.json: remove staticRoot field
This commit is contained in:
commit
0b3ccaff27
@ -3,9 +3,9 @@ package plugins
|
|||||||
import (
|
import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,10 +14,9 @@ type FrontendPluginBase struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fp *FrontendPluginBase) initFrontendPlugin() {
|
func (fp *FrontendPluginBase) initFrontendPlugin() {
|
||||||
if fp.StaticRoot != "" {
|
if isInternalPlugin(fp.PluginDir) {
|
||||||
fp.StaticRootAbs = filepath.Join(fp.PluginDir, fp.StaticRoot)
|
|
||||||
StaticRoutes = append(StaticRoutes, &PluginStaticRoute{
|
StaticRoutes = append(StaticRoutes, &PluginStaticRoute{
|
||||||
Directory: fp.StaticRootAbs,
|
Directory: fp.PluginDir,
|
||||||
PluginId: fp.Id,
|
PluginId: fp.Id,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -41,7 +40,7 @@ func getPluginLogoUrl(path, baseUrl string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) {
|
func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) {
|
||||||
appSubPath := strings.Replace(fp.PluginDir, app.StaticRootAbs, "", 1)
|
appSubPath := strings.Replace(fp.PluginDir, app.PluginDir, "", 1)
|
||||||
fp.IncludedInAppId = app.Id
|
fp.IncludedInAppId = app.Id
|
||||||
fp.BaseUrl = app.BaseUrl
|
fp.BaseUrl = app.BaseUrl
|
||||||
fp.Module = util.JoinUrlFragments("plugins/"+app.Id, appSubPath) + "/module"
|
fp.Module = util.JoinUrlFragments("plugins/"+app.Id, appSubPath) + "/module"
|
||||||
@ -49,7 +48,7 @@ func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) {
|
|||||||
|
|
||||||
func (fp *FrontendPluginBase) handleModuleDefaults() {
|
func (fp *FrontendPluginBase) handleModuleDefaults() {
|
||||||
|
|
||||||
if fp.StaticRoot != "" {
|
if isInternalPlugin(fp.PluginDir) {
|
||||||
fp.Module = path.Join("plugins", fp.Id, "module")
|
fp.Module = path.Join("plugins", fp.Id, "module")
|
||||||
fp.BaseUrl = path.Join("public/plugins", fp.Id)
|
fp.BaseUrl = path.Join("public/plugins", fp.Id)
|
||||||
return
|
return
|
||||||
@ -59,6 +58,10 @@ func (fp *FrontendPluginBase) handleModuleDefaults() {
|
|||||||
fp.BaseUrl = path.Join("public/app/plugins", fp.Type, fp.Id)
|
fp.BaseUrl = path.Join("public/app/plugins", fp.Type, fp.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isInternalPlugin(pluginDir string) bool {
|
||||||
|
return !strings.Contains(pluginDir, setting.StaticRootPath)
|
||||||
|
}
|
||||||
|
|
||||||
func evalRelativePluginUrlPath(pathStr string, baseUrl string) string {
|
func evalRelativePluginUrlPath(pathStr string, baseUrl string) string {
|
||||||
if pathStr == "" {
|
if pathStr == "" {
|
||||||
return ""
|
return ""
|
||||||
|
@ -38,8 +38,6 @@ type PluginBase struct {
|
|||||||
Includes []*PluginInclude `json:"includes"`
|
Includes []*PluginInclude `json:"includes"`
|
||||||
Module string `json:"module"`
|
Module string `json:"module"`
|
||||||
BaseUrl string `json:"baseUrl"`
|
BaseUrl string `json:"baseUrl"`
|
||||||
StaticRoot string `json:"staticRoot"`
|
|
||||||
StaticRootAbs string `json:"-"`
|
|
||||||
|
|
||||||
IncludedInAppId string `json:"-"`
|
IncludedInAppId string `json:"-"`
|
||||||
PluginDir string `json:"-"`
|
PluginDir string `json:"-"`
|
||||||
|
Loading…
Reference in New Issue
Block a user