-
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.
* Add new vislib replacement plugin shell * Add config to toggle new vislib replacement
- Loading branch information
1 parent
653c28a
commit 0f117c9
Showing
9 changed files
with
244 additions
and
7 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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,56 @@ | ||
/* | ||
* 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 '../../types'; | ||
|
||
export interface ConfigSchema { | ||
visTypeXy: { | ||
enabled: boolean; | ||
}; | ||
} | ||
|
||
const visTypeXyPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => | ||
new Plugin({ | ||
id: 'visTypeXy', | ||
require: ['kibana', 'elasticsearch', 'visualizations', 'interpreter', 'data'], | ||
publicDir: resolve(__dirname, 'public'), | ||
uiExports: { | ||
hacks: [resolve(__dirname, 'public/legacy')], | ||
injectDefaultVars(server): ConfigSchema { | ||
const config = server.config(); | ||
|
||
return { | ||
visTypeXy: { | ||
enabled: config.get('visTypeXy.enabled') as boolean, | ||
}, | ||
}; | ||
}, | ||
}, | ||
config(Joi: any) { | ||
return Joi.object({ | ||
enabled: Joi.boolean().default(false), | ||
}).default(); | ||
}, | ||
} as Legacy.PluginSpecOptions); | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default visTypeXyPluginInitializer; |
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,4 @@ | ||
{ | ||
"name": "visTypeXy", | ||
"version": "kibana" | ||
} |
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,25 @@ | ||
/* | ||
* 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 '../../../../core/public'; | ||
import { VisTypeXyPlugin as Plugin } from './plugin'; | ||
|
||
export function plugin(initializerContext: PluginInitializerContext) { | ||
return new Plugin(initializerContext); | ||
} |
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,44 @@ | ||
/* | ||
* 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 { npSetup, npStart } from 'ui/new_platform'; | ||
import { PluginInitializerContext } from 'kibana/public'; | ||
|
||
import { plugin } from '.'; | ||
import { VisTypeXyPluginSetupDependencies, VisTypeXyPluginStartDependencies } from './plugin'; | ||
import { | ||
setup as visualizationsSetup, | ||
start as visualizationsStart, | ||
} from '../../visualizations/public/np_ready/public/legacy'; | ||
|
||
const setupPlugins: Readonly<VisTypeXyPluginSetupDependencies> = { | ||
expressions: npSetup.plugins.expressions, | ||
visualizations: visualizationsSetup, | ||
charts: npSetup.plugins.charts, | ||
}; | ||
|
||
const startPlugins: Readonly<VisTypeXyPluginStartDependencies> = { | ||
expressions: npStart.plugins.expressions, | ||
visualizations: visualizationsStart, | ||
}; | ||
|
||
const pluginInstance = plugin({} as PluginInitializerContext); | ||
|
||
export const setup = pluginInstance.setup(npSetup.core, setupPlugins); | ||
export const start = pluginInstance.start(npStart.core, startPlugins); |
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,82 @@ | ||
/* | ||
* 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 { | ||
CoreSetup, | ||
CoreStart, | ||
Plugin, | ||
IUiSettingsClient, | ||
PluginInitializerContext, | ||
} from 'kibana/public'; | ||
|
||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public'; | ||
import { VisualizationsSetup, VisualizationsStart } from '../../visualizations/public'; | ||
import { ChartsPluginSetup } from '../../../../plugins/charts/public'; | ||
|
||
export interface VisTypeXyDependencies { | ||
uiSettings: IUiSettingsClient; | ||
charts: ChartsPluginSetup; | ||
} | ||
|
||
/** @internal */ | ||
export interface VisTypeXyPluginSetupDependencies { | ||
expressions: ReturnType<ExpressionsPublicPlugin['setup']>; | ||
visualizations: VisualizationsSetup; | ||
charts: ChartsPluginSetup; | ||
} | ||
|
||
/** @internal */ | ||
export interface VisTypeXyPluginStartDependencies { | ||
expressions: ReturnType<ExpressionsPublicPlugin['start']>; | ||
visualizations: VisualizationsStart; | ||
} | ||
|
||
type VisTypeXyCoreSetup = CoreSetup<VisTypeXyPluginStartDependencies>; | ||
|
||
/** @internal */ | ||
export class VisTypeXyPlugin implements Plugin<Promise<void>, void> { | ||
constructor(public initializerContext: PluginInitializerContext) {} | ||
|
||
public async setup( | ||
core: VisTypeXyCoreSetup, | ||
{ expressions, visualizations, charts }: VisTypeXyPluginSetupDependencies | ||
) { | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
'The visTypeXy plugin is enabled\n\n', | ||
'This may negatively alter existing vislib visualization configurations if saved.' | ||
); | ||
const visualizationDependencies: Readonly<VisTypeXyDependencies> = { | ||
uiSettings: core.uiSettings, | ||
charts, | ||
}; | ||
|
||
const visTypeDefinitions: any[] = []; | ||
const visFunctions: any = []; | ||
|
||
visFunctions.forEach((fn: any) => expressions.registerFunction(fn)); | ||
visTypeDefinitions.forEach((vis: any) => | ||
visualizations.types.createBaseVisualization(vis(visualizationDependencies)) | ||
); | ||
} | ||
|
||
public start(core: CoreStart, deps: VisTypeXyPluginStartDependencies) { | ||
// nothing to do here | ||
} | ||
} |