-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tile Map] Shim new Platform (#41265)
* [Table Vis] Shim new platform * cleanup * Set the correct type for the "Data" dependency
- Loading branch information
Showing
17 changed files
with
334 additions
and
94 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,51 @@ | ||
/* | ||
* 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'; | ||
|
||
// @ts-ignore | ||
import emsClient from './common/ems_client'; | ||
|
||
import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types'; | ||
|
||
const tileMapPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => | ||
new Plugin({ | ||
id: 'tile_map', | ||
require: ['kibana', 'elasticsearch', 'visualizations', 'interpreter', 'data'], | ||
publicDir: resolve(__dirname, 'public'), | ||
uiExports: { | ||
styleSheetPaths: resolve(__dirname, 'public/index.scss'), | ||
hacks: [resolve(__dirname, 'public/legacy')], | ||
injectDefaultVars: server => ({}), | ||
}, | ||
init: (server: Legacy.Server) => { | ||
server.expose({ | ||
ems_client: emsClient, | ||
}); | ||
}, | ||
config(Joi: any) { | ||
return Joi.object({ | ||
enabled: Joi.boolean().default(true), | ||
}).default(); | ||
}, | ||
} as Legacy.PluginSpecOptions); | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default tileMapPluginInitializer; |
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
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 { TileMapPluginSetupDependencies } from './plugin'; | ||
import { LegacyDependenciesPlugin } from './shim'; | ||
import { plugin } from '.'; | ||
|
||
const plugins: Readonly<TileMapPluginSetupDependencies> = { | ||
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 { | ||
CoreSetup, | ||
CoreStart, | ||
Plugin, | ||
PluginInitializerContext, | ||
UiSettingsClientContract, | ||
} from '../../../../core/public'; | ||
import { Plugin as DataPublicPlugin } from '../../../../plugins/data/public'; | ||
import { VisualizationsSetup } from '../../visualizations/public'; | ||
|
||
import { LegacyDependenciesPlugin, LegacyDependenciesPluginSetup } from './shim'; | ||
|
||
// @ts-ignore | ||
import { createTileMapFn } from './tile_map_fn'; | ||
// @ts-ignore | ||
import { createTileMapTypeDefinition } from './tile_map_type'; | ||
|
||
/** @private */ | ||
interface TileMapVisualizationDependencies extends LegacyDependenciesPluginSetup { | ||
uiSettings: UiSettingsClientContract; | ||
} | ||
|
||
/** @internal */ | ||
export interface TileMapPluginSetupDependencies { | ||
data: ReturnType<DataPublicPlugin['setup']>; | ||
visualizations: VisualizationsSetup; | ||
__LEGACY: LegacyDependenciesPlugin; | ||
} | ||
|
||
/** @internal */ | ||
export class TileMapPlugin implements Plugin<Promise<void>, void> { | ||
initializerContext: PluginInitializerContext; | ||
|
||
constructor(initializerContext: PluginInitializerContext) { | ||
this.initializerContext = initializerContext; | ||
} | ||
|
||
public async setup( | ||
core: CoreSetup, | ||
{ data, visualizations, __LEGACY }: TileMapPluginSetupDependencies | ||
) { | ||
const visualizationDependencies: Readonly<TileMapVisualizationDependencies> = { | ||
uiSettings: core.uiSettings, | ||
...(await __LEGACY.setup()), | ||
}; | ||
|
||
data.expressions.registerFunction(() => createTileMapFn(visualizationDependencies)); | ||
|
||
visualizations.types.VisTypesRegistryProvider.register(() => | ||
createTileMapTypeDefinition(visualizationDependencies) | ||
); | ||
} | ||
|
||
public start(core: CoreStart) { | ||
// nothing to do here yet | ||
} | ||
} |
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 './legacy_dependencies_plugin'; |
Oops, something went wrong.