mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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:
@@ -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.
|
# 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 =
|
allow_loading_unsigned_plugins =
|
||||||
# Enable or disable installing plugins directly from within Grafana.
|
# Enable or disable installing plugins directly from within Grafana.
|
||||||
plugin_admin_enabled = false
|
plugin_admin_enabled = true
|
||||||
plugin_admin_external_manage_enabled = false
|
plugin_admin_external_manage_enabled = false
|
||||||
plugin_catalog_url = https://grafana.com/grafana/plugins/
|
plugin_catalog_url = https://grafana.com/grafana/plugins/
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export class GrafanaBootConfig implements GrafanaConfig {
|
|||||||
sampleRate: 1,
|
sampleRate: 1,
|
||||||
};
|
};
|
||||||
pluginCatalogURL = 'https://grafana.com/grafana/plugins/';
|
pluginCatalogURL = 'https://grafana.com/grafana/plugins/';
|
||||||
pluginAdminEnabled = false;
|
pluginAdminEnabled = true;
|
||||||
pluginAdminExternalManageEnabled = false;
|
pluginAdminExternalManageEnabled = false;
|
||||||
expressionsEnabled = false;
|
expressionsEnabled = false;
|
||||||
customTheme?: any;
|
customTheme?: any;
|
||||||
|
|||||||
@@ -930,7 +930,7 @@ func (cfg *Cfg) Load(args CommandLineArgs) error {
|
|||||||
cfg.PluginsAllowUnsigned = append(cfg.PluginsAllowUnsigned, plug)
|
cfg.PluginsAllowUnsigned = append(cfg.PluginsAllowUnsigned, plug)
|
||||||
}
|
}
|
||||||
cfg.PluginCatalogURL = pluginsSection.Key("plugin_catalog_url").MustString("https://grafana.com/grafana/plugins/")
|
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)
|
cfg.PluginAdminExternalManageEnabled = pluginsSection.Key("plugin_admin_external_manage_enabled").MustBool(false)
|
||||||
|
|
||||||
if err := cfg.readFeatureToggles(iniFile); err != nil {
|
if err := cfg.readFeatureToggles(iniFile); err != nil {
|
||||||
|
|||||||
@@ -11,14 +11,21 @@ import { afterEach } from '../../../test/lib/common';
|
|||||||
|
|
||||||
let errorsReturnMock: any = [];
|
let errorsReturnMock: any = [];
|
||||||
|
|
||||||
jest.mock('@grafana/runtime', () => ({
|
jest.mock('@grafana/runtime', () => {
|
||||||
...(jest.requireActual('@grafana/runtime') as object),
|
const original = jest.requireActual('@grafana/runtime');
|
||||||
getBackendSrv: () => ({
|
const mockedRuntime = {
|
||||||
get: () => {
|
...original,
|
||||||
return errorsReturnMock as any;
|
getBackendSrv: () => ({
|
||||||
},
|
get: () => {
|
||||||
}),
|
return errorsReturnMock as any;
|
||||||
}));
|
},
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
mockedRuntime.config.pluginAdminEnabled = false;
|
||||||
|
|
||||||
|
return mockedRuntime;
|
||||||
|
});
|
||||||
|
|
||||||
const setup = (propOverrides?: object) => {
|
const setup = (propOverrides?: object) => {
|
||||||
const store = configureStore();
|
const store = configureStore();
|
||||||
|
|||||||
@@ -12,14 +12,12 @@ import { PluginAdminRoutes, CatalogPlugin, ReducerState, RequestStatus } from '.
|
|||||||
import { getCatalogPluginMock, getPluginsStateMock } from '../__mocks__';
|
import { getCatalogPluginMock, getPluginsStateMock } from '../__mocks__';
|
||||||
import BrowsePage from './Browse';
|
import BrowsePage from './Browse';
|
||||||
|
|
||||||
// Mock the config to enable the plugin catalog
|
|
||||||
jest.mock('@grafana/runtime', () => {
|
jest.mock('@grafana/runtime', () => {
|
||||||
const original = jest.requireActual('@grafana/runtime');
|
const original = jest.requireActual('@grafana/runtime');
|
||||||
const mockedRuntime = { ...original };
|
const mockedRuntime = { ...original };
|
||||||
|
|
||||||
mockedRuntime.config.bootData.user.isGrafanaAdmin = true;
|
mockedRuntime.config.bootData.user.isGrafanaAdmin = true;
|
||||||
mockedRuntime.config.buildInfo.version = 'v8.1.0';
|
mockedRuntime.config.buildInfo.version = 'v8.1.0';
|
||||||
mockedRuntime.config.pluginAdminEnabled = true;
|
|
||||||
|
|
||||||
return mockedRuntime;
|
return mockedRuntime;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,14 +14,12 @@ import { mockPluginApis, getCatalogPluginMock, getPluginsStateMock } from '../__
|
|||||||
import { PluginErrorCode, PluginSignatureStatus } from '@grafana/data';
|
import { PluginErrorCode, PluginSignatureStatus } from '@grafana/data';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
|
|
||||||
// Mock the config to enable the plugin catalog
|
|
||||||
jest.mock('@grafana/runtime', () => {
|
jest.mock('@grafana/runtime', () => {
|
||||||
const original = jest.requireActual('@grafana/runtime');
|
const original = jest.requireActual('@grafana/runtime');
|
||||||
const mockedRuntime = { ...original };
|
const mockedRuntime = { ...original };
|
||||||
|
|
||||||
mockedRuntime.config.bootData.user.isGrafanaAdmin = true;
|
mockedRuntime.config.bootData.user.isGrafanaAdmin = true;
|
||||||
mockedRuntime.config.buildInfo.version = 'v8.1.0';
|
mockedRuntime.config.buildInfo.version = 'v8.1.0';
|
||||||
mockedRuntime.config.pluginAdminEnabled = true;
|
|
||||||
|
|
||||||
return mockedRuntime;
|
return mockedRuntime;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ import {
|
|||||||
} from './reducers';
|
} from './reducers';
|
||||||
import { PluginMetaInfo, PluginType } from '@grafana/data';
|
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('pluginsReducer', () => {
|
||||||
describe('when pluginsLoaded is dispatched', () => {
|
describe('when pluginsLoaded is dispatched', () => {
|
||||||
it('then state should be correct', () => {
|
it('then state should be correct', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user