mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Allow disabling angular deprecation UI for specific plugins (#77026)
* Plugins:Allow disabling angular deprecation UI for specific plugins * add backend test * changed test names * lint * Removed angular properties from DataSourceDTO * Update tests * Move angularDetected and hideAngularDeprecation in angularMeta property * Fix angular property name in AppPluginConfig * Fix reference to angularMeta.detected * Fix hide_angular_deprecation not working for core plugins * lint
This commit is contained in:
@@ -95,7 +95,7 @@ func (a *AngularDetector) Validate(ctx context.Context, p *plugins.Plugin) error
|
||||
var err error
|
||||
|
||||
cctx, canc := context.WithTimeout(ctx, time.Second*10)
|
||||
p.AngularDetected, err = a.angularInspector.Inspect(cctx, p)
|
||||
p.Angular.Detected, err = a.angularInspector.Inspect(cctx, p)
|
||||
canc()
|
||||
|
||||
if err != nil {
|
||||
@@ -103,11 +103,11 @@ func (a *AngularDetector) Validate(ctx context.Context, p *plugins.Plugin) error
|
||||
}
|
||||
|
||||
// Do not initialize plugins if they're using Angular and Angular support is disabled
|
||||
if p.AngularDetected && !a.cfg.AngularSupportEnabled {
|
||||
if p.Angular.Detected && !a.cfg.AngularSupportEnabled {
|
||||
a.log.Error("Refusing to initialize plugin because it's using Angular, which has been disabled", "pluginId", p.ID)
|
||||
return errors.New("angular plugins are not supported")
|
||||
}
|
||||
}
|
||||
|
||||
p.Angular.HideDeprecation = a.cfg.PluginSettings[p.ID]["hide_angular_deprecation"] == "true"
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -208,22 +208,23 @@ type PluginMetaDTO struct {
|
||||
|
||||
Module string `json:"module"`
|
||||
BaseURL string `json:"baseUrl"`
|
||||
|
||||
Angular AngularMeta `json:"angular"`
|
||||
}
|
||||
|
||||
type DataSourceDTO struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
UID string `json:"uid,omitempty"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
PluginMeta *PluginMetaDTO `json:"meta"`
|
||||
URL string `json:"url,omitempty"`
|
||||
IsDefault bool `json:"isDefault"`
|
||||
Access string `json:"access,omitempty"`
|
||||
Preload bool `json:"preload"`
|
||||
Module string `json:"module,omitempty"`
|
||||
JSONData map[string]any `json:"jsonData"`
|
||||
ReadOnly bool `json:"readOnly"`
|
||||
AngularDetected bool `json:"angularDetected"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
UID string `json:"uid,omitempty"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
PluginMeta *PluginMetaDTO `json:"meta"`
|
||||
URL string `json:"url,omitempty"`
|
||||
IsDefault bool `json:"isDefault"`
|
||||
Access string `json:"access,omitempty"`
|
||||
Preload bool `json:"preload"`
|
||||
Module string `json:"module,omitempty"`
|
||||
JSONData map[string]any `json:"jsonData"`
|
||||
ReadOnly bool `json:"readOnly"`
|
||||
|
||||
BasicAuth string `json:"basicAuth,omitempty"`
|
||||
WithCredentials bool `json:"withCredentials,omitempty"`
|
||||
@@ -243,26 +244,28 @@ type DataSourceDTO struct {
|
||||
}
|
||||
|
||||
type PanelDTO struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
AliasIDs []string `json:"aliasIds,omitempty"`
|
||||
Info Info `json:"info"`
|
||||
HideFromList bool `json:"hideFromList"`
|
||||
Sort int `json:"sort"`
|
||||
SkipDataQuery bool `json:"skipDataQuery"`
|
||||
ReleaseState string `json:"state"`
|
||||
BaseURL string `json:"baseUrl"`
|
||||
Signature string `json:"signature"`
|
||||
Module string `json:"module"`
|
||||
AngularDetected bool `json:"angularDetected"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
AliasIDs []string `json:"aliasIds,omitempty"`
|
||||
Info Info `json:"info"`
|
||||
HideFromList bool `json:"hideFromList"`
|
||||
Sort int `json:"sort"`
|
||||
SkipDataQuery bool `json:"skipDataQuery"`
|
||||
ReleaseState string `json:"state"`
|
||||
BaseURL string `json:"baseUrl"`
|
||||
Signature string `json:"signature"`
|
||||
Module string `json:"module"`
|
||||
|
||||
Angular AngularMeta `json:"angular"`
|
||||
}
|
||||
|
||||
type AppDTO struct {
|
||||
ID string `json:"id"`
|
||||
Path string `json:"path"`
|
||||
Version string `json:"version"`
|
||||
Preload bool `json:"preload"`
|
||||
AngularDetected bool `json:"angularDetected"`
|
||||
ID string `json:"id"`
|
||||
Path string `json:"path"`
|
||||
Version string `json:"version"`
|
||||
Preload bool `json:"preload"`
|
||||
|
||||
Angular AngularMeta `json:"angular"`
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
@@ -55,7 +55,7 @@ type Plugin struct {
|
||||
Module string
|
||||
BaseURL string
|
||||
|
||||
AngularDetected bool
|
||||
Angular AngularMeta
|
||||
|
||||
ExternalService *auth.ExternalService
|
||||
|
||||
@@ -67,6 +67,11 @@ type Plugin struct {
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
type AngularMeta struct {
|
||||
Detected bool `json:"detected"`
|
||||
HideDeprecation bool `json:"hideDeprecation"`
|
||||
}
|
||||
|
||||
// JSONData represents the plugin's plugin.json
|
||||
type JSONData struct {
|
||||
// Common settings
|
||||
|
||||
Reference in New Issue
Block a user