diff --git a/src/plugins/region_map/public/index.ts b/src/plugins/region_map/public/index.ts index 1db83bd56f07..57162e0dc7b8 100644 --- a/src/plugins/region_map/public/index.ts +++ b/src/plugins/region_map/public/index.ts @@ -39,3 +39,6 @@ export interface RegionMapsConfigType { export function plugin(initializerContext: PluginInitializerContext) { return new Plugin(initializerContext); } + +export { RegionMapPluginSetup, RegionMapVisualizationDependencies } from './plugin'; +export { RegionMapOptionsProps } from './components/region_map_options'; diff --git a/src/plugins/region_map/public/plugin.ts b/src/plugins/region_map/public/plugin.ts index 6f340fb337b8..4bfa410d01c9 100644 --- a/src/plugins/region_map/public/plugin.ts +++ b/src/plugins/region_map/public/plugin.ts @@ -58,11 +58,14 @@ import { OpenSearchDashboardsLegacyStart } from '../../opensearch_dashboards_leg import { SharePluginStart } from '../../share/public'; /** @private */ -interface RegionMapVisualizationDependencies { +export interface RegionMapVisualizationDependencies { + http: CoreStart['http']; + notifications: CoreStart['notifications']; uiSettings: IUiSettingsClient; regionmapsConfig: RegionMapsConfig; getServiceSettings: () => Promise; BaseMapsVisualization: any; + additionalOptions: AddImportMapTab[]; } /** @internal */ @@ -88,6 +91,13 @@ export interface RegionMapsConfig { export interface RegionMapPluginSetup { config: any; + addOptionTab: (options: AddImportMapTab) => void; +} + +export interface AddImportMapTab { + name: string; + title: string; + editor: (props: any) => JSX.Element; } // eslint-disable-next-line @typescript-eslint/no-empty-interface export interface RegionMapPluginStart {} @@ -95,9 +105,11 @@ export interface RegionMapPluginStart {} /** @internal */ export class RegionMapPlugin implements Plugin { readonly _initializerContext: PluginInitializerContext; + private additionalOptions: AddImportMapTab[]; constructor(initializerContext: PluginInitializerContext) { this._initializerContext = initializerContext; + this.additionalOptions = []; } public async setup( @@ -112,10 +124,13 @@ export class RegionMapPlugin implements Plugin = { + http: core.http, + notifications: core.notifications, uiSettings: core.uiSettings, regionmapsConfig: config as RegionMapsConfig, getServiceSettings: mapsLegacy.getServiceSettings, BaseMapsVisualization: mapsLegacy.getBaseMapsVis(), + additionalOptions: this.additionalOptions, }; expressions.registerFunction(createRegionMapFn); @@ -126,6 +141,8 @@ export class RegionMapPlugin implements Plugin + this.additionalOptions.push(importMapTabConfig), }; } diff --git a/src/plugins/region_map/public/region_map_type.js b/src/plugins/region_map/public/region_map_type.js index 6331db05e23f..b2ae14cfe40e 100644 --- a/src/plugins/region_map/public/region_map_type.js +++ b/src/plugins/region_map/public/region_map_type.js @@ -38,7 +38,7 @@ import { Schemas } from '../../vis_default_editor/public'; import { ORIGIN } from '../../maps_legacy/public'; export function createRegionMapTypeDefinition(dependencies) { - const { uiSettings, regionmapsConfig, getServiceSettings } = dependencies; + const { uiSettings, regionmapsConfig, getServiceSettings, additionalOptions } = dependencies; const visualization = createRegionMapVisualization(dependencies); return { @@ -66,9 +66,23 @@ provided base maps, or add your own. Darker colors represent higher values.', }, visualization, editorConfig: { - optionsTemplate: (props) => ( - - ), + optionTabs: () => { + return [ + { + name: 'options', + title: i18n.translate( + 'regionMap.mapVis.regionMapEditorConfig.optionTabs.optionsTitle', + { + defaultMessage: 'Layer Options', + } + ), + editor: (props) => ( + + ), + }, + ...additionalOptions, + ]; + }, collections: { colorSchemas: truncatedColorSchemas, vectorLayers: [], diff --git a/src/plugins/vis_default_editor/public/components/sidebar/use_option_tabs.ts b/src/plugins/vis_default_editor/public/components/sidebar/use_option_tabs.ts index 96831e6064c1..72b064999e7c 100644 --- a/src/plugins/vis_default_editor/public/components/sidebar/use_option_tabs.ts +++ b/src/plugins/vis_default_editor/public/components/sidebar/use_option_tabs.ts @@ -67,6 +67,8 @@ export const useOptionTabs = ({ type: visType }: Vis): [OptionTab[], (name: stri editor: visType.editorConfig.optionsTemplate, }, ] + : visType.editorConfig.optionTabs instanceof Function + ? visType.editorConfig.optionTabs() : visType.editorConfig.optionTabs), ]; // set up the first tab as selected