-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
19 changed files
with
521 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 { resolve } from 'path'; | ||
import { Legacy } from 'kibana'; | ||
|
||
import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types'; | ||
|
||
const vegaPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => | ||
new Plugin({ | ||
id: 'vega', | ||
require: ['kibana', 'elasticsearch', 'visualizations', 'interpreter', 'data'], | ||
publicDir: resolve(__dirname, 'public'), | ||
uiExports: { | ||
styleSheetPaths: resolve(__dirname, 'public/index.scss'), | ||
hacks: [resolve(__dirname, 'public/legacy')], | ||
injectDefaultVars: server => ({ | ||
enableExternalUrls: server.config().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 | ||
export default vegaPluginInitializer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from './vega_config_provider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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 { npSetup, npStart } from 'ui/new_platform'; | ||
|
||
import { visualizations } from '../../visualizations/public'; | ||
import { VegaPluginSetupDependencies } from './plugin'; | ||
import { LegacyDependenciesPlugin } from './shim'; | ||
import { plugin } from '.'; | ||
|
||
const plugins: Readonly<VegaPluginSetupDependencies> = { | ||
visualizations, | ||
data: npSetup.plugins.data, | ||
|
||
// Temporary solution | ||
// It will be removed when all dependent services are migrated to the new platform. | ||
__LEGACY: new LegacyDependenciesPlugin(), | ||
}; | ||
|
||
const pluginInstance = plugin({} as PluginInitializerContext); | ||
|
||
export const setup = pluginInstance.setup(npSetup.core, plugins); | ||
export const start = pluginInstance.start(npStart.core); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* 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, | ||
CoreSetup, | ||
CoreStart, | ||
Plugin, | ||
UiSettingsClientContract, | ||
} from '../../../../core/public'; | ||
import { LegacyDependenciesPlugin, LegacyDependenciesPluginSetup } from './shim'; | ||
|
||
// @ts-ignore | ||
import { createVegaFn } from './vega_fn'; | ||
// @ts-ignore | ||
import { createVegaTypeDefinition } from './vega_type'; | ||
import { DataSetup } from '../../data/public'; | ||
import { VisualizationsSetup } from '../../visualizations/public'; | ||
|
||
/** @private */ | ||
interface VegaVisualizationDependencies extends LegacyDependenciesPluginSetup { | ||
uiSettings: UiSettingsClientContract; | ||
} | ||
|
||
/** @internal */ | ||
export interface VegaPluginSetupDependencies { | ||
// TODO: Remove `any` as functionsRegistry will be added to the DataSetup. | ||
data: DataSetup | any; | ||
visualizations: VisualizationsSetup; | ||
__LEGACY: LegacyDependenciesPlugin; | ||
} | ||
|
||
/** @internal */ | ||
export class VegaPlugin implements Plugin<Promise<void>, void> { | ||
initializerContext: PluginInitializerContext; | ||
|
||
constructor(initializerContext: PluginInitializerContext) { | ||
this.initializerContext = initializerContext; | ||
} | ||
|
||
public async setup( | ||
core: CoreSetup, | ||
{ data, visualizations, __LEGACY }: VegaPluginSetupDependencies | ||
) { | ||
const visualizationDependencies: Readonly<VegaVisualizationDependencies> = { | ||
uiSettings: core.uiSettings, | ||
...(await __LEGACY.setup()), | ||
}; | ||
|
||
data.expressions.registerFunction(() => createVegaFn(visualizationDependencies)); | ||
|
||
visualizations.types.VisTypesRegistryProvider.register(() => | ||
createVegaTypeDefinition(visualizationDependencies) | ||
); | ||
} | ||
|
||
public start(core: CoreStart) { | ||
// nothing to do here yet | ||
} | ||
} |
Oops, something went wrong.