parent
15ea696531
commit
ecc03e9468
17 changed files with 189 additions and 28 deletions
|
@ -453,7 +453,7 @@ us improve your user experience. Your data is never shared with anyone. Set to
|
|||
`false` to disable telemetry capabilities entirely. You can alternatively opt
|
||||
out through the *Advanced Settings* in {kib}.
|
||||
|
||||
`vega.enableExternalUrls:`:: *Default: false* Set this value to true to allow Vega to use any URL to access external data sources and images. If false, Vega can only get data from Elasticsearch.
|
||||
`vis_type_vega.enableExternalUrls:`:: *Default: false* Set this value to true to allow Vega to use any URL to access external data sources and images. If false, Vega can only get data from Elasticsearch.
|
||||
|
||||
`xpack.license_management.enabled`:: *Default: true* Set this value to false to
|
||||
disable the License Management user interface.
|
||||
|
|
|
@ -39,17 +39,10 @@ const vegaPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPlugin
|
|||
|
||||
return {
|
||||
emsTileLayerId: mapConfig.emsTileLayerId,
|
||||
enableExternalUrls: serverConfig.get('vega.enableExternalUrls'),
|
||||
};
|
||||
},
|
||||
},
|
||||
init: (server: Legacy.Server) => ({}),
|
||||
config(Joi: any) {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
enableExternalUrls: Joi.boolean().default(false),
|
||||
}).default();
|
||||
},
|
||||
} as Legacy.PluginSpecOptions);
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
|
|
|
@ -47,6 +47,7 @@ import { createVegaTypeDefinition } from '../vega_type';
|
|||
// this test has to be migrated to the newly created integration test environment.
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { setInjectedVars } from '../services';
|
||||
|
||||
const THRESHOLD = 0.1;
|
||||
const PIXEL_DIFF = 30;
|
||||
|
@ -60,6 +61,12 @@ describe('VegaVisualizations', () => {
|
|||
let vegaVisualizationDependencies;
|
||||
let visRegComplete = false;
|
||||
|
||||
setInjectedVars({
|
||||
emsTileLayerId: {},
|
||||
enableExternalUrls: true,
|
||||
esShardTimeout: 10000,
|
||||
});
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(
|
||||
ngMock.inject((Private, $injector) => {
|
||||
|
|
|
@ -26,9 +26,8 @@ import { LegacyDependenciesPlugin } from './shim';
|
|||
import { plugin } from '.';
|
||||
|
||||
const setupPlugins: Readonly<VegaPluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
...npSetup.plugins,
|
||||
visualizations: visualizationsSetup,
|
||||
data: npSetup.plugins.data,
|
||||
|
||||
// Temporary solution
|
||||
// It will be removed when all dependent services are migrated to the new platform.
|
||||
|
@ -36,7 +35,7 @@ const setupPlugins: Readonly<VegaPluginSetupDependencies> = {
|
|||
};
|
||||
|
||||
const startPlugins: Readonly<VegaPluginStartDependencies> = {
|
||||
data: npStart.plugins.data,
|
||||
...npStart.plugins,
|
||||
};
|
||||
|
||||
const pluginInstance = plugin({} as PluginInitializerContext);
|
||||
|
|
|
@ -31,6 +31,7 @@ import {
|
|||
|
||||
import { createVegaFn } from './vega_fn';
|
||||
import { createVegaTypeDefinition } from './vega_type';
|
||||
import { VisTypeVegaSetup } from '../../../../plugins/vis_type_vega/public';
|
||||
|
||||
/** @internal */
|
||||
export interface VegaVisualizationDependencies extends LegacyDependenciesPluginSetup {
|
||||
|
@ -45,6 +46,7 @@ export interface VegaPluginSetupDependencies {
|
|||
expressions: ReturnType<ExpressionsPublicPlugin['setup']>;
|
||||
visualizations: VisualizationsSetup;
|
||||
data: ReturnType<DataPublicPlugin['setup']>;
|
||||
visTypeVega: VisTypeVegaSetup;
|
||||
__LEGACY: LegacyDependenciesPlugin;
|
||||
}
|
||||
|
||||
|
@ -63,11 +65,11 @@ export class VegaPlugin implements Plugin<Promise<void>, void> {
|
|||
|
||||
public async setup(
|
||||
core: CoreSetup,
|
||||
{ data, expressions, visualizations, __LEGACY }: VegaPluginSetupDependencies
|
||||
{ data, expressions, visualizations, visTypeVega, __LEGACY }: VegaPluginSetupDependencies
|
||||
) {
|
||||
setInjectedVars({
|
||||
enableExternalUrls: visTypeVega.config.enableExternalUrls,
|
||||
esShardTimeout: core.injectedMetadata.getInjectedVar('esShardTimeout') as number,
|
||||
enableExternalUrls: core.injectedMetadata.getInjectedVar('enableExternalUrls') as boolean,
|
||||
emsTileLayerId: core.injectedMetadata.getInjectedVar('emsTileLayerId', true),
|
||||
});
|
||||
setUISettings(core.uiSettings);
|
||||
|
|
|
@ -44,6 +44,7 @@ import {
|
|||
NavigationPublicPluginSetup,
|
||||
NavigationPublicPluginStart,
|
||||
} from '../../../../plugins/navigation/public';
|
||||
import { VisTypeVegaSetup } from '../../../../plugins/vis_type_vega/public';
|
||||
|
||||
export interface PluginsSetup {
|
||||
bfetch: BfetchPublicSetup;
|
||||
|
@ -61,6 +62,7 @@ export interface PluginsSetup {
|
|||
usageCollection: UsageCollectionSetup;
|
||||
advancedSettings: AdvancedSettingsSetup;
|
||||
management: ManagementSetup;
|
||||
visTypeVega: VisTypeVegaSetup;
|
||||
telemetry?: TelemetryPluginSetup;
|
||||
}
|
||||
|
||||
|
|
27
src/plugins/vis_type_vega/config.ts
Normal file
27
src/plugins/vis_type_vega/config.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { schema, TypeOf } from '@kbn/config-schema';
|
||||
|
||||
export const configSchema = schema.object({
|
||||
enabled: schema.boolean({ defaultValue: true }),
|
||||
enableExternalUrls: schema.boolean({ defaultValue: false }),
|
||||
});
|
||||
|
||||
export type ConfigSchema = TypeOf<typeof configSchema>;
|
6
src/plugins/vis_type_vega/kibana.json
Normal file
6
src/plugins/vis_type_vega/kibana.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"id": "visTypeVega",
|
||||
"version": "kibana",
|
||||
"server": true,
|
||||
"ui": true
|
||||
}
|
38
src/plugins/vis_type_vega/public/index.ts
Normal file
38
src/plugins/vis_type_vega/public/index.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { ConfigSchema } from '../config';
|
||||
|
||||
export const plugin = (initializerContext: PluginInitializerContext<ConfigSchema>) => ({
|
||||
setup() {
|
||||
return {
|
||||
/**
|
||||
* The configuration is temporarily exposed to allow the legacy vega plugin to consume
|
||||
* the setting. Once the vega plugin is migrated completely, this will become an implementation
|
||||
* detail.
|
||||
* @deprecated
|
||||
*/
|
||||
config: initializerContext.config.get(),
|
||||
};
|
||||
},
|
||||
start() {},
|
||||
});
|
||||
|
||||
export type VisTypeVegaSetup = ReturnType<ReturnType<typeof plugin>['setup']>;
|
38
src/plugins/vis_type_vega/server/index.ts
Normal file
38
src/plugins/vis_type_vega/server/index.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginConfigDescriptor } from 'kibana/server';
|
||||
|
||||
import { configSchema, ConfigSchema } from '../config';
|
||||
|
||||
export const config: PluginConfigDescriptor<ConfigSchema> = {
|
||||
exposeToBrowser: {
|
||||
enableExternalUrls: true,
|
||||
},
|
||||
schema: configSchema,
|
||||
deprecations: ({ renameFromRoot }) => [
|
||||
renameFromRoot('vega.enableExternalUrls', 'vis_type_vega.enableExternalUrls'),
|
||||
renameFromRoot('vega.enabled', 'vis_type_vega.enabled'),
|
||||
],
|
||||
};
|
||||
|
||||
export const plugin = () => ({
|
||||
setup() {},
|
||||
start() {},
|
||||
});
|
|
@ -44,14 +44,6 @@ export const graph: LegacyPluginInitializer = kibana => {
|
|||
},
|
||||
|
||||
init(server) {
|
||||
server.injectUiAppVars('graph', () => {
|
||||
const config = server.config();
|
||||
return {
|
||||
graphSavePolicy: config.get('xpack.graph.savePolicy'),
|
||||
canEditDrillDownUrls: config.get('xpack.graph.canEditDrillDownUrls'),
|
||||
};
|
||||
});
|
||||
|
||||
server.plugins.xpack_main.registerFeature({
|
||||
id: 'graph',
|
||||
name: i18n.translate('xpack.graph.featureRegistry.graphFeatureName', {
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
import { LicensingPluginSetup } from '../../../../plugins/licensing/public';
|
||||
import { GraphPlugin } from './plugin';
|
||||
import { GraphSetup } from '../../../../plugins/graph/public';
|
||||
|
||||
type XpackNpSetupDeps = typeof npSetup.plugins & {
|
||||
licensing: LicensingPluginSetup;
|
||||
graph: GraphSetup;
|
||||
};
|
||||
|
||||
(async () => {
|
||||
|
|
|
@ -11,6 +11,7 @@ import { Storage } from '../../../../../src/plugins/kibana_utils/public';
|
|||
import { LicensingPluginSetup } from '../../../../plugins/licensing/public';
|
||||
import { NavigationPublicPluginStart as NavigationStart } from '../../../../../src/plugins/navigation/public';
|
||||
import { initAngularBootstrap } from '../../../../../src/plugins/kibana_legacy/public';
|
||||
import { GraphSetup } from '../../../../plugins/graph/public';
|
||||
|
||||
export interface GraphPluginStartDependencies {
|
||||
npData: ReturnType<DataPlugin['start']>;
|
||||
|
@ -19,6 +20,7 @@ export interface GraphPluginStartDependencies {
|
|||
|
||||
export interface GraphPluginSetupDependencies {
|
||||
licensing: LicensingPluginSetup;
|
||||
graph: GraphSetup;
|
||||
}
|
||||
|
||||
export class GraphPlugin implements Plugin {
|
||||
|
@ -26,7 +28,7 @@ export class GraphPlugin implements Plugin {
|
|||
private npDataStart: ReturnType<DataPlugin['start']> | null = null;
|
||||
private savedObjectsClient: SavedObjectsClientContract | null = null;
|
||||
|
||||
setup(core: CoreSetup, { licensing }: GraphPluginSetupDependencies) {
|
||||
setup(core: CoreSetup, { licensing, graph }: GraphPluginSetupDependencies) {
|
||||
initAngularBootstrap();
|
||||
core.application.register({
|
||||
id: 'graph',
|
||||
|
@ -41,10 +43,8 @@ export class GraphPlugin implements Plugin {
|
|||
savedObjectsClient: this.savedObjectsClient!,
|
||||
addBasePath: core.http.basePath.prepend,
|
||||
getBasePath: core.http.basePath.get,
|
||||
canEditDrillDownUrls: core.injectedMetadata.getInjectedVar(
|
||||
'canEditDrillDownUrls'
|
||||
) as boolean,
|
||||
graphSavePolicy: core.injectedMetadata.getInjectedVar('graphSavePolicy') as string,
|
||||
canEditDrillDownUrls: graph.config.canEditDrillDownUrls,
|
||||
graphSavePolicy: graph.config.savePolicy,
|
||||
storage: new Storage(window.localStorage),
|
||||
capabilities: contextCore.application.capabilities.graph,
|
||||
coreStart: contextCore,
|
||||
|
|
23
x-pack/plugins/graph/config.ts
Normal file
23
x-pack/plugins/graph/config.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { schema, TypeOf } from '@kbn/config-schema';
|
||||
|
||||
export const configSchema = schema.object({
|
||||
enabled: schema.boolean({ defaultValue: true }),
|
||||
savePolicy: schema.oneOf(
|
||||
[
|
||||
schema.literal('none'),
|
||||
schema.literal('config'),
|
||||
schema.literal('configAndData'),
|
||||
schema.literal('configAndDataWithConsent'),
|
||||
],
|
||||
{ defaultValue: 'configAndData' }
|
||||
),
|
||||
canEditDrillDownUrls: schema.boolean({ defaultValue: true }),
|
||||
});
|
||||
|
||||
export type ConfigSchema = TypeOf<typeof configSchema>;
|
|
@ -4,6 +4,11 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { GraphPlugin } from './plugin';
|
||||
import { ConfigSchema } from '../config';
|
||||
|
||||
export const plugin = () => new GraphPlugin();
|
||||
export const plugin = (initializerContext: PluginInitializerContext<ConfigSchema>) =>
|
||||
new GraphPlugin(initializerContext);
|
||||
|
||||
export { GraphSetup } from './plugin';
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import { CoreSetup, CoreStart } from 'kibana/public';
|
||||
import { Plugin } from 'src/core/public';
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { toggleNavLink } from './services/toggle_nav_link';
|
||||
import { LicensingPluginSetup } from '../../licensing/public';
|
||||
import { checkLicense } from '../common/check_license';
|
||||
|
@ -14,15 +15,18 @@ import {
|
|||
FeatureCatalogueCategory,
|
||||
HomePublicPluginSetup,
|
||||
} from '../../../../src/plugins/home/public';
|
||||
import { ConfigSchema } from '../config';
|
||||
|
||||
export interface GraphPluginSetupDependencies {
|
||||
licensing: LicensingPluginSetup;
|
||||
home?: HomePublicPluginSetup;
|
||||
}
|
||||
|
||||
export class GraphPlugin implements Plugin {
|
||||
export class GraphPlugin implements Plugin<{ config: Readonly<ConfigSchema> }, void> {
|
||||
private licensing: LicensingPluginSetup | null = null;
|
||||
|
||||
constructor(private initializerContext: PluginInitializerContext<ConfigSchema>) {}
|
||||
|
||||
setup(core: CoreSetup, { licensing, home }: GraphPluginSetupDependencies) {
|
||||
this.licensing = licensing;
|
||||
|
||||
|
@ -39,6 +43,16 @@ export class GraphPlugin implements Plugin {
|
|||
category: FeatureCatalogueCategory.DATA,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* The configuration is temporarily exposed to allow the legacy graph plugin to consume
|
||||
* the setting. Once the graph plugin is migrated completely, this will become an implementation
|
||||
* detail.
|
||||
* @deprecated
|
||||
*/
|
||||
config: this.initializerContext.config.get(),
|
||||
};
|
||||
}
|
||||
|
||||
start(core: CoreStart) {
|
||||
|
@ -52,3 +66,5 @@ export class GraphPlugin implements Plugin {
|
|||
|
||||
stop() {}
|
||||
}
|
||||
|
||||
export type GraphSetup = ReturnType<GraphPlugin['setup']>;
|
||||
|
|
|
@ -4,6 +4,17 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { PluginConfigDescriptor } from 'kibana/server';
|
||||
|
||||
import { configSchema, ConfigSchema } from '../config';
|
||||
import { GraphPlugin } from './plugin';
|
||||
|
||||
export const plugin = () => new GraphPlugin();
|
||||
|
||||
export const config: PluginConfigDescriptor<ConfigSchema> = {
|
||||
exposeToBrowser: {
|
||||
canEditDrillDownUrls: true,
|
||||
savePolicy: true,
|
||||
},
|
||||
schema: configSchema,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue