mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 04:12:09 +08:00
feat(apps): lots of work making apps easier to develop, module paths are handled automatically
This commit is contained in:
@ -4,6 +4,10 @@ import (
|
||||
"net/url"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/grafana/grafana/pkg/log"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
type FrontendPluginBase struct {
|
||||
@ -23,18 +27,27 @@ func (fp *FrontendPluginBase) initFrontendPlugin() {
|
||||
})
|
||||
}
|
||||
|
||||
fp.handleModuleDefaults()
|
||||
|
||||
fp.Info.Logos.Small = evalRelativePluginUrlPath(fp.Info.Logos.Small, fp.Id)
|
||||
fp.Info.Logos.Large = evalRelativePluginUrlPath(fp.Info.Logos.Large, fp.Id)
|
||||
for i := -0; i < len(fp.Info.Screenshots); i++ {
|
||||
|
||||
for i := 0; i < len(fp.Info.Screenshots); i++ {
|
||||
fp.Info.Screenshots[i].Path = evalRelativePluginUrlPath(fp.Info.Screenshots[i].Path, fp.Id)
|
||||
}
|
||||
fp.handleModuleDefaults()
|
||||
}
|
||||
|
||||
func (fp *FrontendPluginBase) setPathsBasedOnApp(app *AppPlugin) {
|
||||
// log.Info("Module Before: %v", fp.Module)
|
||||
// find out plugins path relative to app static root
|
||||
appSubPath := strings.Replace(fp.PluginDir, app.StaticRootAbs, "", 1)
|
||||
fp.IncludedInAppId = app.Id
|
||||
fp.BaseUrl = app.BaseUrl
|
||||
fp.Module = util.JoinUrlFragments("plugins/"+app.Id, appSubPath) + "/module"
|
||||
log.Info("setting paths based on app: subpath = %v, module: %v", appSubPath, fp.Module)
|
||||
}
|
||||
|
||||
func (fp *FrontendPluginBase) handleModuleDefaults() {
|
||||
if fp.Module != "" {
|
||||
return
|
||||
}
|
||||
|
||||
if fp.StaticRoot != "" {
|
||||
fp.Module = path.Join("plugins", fp.Id, "module")
|
||||
|
Reference in New Issue
Block a user