[v10.2.x] Plugins: Don't auto prepend app sub url to plugin asset paths (#82146)
Plugins: Don't auto prepend app sub url to plugin asset paths (#81658)
* don't prepend app sub url to paths
* simplify logo path
* fix(plugins): dynamically prepend appSubUrl for System module resolving to work
* fix(sandbox): support dynamic appSuburl prepend when loading plugin module.js
* fix tests
* update test name
* fix tests
* update fe + add some tests
* refactor(plugins): move wrangleurl to utils, rename to resolveModulePath, update usage
* chore: fix a typo
* test(plugins): add missing name to utils test
* reset test flag
---------
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
(cherry picked from commit 99feb928cf)
Co-authored-by: Will Browne <wbrowne@users.noreply.github.com>
This commit is contained in:
co-authored by
Will Browne
parent
147e7b0613
commit
dfb6c28197
@@ -32,7 +32,7 @@ func DefaultDecorateFuncs(cfg *config.Cfg) []DecorateFunc {
|
||||
return []DecorateFunc{
|
||||
AppDefaultNavURLDecorateFunc,
|
||||
TemplateDecorateFunc,
|
||||
AppChildDecorateFunc(cfg),
|
||||
AppChildDecorateFunc(),
|
||||
SkipHostEnvVarsDecorateFunc(cfg),
|
||||
}
|
||||
}
|
||||
@@ -132,27 +132,28 @@ func setDefaultNavURL(p *plugins.Plugin) {
|
||||
}
|
||||
|
||||
// AppChildDecorateFunc is a DecorateFunc that configures child plugins of app plugins.
|
||||
func AppChildDecorateFunc(cfg *config.Cfg) DecorateFunc {
|
||||
func AppChildDecorateFunc() DecorateFunc {
|
||||
return func(_ context.Context, p *plugins.Plugin) (*plugins.Plugin, error) {
|
||||
if p.Parent != nil && p.Parent.IsApp() {
|
||||
configureAppChildPlugin(cfg, p.Parent, p)
|
||||
configureAppChildPlugin(p.Parent, p)
|
||||
}
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
|
||||
func configureAppChildPlugin(cfg *config.Cfg, parent *plugins.Plugin, child *plugins.Plugin) {
|
||||
func configureAppChildPlugin(parent *plugins.Plugin, child *plugins.Plugin) {
|
||||
if !parent.IsApp() {
|
||||
return
|
||||
}
|
||||
child.IncludedInAppID = parent.ID
|
||||
child.BaseURL = parent.BaseURL
|
||||
|
||||
// TODO move this logic within assetpath package
|
||||
appSubPath := strings.ReplaceAll(strings.Replace(child.FS.Base(), parent.FS.Base(), "", 1), "\\", "/")
|
||||
if parent.IsCorePlugin() {
|
||||
child.Module = path.Join("core:plugin", parent.ID, appSubPath)
|
||||
} else {
|
||||
child.Module = path.Join("/", cfg.GrafanaAppSubURL, "/public/plugins", parent.ID, appSubPath, "module.js")
|
||||
child.Module = path.Join("public/plugins", parent.ID, appSubPath, "module.js")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user