mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 18:52:44 +08:00

* 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>
91 lines
1.8 KiB
Go
91 lines
1.8 KiB
Go
package pluginstore
|
|
|
|
import (
|
|
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
|
|
|
"github.com/grafana/grafana/pkg/plugins"
|
|
"github.com/grafana/grafana/pkg/plugins/auth"
|
|
)
|
|
|
|
type Plugin struct {
|
|
plugins.JSONData
|
|
|
|
fs plugins.FS
|
|
supportsStreaming bool
|
|
|
|
Class plugins.Class
|
|
|
|
// App fields
|
|
Parent *ParentPlugin
|
|
IncludedInAppID string
|
|
DefaultNavURL string
|
|
Pinned bool
|
|
|
|
// Signature fields
|
|
Signature plugins.SignatureStatus
|
|
SignatureType plugins.SignatureType
|
|
SignatureOrg string
|
|
|
|
Error *plugins.Error
|
|
|
|
// SystemJS fields
|
|
Module string
|
|
BaseURL string
|
|
|
|
Angular plugins.AngularMeta
|
|
|
|
ExternalService *auth.ExternalService
|
|
}
|
|
|
|
func (p Plugin) SupportsStreaming() bool {
|
|
return p.supportsStreaming
|
|
}
|
|
|
|
func (p Plugin) Base() string {
|
|
return p.fs.Base()
|
|
}
|
|
|
|
func (p Plugin) IsApp() bool {
|
|
return p.Type == plugins.TypeApp
|
|
}
|
|
|
|
func (p Plugin) IsCorePlugin() bool {
|
|
return p.Class == plugins.ClassCore
|
|
}
|
|
|
|
func ToGrafanaDTO(p *plugins.Plugin) Plugin {
|
|
supportsStreaming := false
|
|
pc, exists := p.Client()
|
|
if exists && pc != nil && pc.(backend.StreamHandler) != nil {
|
|
supportsStreaming = true
|
|
}
|
|
|
|
dto := Plugin{
|
|
fs: p.FS,
|
|
supportsStreaming: supportsStreaming,
|
|
Class: p.Class,
|
|
JSONData: p.JSONData,
|
|
IncludedInAppID: p.IncludedInAppID,
|
|
DefaultNavURL: p.DefaultNavURL,
|
|
Pinned: p.Pinned,
|
|
Signature: p.Signature,
|
|
SignatureType: p.SignatureType,
|
|
SignatureOrg: p.SignatureOrg,
|
|
Error: p.Error,
|
|
Module: p.Module,
|
|
BaseURL: p.BaseURL,
|
|
ExternalService: p.ExternalService,
|
|
Angular: p.Angular,
|
|
}
|
|
|
|
if p.Parent != nil {
|
|
dto.Parent = &ParentPlugin{ID: p.Parent.ID}
|
|
}
|
|
|
|
return dto
|
|
}
|
|
|
|
type ParentPlugin struct {
|
|
ID string
|
|
}
|