Skip to content

Commit

Permalink
Migrate legacy map UI settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Aug 25, 2020
1 parent 1e8c05f commit f817dbc
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 85 deletions.
83 changes: 1 addition & 82 deletions src/legacy/core_plugins/kibana/server/ui_setting_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,88 +17,7 @@
* under the License.
*/

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

export function getUiSettingDefaults() {
// wrapped in provider so that a new instance is given to each app/test
return {
'visualization:tileMap:maxPrecision': {
name: i18n.translate('kbn.advancedSettings.visualization.tileMap.maxPrecisionTitle', {
defaultMessage: 'Maximum tile map precision',
}),
value: 7,
description: i18n.translate('kbn.advancedSettings.visualization.tileMap.maxPrecisionText', {
defaultMessage:
'The maximum geoHash precision displayed on tile maps: 7 is high, 10 is very high, 12 is the max. {cellDimensionsLink}',
description:
'Part of composite text: kbn.advancedSettings.visualization.tileMap.maxPrecisionText + ' +
'kbn.advancedSettings.visualization.tileMap.maxPrecision.cellDimensionsLinkText',
values: {
cellDimensionsLink:
`<a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html#_cell_dimensions_at_the_equator"
target="_blank" rel="noopener">` +
i18n.translate(
'kbn.advancedSettings.visualization.tileMap.maxPrecision.cellDimensionsLinkText',
{
defaultMessage: 'Explanation of cell dimensions',
}
) +
'</a>',
},
}),
category: ['visualization'],
},
'visualization:tileMap:WMSdefaults': {
name: i18n.translate('kbn.advancedSettings.visualization.tileMap.wmsDefaultsTitle', {
defaultMessage: 'Default WMS properties',
}),
value: JSON.stringify(
{
enabled: false,
url: undefined,
options: {
version: undefined,
layers: undefined,
format: 'image/png',
transparent: true,
attribution: undefined,
styles: undefined,
},
},
null,
2
),
type: 'json',
description: i18n.translate('kbn.advancedSettings.visualization.tileMap.wmsDefaultsText', {
defaultMessage:
'Default {propertiesLink} for the WMS map server support in the coordinate map',
description:
'Part of composite text: kbn.advancedSettings.visualization.tileMap.wmsDefaultsText + ' +
'kbn.advancedSettings.visualization.tileMap.wmsDefaults.propertiesLinkText',
values: {
propertiesLink:
'<a href="http://leafletjs.com/reference.html#tilelayer-wms" target="_blank" rel="noopener noreferrer">' +
i18n.translate(
'kbn.advancedSettings.visualization.tileMap.wmsDefaults.propertiesLinkText',
{
defaultMessage: 'properties',
}
) +
'</a>',
},
}),
category: ['visualization'],
},
'visualization:regionmap:showWarnings': {
name: i18n.translate('kbn.advancedSettings.visualization.showRegionMapWarningsTitle', {
defaultMessage: 'Show region map warning',
}),
value: true,
description: i18n.translate('kbn.advancedSettings.visualization.showRegionMapWarningsText', {
defaultMessage:
'Whether the region map shows a warning when terms cannot be joined to a shape on the map.',
}),
category: ['visualization'],
},
};
return {};
}
7 changes: 5 additions & 2 deletions src/plugins/maps_legacy/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/

import { Plugin, PluginConfigDescriptor } from 'kibana/server';
import { PluginInitializerContext } from 'src/core/server';
import { CoreSetup, PluginInitializerContext } from 'src/core/server';
import { Observable } from 'rxjs';
import { configSchema, ConfigSchema } from '../config';
import { getUiSettings } from './ui_settings';

export const config: PluginConfigDescriptor<ConfigSchema> = {
exposeToBrowser: {
Expand Down Expand Up @@ -49,7 +50,9 @@ export class MapsLegacyPlugin implements Plugin<MapsLegacyPluginSetup> {
this._initializerContext = initializerContext;
}

public setup() {
public setup(core: CoreSetup) {
core.uiSettings.register(getUiSettings());

// @ts-ignore
const config$ = this._initializerContext.config.create();
return {
Expand Down
113 changes: 113 additions & 0 deletions src/plugins/maps_legacy/server/ui_settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { UiSettingsParams } from 'kibana/server';
import { schema } from '@kbn/config-schema';

export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
return {
'visualization:tileMap:maxPrecision': {
name: i18n.translate('mapsLegacy.advancedSettings.visualization.tileMap.maxPrecisionTitle', {
defaultMessage: 'Maximum tile map precision',
}),
value: 7,
description: i18n.translate(
'mapsLegacy.advancedSettings.visualization.tileMap.maxPrecisionText',
{
defaultMessage:
'The maximum geoHash precision displayed on tile maps: 7 is high, 10 is very high, 12 is the max. {cellDimensionsLink}',
description:
'Part of composite text: mapsLegacy.advancedSettings.visualization.tileMap.maxPrecisionText + ' +
'mapsLegacy.advancedSettings.visualization.tileMap.maxPrecision.cellDimensionsLinkText',
values: {
cellDimensionsLink:
`<a href="http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html#_cell_dimensions_at_the_equator"
target="_blank" rel="noopener">` +
i18n.translate(
'mapsLegacy.advancedSettings.visualization.tileMap.maxPrecision.cellDimensionsLinkText',
{
defaultMessage: 'Explanation of cell dimensions',
}
) +
'</a>',
},
}
),
schema: schema.number(),
category: ['visualization'],
},
'visualization:tileMap:WMSdefaults': {
name: i18n.translate('mapsLegacy.advancedSettings.visualization.tileMap.wmsDefaultsTitle', {
defaultMessage: 'Default WMS properties',
}),
value: JSON.stringify(
{
enabled: false,
url: '',
options: {
version: '',
layers: '',
format: 'image/png',
transparent: true,
attribution: '',
styles: '',
},
},
null,
2
),
type: 'json',
description: i18n.translate(
'mapsLegacy.advancedSettings.visualization.tileMap.wmsDefaultsText',
{
defaultMessage:
'Default {propertiesLink} for the WMS map server support in the coordinate map',
description:
'Part of composite text: mapsLegacy.advancedSettings.visualization.tileMap.wmsDefaultsText + ' +
'mapsLegacy.advancedSettings.visualization.tileMap.wmsDefaults.propertiesLinkText',
values: {
propertiesLink:
'<a href="http://leafletjs.com/reference.html#tilelayer-wms" target="_blank" rel="noopener noreferrer">' +
i18n.translate(
'mapsLegacy.advancedSettings.visualization.tileMap.wmsDefaults.propertiesLinkText',
{
defaultMessage: 'properties',
}
) +
'</a>',
},
}
),
schema: schema.object({
enabled: schema.boolean(),
url: schema.string(),
options: schema.object({
version: schema.string(),
layers: schema.string(),
format: schema.string(),
transparent: schema.boolean(),
attribution: schema.string(),
styles: schema.string(),
}),
}),
category: ['visualization'],
},
};
}
7 changes: 6 additions & 1 deletion src/plugins/region_map/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
*/

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

export const config: PluginConfigDescriptor<ConfigSchema> = {
exposeToBrowser: {
Expand All @@ -29,6 +31,9 @@ export const config: PluginConfigDescriptor<ConfigSchema> = {
};

export const plugin = () => ({
setup() {},
setup(core: CoreSetup) {
core.uiSettings.register(getUiSettings());
},

start() {},
});
42 changes: 42 additions & 0 deletions src/plugins/region_map/server/ui_settings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 { i18n } from '@kbn/i18n';
import { UiSettingsParams } from 'kibana/server';
import { schema } from '@kbn/config-schema';

export function getUiSettings(): Record<string, UiSettingsParams<unknown>> {
return {
'visualization:regionmap:showWarnings': {
name: i18n.translate('regionMap.advancedSettings.visualization.showRegionMapWarningsTitle', {
defaultMessage: 'Show region map warning',
}),
value: true,
description: i18n.translate(
'regionMap.advancedSettings.visualization.showRegionMapWarningsText',
{
defaultMessage:
'Whether the region map shows a warning when terms cannot be joined to a shape on the map.',
}
),
schema: schema.boolean(),
category: ['visualization'],
},
};
}

0 comments on commit f817dbc

Please sign in to comment.