Plugins Catalog: Make the catalog the default way to interact with plugins (#39779)

* chore(Plugins/Admin): make the Plugins Catalog the default way to interact with plugins

* chore(defaults.ini): change the default value for `plugin_admin_enabled`

* test(Plugins): make the tests pass
This commit is contained in:
Levente Balogh 2021-09-30 08:34:03 +02:00 committed by GitHub
parent 4c8c2f6c96
commit c2754eb9cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 28 additions and 15 deletions

View File

@ -965,7 +965,7 @@ app_tls_skip_verify_insecure = false
# Enter a comma-separated list of plugin identifiers to identify plugins to load even if they are unsigned. Plugins with modified signatures are never loaded.
allow_loading_unsigned_plugins =
# Enable or disable installing plugins directly from within Grafana.
plugin_admin_enabled = false
plugin_admin_enabled = true
plugin_admin_external_manage_enabled = false
plugin_catalog_url = https://grafana.com/grafana/plugins/

View File

@ -80,7 +80,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
sampleRate: 1,
};
pluginCatalogURL = 'https://grafana.com/grafana/plugins/';
pluginAdminEnabled = false;
pluginAdminEnabled = true;
pluginAdminExternalManageEnabled = false;
expressionsEnabled = false;
customTheme?: any;

View File

@ -930,7 +930,7 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
cfg.PluginsAllowUnsigned = append(cfg.PluginsAllowUnsigned, plug)
}
cfg.PluginCatalogURL = pluginsSection.Key("plugin_catalog_url").MustString("https://grafana.com/grafana/plugins/")
cfg.PluginAdminEnabled = pluginsSection.Key("plugin_admin_enabled").MustBool(false)
cfg.PluginAdminEnabled = pluginsSection.Key("plugin_admin_enabled").MustBool(true)
cfg.PluginAdminExternalManageEnabled = pluginsSection.Key("plugin_admin_external_manage_enabled").MustBool(false)
if err := cfg.readFeatureToggles(iniFile); err != nil {

View File

@ -11,14 +11,21 @@ import { afterEach } from '../../../test/lib/common';
let errorsReturnMock: any = [];
jest.mock('@grafana/runtime', () => ({
...(jest.requireActual('@grafana/runtime') as object),
jest.mock('@grafana/runtime', () => {
const original = jest.requireActual('@grafana/runtime');
const mockedRuntime = {
...original,
getBackendSrv: () => ({
get: () => {
return errorsReturnMock as any;
},
}),
}));
};
mockedRuntime.config.pluginAdminEnabled = false;
return mockedRuntime;
});
const setup = (propOverrides?: object) => {
const store = configureStore();

View File

@ -12,14 +12,12 @@ import { PluginAdminRoutes, CatalogPlugin, ReducerState, RequestStatus } from '.
import { getCatalogPluginMock, getPluginsStateMock } from '../__mocks__';
import BrowsePage from './Browse';
// Mock the config to enable the plugin catalog
jest.mock('@grafana/runtime', () => {
const original = jest.requireActual('@grafana/runtime');
const mockedRuntime = { ...original };
mockedRuntime.config.bootData.user.isGrafanaAdmin = true;
mockedRuntime.config.buildInfo.version = 'v8.1.0';
mockedRuntime.config.pluginAdminEnabled = true;
return mockedRuntime;
});

View File

@ -14,14 +14,12 @@ import { mockPluginApis, getCatalogPluginMock, getPluginsStateMock } from '../__
import { PluginErrorCode, PluginSignatureStatus } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
// Mock the config to enable the plugin catalog
jest.mock('@grafana/runtime', () => {
const original = jest.requireActual('@grafana/runtime');
const mockedRuntime = { ...original };
mockedRuntime.config.bootData.user.isGrafanaAdmin = true;
mockedRuntime.config.buildInfo.version = 'v8.1.0';
mockedRuntime.config.pluginAdminEnabled = true;
return mockedRuntime;
});

View File

@ -11,6 +11,16 @@ import {
} from './reducers';
import { PluginMetaInfo, PluginType } from '@grafana/data';
// Mock the config to enable the old version of the plugins page
jest.mock('@grafana/runtime', () => {
const original = jest.requireActual('@grafana/runtime');
const mockedRuntime = { ...original };
mockedRuntime.config.pluginAdminEnabled = false;
return mockedRuntime;
});
describe('pluginsReducer', () => {
describe('when pluginsLoaded is dispatched', () => {
it('then state should be correct', () => {