Plugins: Introduce LoadingStrategy for frontend loading logic (#92392)

* do it all

* feat(plugins): move loadingStrategy to ds pluginMeta and add to plugin settings endpoint

* support child plugins and update tests

* use relative path for nested plugins

* feat(plugins): support nested plugins in the plugin loader cache by extracting pluginId from path

* feat(grafana-data): add plugin loading strategy to plugin meta and export

* feat(plugins): pass down loadingStrategy to fe plugin loader

* refactor(plugins): make PluginLoadingStrategy an enum

* feat(plugins): add the loading strategy to the fe plugin loader cache

* feat(plugins): load fe plugin js assets as script tags based on be loadingStrategy

* add more tests

* feat(plugins): add loading strategy to plugin preloader

* feat(plugins): make loadingStrategy a maybe and provide fetch fallback

* test(alerting): update config.apps mocks to include loadingStrategy

* fix format

---------

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
This commit is contained in:
Will Browne
2024-09-09 10:38:35 +01:00
committed by GitHub
parent d61530941a
commit 2c47d246fc
24 changed files with 724 additions and 119 deletions

View File

@ -16,6 +16,7 @@ type Plugin struct {
Class plugins.Class
// App fields
Parent *ParentPlugin
IncludedInAppID string
DefaultNavURL string
Pinned bool
@ -59,7 +60,7 @@ func ToGrafanaDTO(p *plugins.Plugin) Plugin {
supportsStreaming = true
}
return Plugin{
dto := Plugin{
fs: p.FS,
supportsStreaming: supportsStreaming,
Class: p.Class,
@ -76,4 +77,14 @@ func ToGrafanaDTO(p *plugins.Plugin) Plugin {
ExternalService: p.ExternalService,
Angular: p.Angular,
}
if p.Parent != nil {
dto.Parent = &ParentPlugin{ID: p.Parent.ID}
}
return dto
}
type ParentPlugin struct {
ID string
}