Chore: defaults localizationForPlugins behavior (#109778)
* Chore: defaults localizationForPlugins behavior * chore: fixes backend tests * chore: fix backend tests * chore: fix some more backend tests
This commit is contained in:
@@ -122,11 +122,12 @@ func TestLoader_Load(t *testing.T) {
|
||||
Backend: true,
|
||||
QueryOptions: map[string]bool{"minInterval": true},
|
||||
},
|
||||
Module: "core:plugin/cloudwatch",
|
||||
BaseURL: "public/plugins/cloudwatch",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(corePluginDir, "app/plugins/datasource/cloudwatch")),
|
||||
Signature: plugins.SignatureStatusInternal,
|
||||
Class: plugins.ClassCore,
|
||||
Module: "core:plugin/cloudwatch",
|
||||
BaseURL: "public/plugins/cloudwatch",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(corePluginDir, "app/plugins/datasource/cloudwatch")),
|
||||
Signature: plugins.SignatureStatusInternal,
|
||||
Class: plugins.ClassCore,
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -221,6 +222,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
Signature: "valid",
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -266,11 +268,12 @@ func TestLoader_Load(t *testing.T) {
|
||||
Backend: true,
|
||||
State: plugins.ReleaseStateAlpha,
|
||||
},
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "public/plugins/test-datasource/module.js",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/unsigned-datasource/plugin")),
|
||||
Signature: "unsigned",
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "public/plugins/test-datasource/module.js",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/unsigned-datasource/plugin")),
|
||||
Signature: "unsigned",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -323,11 +326,12 @@ func TestLoader_Load(t *testing.T) {
|
||||
Backend: true,
|
||||
State: plugins.ReleaseStateAlpha,
|
||||
},
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "public/plugins/test-datasource/module.js",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/unsigned-datasource/plugin")),
|
||||
Signature: plugins.SignatureStatusUnsigned,
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "public/plugins/test-datasource/module.js",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(parentDir, "testdata/unsigned-datasource/plugin")),
|
||||
Signature: plugins.SignatureStatusUnsigned,
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -424,6 +428,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
Signature: plugins.SignatureStatusUnsigned,
|
||||
Module: "public/plugins/test-app/module.js",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -78,10 +78,8 @@ func (f *DefaultPluginFactory) newPlugin(p plugins.FoundPlugin, class plugins.Cl
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if f.features.LocalizationForPlugins {
|
||||
if err := setTranslations(plugin, f.assetPath, info); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := setTranslations(plugin, f.assetPath, info); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return plugin, nil
|
||||
|
||||
@@ -121,11 +121,12 @@ func TestLoader_Load(t *testing.T) {
|
||||
Backend: true,
|
||||
QueryOptions: map[string]bool{"minInterval": true},
|
||||
},
|
||||
Module: "core:plugin/cloudwatch",
|
||||
BaseURL: "public/plugins/cloudwatch",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(corePluginDir(t), "app/plugins/datasource/cloudwatch")),
|
||||
Signature: plugins.SignatureStatusInternal,
|
||||
Class: plugins.ClassCore,
|
||||
Module: "core:plugin/cloudwatch",
|
||||
BaseURL: "public/plugins/cloudwatch",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(corePluginDir(t), "app/plugins/datasource/cloudwatch")),
|
||||
Signature: plugins.SignatureStatusInternal,
|
||||
Class: plugins.ClassCore,
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -220,6 +221,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
Signature: "valid",
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -265,11 +267,12 @@ func TestLoader_Load(t *testing.T) {
|
||||
Backend: true,
|
||||
State: plugins.ReleaseStateAlpha,
|
||||
},
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "public/plugins/test-datasource/module.js",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(testDataDir(t), "unsigned-datasource/plugin")),
|
||||
Signature: "unsigned",
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "public/plugins/test-datasource/module.js",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(testDataDir(t), "unsigned-datasource/plugin")),
|
||||
Signature: "unsigned",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -328,11 +331,12 @@ func TestLoader_Load(t *testing.T) {
|
||||
Backend: true,
|
||||
State: plugins.ReleaseStateAlpha,
|
||||
},
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "public/plugins/test-datasource/module.js",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(testDataDir(t), "unsigned-datasource/plugin")),
|
||||
Signature: plugins.SignatureStatusUnsigned,
|
||||
Class: plugins.ClassExternal,
|
||||
Module: "public/plugins/test-datasource/module.js",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(testDataDir(t), "unsigned-datasource/plugin")),
|
||||
Signature: plugins.SignatureStatusUnsigned,
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -453,6 +457,7 @@ func TestLoader_Load(t *testing.T) {
|
||||
Signature: plugins.SignatureStatusUnsigned,
|
||||
Module: "public/plugins/test-app/module.js",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -542,6 +547,7 @@ func TestLoader_Load_ExternalRegistration(t *testing.T) {
|
||||
ClientID: "client-id",
|
||||
ClientSecret: "secretz",
|
||||
},
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -636,11 +642,12 @@ func TestLoader_Load_CustomSource(t *testing.T) {
|
||||
ExtensionPoints: []plugins.ExtensionPoint{},
|
||||
},
|
||||
},
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(testDataDir(t), "cdn/plugin")),
|
||||
Class: plugins.ClassExternal,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
BaseURL: "https://cdn.example.com/grafana-worldmap-panel/0.3.3/public/plugins/grafana-worldmap-panel",
|
||||
Module: "https://cdn.example.com/grafana-worldmap-panel/0.3.3/public/plugins/grafana-worldmap-panel/module.js",
|
||||
FS: mustNewStaticFSForTests(t, filepath.Join(testDataDir(t), "cdn/plugin")),
|
||||
Class: plugins.ClassExternal,
|
||||
Signature: plugins.SignatureStatusValid,
|
||||
BaseURL: "https://cdn.example.com/grafana-worldmap-panel/0.3.3/public/plugins/grafana-worldmap-panel",
|
||||
Module: "https://cdn.example.com/grafana-worldmap-panel/0.3.3/public/plugins/grafana-worldmap-panel/module.js",
|
||||
Translations: map[string]string{},
|
||||
}}
|
||||
|
||||
l := newLoader(t, cfg, fakes.NewFakePluginRegistry(), fakes.NewFakeProcessManager(), fakes.NewFakeBackendProcessProvider(), newFakeErrorTracker())
|
||||
@@ -727,6 +734,7 @@ func TestLoader_Load_MultiplePlugins(t *testing.T) {
|
||||
Signature: "valid",
|
||||
SignatureType: plugins.SignatureTypePrivate,
|
||||
SignatureOrg: "Will Browne",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
pluginErrors: map[string]*plugins.Error{
|
||||
@@ -845,6 +853,7 @@ func TestLoader_Load_RBACReady(t *testing.T) {
|
||||
SignatureOrg: "gabrielmabille",
|
||||
Module: "public/plugins/test-app/module.js",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -913,6 +922,7 @@ func TestLoader_Load_Signature_RootURL(t *testing.T) {
|
||||
SignatureOrg: "Will Browne",
|
||||
Module: "public/plugins/test-datasource/module.js",
|
||||
BaseURL: "public/plugins/test-datasource",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -999,6 +1009,7 @@ func TestLoader_Load_DuplicatePlugins(t *testing.T) {
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Module: "public/plugins/test-app/module.js",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1089,6 +1100,7 @@ func TestLoader_Load_SkipUninitializedPlugins(t *testing.T) {
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Module: "public/plugins/test-app/module.js",
|
||||
BaseURL: "public/plugins/test-app",
|
||||
Translations: map[string]string{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1290,6 +1302,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Class: plugins.ClassExternal,
|
||||
Translations: map[string]string{},
|
||||
}
|
||||
|
||||
child := &plugins.Plugin{
|
||||
@@ -1333,6 +1346,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Class: plugins.ClassExternal,
|
||||
Translations: map[string]string{},
|
||||
}
|
||||
|
||||
parent.Children = []*plugins.Plugin{child}
|
||||
@@ -1482,6 +1496,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Class: plugins.ClassExternal,
|
||||
Translations: map[string]string{},
|
||||
}
|
||||
|
||||
child := &plugins.Plugin{
|
||||
@@ -1532,6 +1547,7 @@ func TestLoader_Load_NestedPlugins(t *testing.T) {
|
||||
SignatureType: plugins.SignatureTypeGrafana,
|
||||
SignatureOrg: "Grafana Labs",
|
||||
Class: plugins.ClassExternal,
|
||||
Translations: map[string]string{},
|
||||
}
|
||||
|
||||
parent.Children = []*plugins.Plugin{child}
|
||||
|
||||
@@ -32,7 +32,6 @@ func ProvidePluginManagementConfig(cfg *setting.Cfg, settingProvider setting.Pro
|
||||
config.Features{
|
||||
SkipHostEnvVarsEnabled: features.IsEnabledGlobally(featuremgmt.FlagPluginsSkipHostEnvVars),
|
||||
SriChecksEnabled: features.IsEnabledGlobally(featuremgmt.FlagPluginsSriChecks),
|
||||
LocalizationForPlugins: features.IsEnabledGlobally(featuremgmt.FlagLocalizationForPlugins),
|
||||
TempoAlertingEnabled: features.IsEnabledGlobally(featuremgmt.FlagTempoAlerting),
|
||||
PluginAssetProvider: features.IsEnabledGlobally(featuremgmt.FlagPluginAssetProvider),
|
||||
},
|
||||
|
||||
@@ -26,7 +26,7 @@ export async function importPluginModule({
|
||||
}
|
||||
|
||||
// Add locales to i18n for a plugin if the feature toggle is enabled and the plugin has locales
|
||||
if (config.featureToggles.localizationForPlugins && translations) {
|
||||
if (translations) {
|
||||
await addTranslationsToI18n({
|
||||
resolvedLanguage: getResolvedLanguage(),
|
||||
fallbackLanguage: DEFAULT_LANGUAGE,
|
||||
|
||||
Reference in New Issue
Block a user