Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rename] region-maps #126

Merged
merged 1 commit into from
Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/plugins/region_map/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

import { schema, TypeOf } from '@kbn/config-schema';
import { schema, TypeOf } from '@osd/config-schema';

export const configSchema = schema.object({
includeElasticMapsService: schema.boolean({ defaultValue: true }),
includeOpenSearchMapsService: schema.boolean({ defaultValue: true }),
layers: schema.arrayOf(
schema.object({
url: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"id": "regionMap",
"version": "8.0.0",
"kibanaVersion": "kibana",
"opensearchDashboardsVersion": "opensearchDashboards",
"configPath": ["map", "regionmap"],
"ui": true,
"server": true,
"requiredPlugins": [
"visualizations",
"expressions",
"mapsLegacy",
"kibanaLegacy",
"opensearchDashboardsLegacy",
"data",
"share"
],
"requiredBundles": [
"kibanaUtils",
"opensearchDashboardsUtils",
"charts",
"visDefaultEditor"
]
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/region_map/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "region_map",
"version": "kibana"
"version": "opensearchDashboards"
}
22 changes: 11 additions & 11 deletions src/plugins/region_map/public/choropleth_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import $ from 'jquery';
import _ from 'lodash';
import d3 from 'd3';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import * as topojson from 'topojson-client';
import { getNotifications } from './kibana_services';
import { colorUtil, KibanaMapLayer } from '../../maps_legacy/public';
import { getNotifications } from './opensearch_dashboards_services';
import { colorUtil, OpensearchDashboardsMapLayer } from '../../maps_legacy/public';
import { truncatedColorMaps } from '../../charts/public';

const EMPTY_STYLE = {
Expand All @@ -33,19 +33,19 @@ const EMPTY_STYLE = {
fillOpacity: 0,
};

export class ChoroplethLayer extends KibanaMapLayer {
export class ChoroplethLayer extends OpensearchDashboardsMapLayer {
static _doInnerJoin(sortedMetrics, sortedGeojsonFeatures, joinField) {
let j = 0;
for (let i = 0; i < sortedGeojsonFeatures.length; i++) {
const property = sortedGeojsonFeatures[i].properties[joinField];
sortedGeojsonFeatures[i].__kbnJoinedMetric = null;
sortedGeojsonFeatures[i].__osdJoinedMetric = null;
const position = sortedMetrics.length
? compareLexicographically(property, sortedMetrics[j].term)
: -1;
if (position === -1) {
//just need to cycle on
} else if (position === 0) {
sortedGeojsonFeatures[i].__kbnJoinedMetric = sortedMetrics[j];
sortedGeojsonFeatures[i].__osdJoinedMetric = sortedMetrics[j];
} else if (position === 1) {
//needs to catch up
while (j < sortedMetrics.length) {
Expand All @@ -54,7 +54,7 @@ export class ChoroplethLayer extends KibanaMapLayer {
if (newPosition === -1) {
//not far enough
} else if (newPosition === 0) {
sortedGeojsonFeatures[i].__kbnJoinedMetric = sortedMetrics[j];
sortedGeojsonFeatures[i].__osdJoinedMetric = sortedMetrics[j];
break;
} else if (newPosition === 1) {
//too far!
Expand Down Expand Up @@ -186,7 +186,7 @@ Make sure the file exists at that location.",
{
defaultMessage:
'Cannot download {name} file. Please ensure the \
CORS configuration of the server permits requests from the Kibana application on this host.',
CORS configuration of the server permits requests from the OpenSearch Dashboards application on this host.',
values: { name: name },
}
);
Expand Down Expand Up @@ -231,7 +231,7 @@ CORS configuration of the server permits requests from the Kibana application on
if (!this._showAllShapes) {
const featureCollection = {
type: 'FeatureCollection',
features: this._sortedFeatures.filter((feature) => feature.__kbnJoinedMetric),
features: this._sortedFeatures.filter((feature) => feature.__osdJoinedMetric),
};
this._leafletLayer.addData(featureCollection);
}
Expand Down Expand Up @@ -440,7 +440,7 @@ CORS configuration of the server permits requests from the Kibana application on
const boundsOfAllFeatures = new this._leaflet.LatLngBounds();
return {
leafletStyleFunction: (geojsonFeature) => {
const match = geojsonFeature.__kbnJoinedMetric;
const match = geojsonFeature.__osdJoinedMetric;
if (!match) {
return emptyStyle();
}
Expand All @@ -463,7 +463,7 @@ CORS configuration of the server permits requests from the Kibana application on
getMismatches: () => {
const mismatches = this._metrics.slice();
this._sortedFeatures.forEach((feature) => {
const index = mismatches.indexOf(feature.__kbnJoinedMetric);
const index = mismatches.indexOf(feature.__osdJoinedMetric);
if (index >= 0) {
mismatches.splice(index, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import React, { useCallback, useMemo } from 'react';
import { EuiIcon, EuiLink, EuiPanel, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@osd/i18n';
import { FormattedMessage } from '@osd/i18n/react';
import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
import { FileLayerField, VectorLayer, IServiceSettings } from '../../../maps_legacy/public';
import { NumberInputOption, SelectOption, SwitchOption } from '../../../charts/public';
Expand Down Expand Up @@ -111,7 +111,7 @@ function RegionMapOptions(props: RegionMapOptionsProps) {
href={stateParams.emsHotLink}
target="_blank"
title={i18n.translate('regionMap.visParams.previewOnEMSLinkTitle', {
defaultMessage: 'Preview {selectedLayerName} on the Elastic Maps Service',
defaultMessage: 'Preview {selectedLayerName} on the OpenSearch Maps Service',
values: {
selectedLayerName:
stateParams.selectedLayer && stateParams.selectedLayer.name,
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/region_map/public/get_deprecation_message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import React from 'react';
import { UrlGeneratorContract } from 'src/plugins/share/public';
import { getCoreService, getQueryService, getShareService } from './kibana_services';
import { getCoreService, getQueryService, getShareService } from './opensearch_dashboards_services';
import { Vis } from '../../visualizations/public';
import { LegacyMapDeprecationMessage } from '../../maps_legacy/public';

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/region_map/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/

import { PluginInitializerContext } from 'kibana/public';
import { PluginInitializerContext } from 'opensearch-dashboards/public';
import { RegionMapPlugin as Plugin } from './plugin';

export interface RegionMapsConfigType {
includeElasticMapsService: boolean;
includeOpenSearchMapsService: boolean;
layers: any[];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/

import { CoreStart } from 'kibana/public';
import { NotificationsStart } from 'kibana/public';
import { createGetterSetter } from '../../kibana_utils/public';
import { CoreStart } from 'opensearch-dashboards/public';
import { NotificationsStart } from 'opensearch-dashboards/public';
import { createGetterSetter } from '../../opensearch_dashboards_utils/public';
import { DataPublicPluginStart } from '../../data/public';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { OpenSearchDashboardsLegacyStart } from '../../opensearch_dashboards_legacy/public';
import { SharePluginStart } from '../../share/public';

export const [getCoreService, setCoreService] = createGetterSetter<CoreStart>('Core');
Expand All @@ -40,6 +40,6 @@ export const [getQueryService, setQueryService] = createGetterSetter<

export const [getShareService, setShareService] = createGetterSetter<SharePluginStart>('Share');

export const [getKibanaLegacy, setKibanaLegacy] = createGetterSetter<KibanaLegacyStart>(
'KibanaLegacy'
export const [getOpenSearchDashboardsLegacy, setOpenSearchDashboardsLegacy] = createGetterSetter<OpenSearchDashboardsLegacyStart>(
'OpenSearchDashboardsLegacy'
);
14 changes: 7 additions & 7 deletions src/plugins/region_map/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
PluginInitializerContext,
IUiSettingsClient,
NotificationsStart,
} from 'kibana/public';
} from 'opensearch-dashboards/public';
import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public';
import { VisualizationsSetup } from '../../visualizations/public';
// @ts-ignore
Expand All @@ -35,14 +35,14 @@ import {
setCoreService,
setFormatService,
setNotifications,
setKibanaLegacy,
setOpenSearchDashboardsLegacy,
setQueryService,
setShareService,
} from './kibana_services';
} from './opensearch_dashboards_services';
import { DataPublicPluginStart } from '../../data/public';
import { RegionMapsConfigType } from './index';
import { MapsLegacyConfig } from '../../maps_legacy/config';
import { KibanaLegacyStart } from '../../kibana_legacy/public';
import { OpenSearchDashboardsLegacyStart } from '../../opensearch_dashboards_legacy/public';
import { SharePluginStart } from '../../share/public';

/** @private */
Expand All @@ -64,13 +64,13 @@ export interface RegionMapPluginSetupDependencies {
export interface RegionMapPluginStartDependencies {
data: DataPublicPluginStart;
notifications: NotificationsStart;
kibanaLegacy: KibanaLegacyStart;
opensearchDashboardsLegacy: OpenSearchDashboardsLegacyStart;
share: SharePluginStart;
}

/** @internal */
export interface RegionMapsConfig {
includeElasticMapsService: boolean;
includeOpenSearchMapsService: boolean;
layers: any[];
}

Expand Down Expand Up @@ -122,7 +122,7 @@ export class RegionMapPlugin implements Plugin<RegionMapPluginSetup, RegionMapPl
setFormatService(plugins.data.fieldFormats);
setQueryService(plugins.data.query);
setNotifications(core.notifications);
setKibanaLegacy(plugins.kibanaLegacy);
setOpenSearchDashboardsLegacy(plugins.opensearchDashboardsLegacy);
setShareService(plugins.share);
return {};
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/region_map/public/region_map_fn.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';

export const createRegionMapFn = () => ({
name: 'regionmap',
type: 'render',
context: {
types: ['kibana_datatable'],
types: ['opensearch_dashboards_datatable'],
},
help: i18n.translate('regionMap.function.help', {
defaultMessage: 'Regionmap visualization',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/region_map/public/region_map_fn.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { createRegionMapFn } from './region_map_fn';
describe('interpreter/functions#regionmap', () => {
const fn = functionWrapper(createRegionMapFn());
const context = {
type: 'kibana_datatable',
type: 'opensearch_dashboards_datatable',
rows: [{ 'col-0-1': 0 }],
columns: [{ id: 'col-0-1', name: 'Count' }],
};
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/region_map/public/region_map_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { i18n } from '@kbn/i18n';
import { i18n } from '@osd/i18n';
import { mapToLayerWithId } from './util';
import { createRegionMapVisualization } from './region_map_visualization';
import { RegionMapOptions } from './components/region_map_options';
Expand Down Expand Up @@ -109,11 +109,11 @@ provided base maps, or add your own. Darker colors represent higher values.',
}

const vectorLayers = regionmapsConfig.layers.map(
mapToLayerWithId.bind(null, ORIGIN.KIBANA_YML)
mapToLayerWithId.bind(null, ORIGIN.OPENSEARCH_DASHBOARDS_YML)
);
let selectedLayer = vectorLayers[0];
let selectedJoinField = selectedLayer ? selectedLayer.fields[0] : null;
if (regionmapsConfig.includeElasticMapsService) {
if (regionmapsConfig.includeOpenSearchMapsService) {
const layers = await serviceSettings.getFileLayers();
const newLayers = layers
.map(mapToLayerWithId.bind(null, ORIGIN.EMS))
Expand Down
18 changes: 9 additions & 9 deletions src/plugins/region_map/public/region_map_visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { getFormatService, getNotifications, getKibanaLegacy } from './kibana_services';
import { i18n } from '@osd/i18n';
import { getFormatService, getNotifications, getOpenSearchDashboardsLegacy } from './opensearch_dashboards_services';
import { truncatedColorMaps } from '../../charts/public';
import { tooltipFormatter } from './tooltip_formatter';
import { mapTooltipProvider, ORIGIN, lazyLoadMapsLegacyModules } from '../../maps_legacy/public';
Expand All @@ -37,9 +37,9 @@ export function createRegionMapVisualization({
this._tooltipFormatter = mapTooltipProvider(container, tooltipFormatter);
}

async render(esResponse, visParams) {
getKibanaLegacy().loadFontAwesome();
await super.render(esResponse, visParams);
async render(opensearchResponse, visParams) {
getOpenSearchDashboardsLegacy().loadFontAwesome();
await super.render(opensearchResponse, visParams);
if (this._choroplethLayer) {
await this._choroplethLayer.whenDataLoaded();
}
Expand Down Expand Up @@ -88,7 +88,7 @@ export function createRegionMapVisualization({
);
}

this._kibanaMap.useUiStateFromVisualization(this._vis);
this._opensearchDashboardsMap.useUiStateFromVisualization(this._vis);
}

async _loadConfig(fileLayerConfig) {
Expand All @@ -106,7 +106,7 @@ export function createRegionMapVisualization({
return await serviceSettings.loadFileLayerConfig(fileLayerConfig);
}

//Configured in the kibana.yml. Needs to be resolved through the settings.
//Configured in the opensearch_dashboards.yml. Needs to be resolved through the settings.
const configuredLayer = regionmapsConfig.layers.find(
(layer) => layer.name === fileLayerConfig.name
);
Expand Down Expand Up @@ -171,7 +171,7 @@ export function createRegionMapVisualization({

async _recreateChoroplethLayer(name, attribution, showAllData) {
const selectedLayer = await this._loadConfig(this._params.selectedLayer);
this._kibanaMap.removeLayer(this._choroplethLayer);
this._opensearchDashboardsMap.removeLayer(this._choroplethLayer);

if (this._choroplethLayer) {
this._choroplethLayer = this._choroplethLayer.cloneChoroplethLayerForNewData(
Expand Down Expand Up @@ -233,7 +233,7 @@ export function createRegionMapVisualization({
}
});

this._kibanaMap.addLayer(this._choroplethLayer);
this._opensearchDashboardsMap.addLayer(this._choroplethLayer);
}

_hasColumns() {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/region_map/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* under the License.
*/

import { PluginConfigDescriptor } from 'kibana/server';
import { PluginConfigDescriptor } from 'opensearch-dashboards/server';
import { CoreSetup } from 'src/core/server';
import { configSchema, ConfigSchema } from '../config';
import { getUiSettings } from './ui_settings';

export const config: PluginConfigDescriptor<ConfigSchema> = {
exposeToBrowser: {
includeElasticMapsService: true,
includeOpenSearchMapsService: true,
layers: true,
},
schema: configSchema,
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/region_map/server/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { UiSettingsParams } from 'kibana/server';
import { schema } from '@kbn/config-schema';
import { i18n } from '@osd/i18n';
import { UiSettingsParams } from 'opensearch-dashboards/server';
import { schema } from '@osd/config-schema';

export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
return {
Expand Down