Skip to content

Commit 57d64fb

Browse files
[Maps] avoid using MAP_SAVED_OBJECT_TYPE constant when defining URL paths (#69723) (#70036)
* [Maps] avoid using MAP_SAVED_OBJECT_TYPE constant when defining URL paths * rename methods Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent fed64c8 commit 57d64fb

File tree

8 files changed

+23
-20
lines changed

8 files changed

+23
-20
lines changed

x-pack/plugins/maps/common/constants.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ export const MAP_SAVED_OBJECT_TYPE = 'map';
2626
export const APP_ID = 'maps';
2727
export const APP_ICON = 'gisApp';
2828

29-
export const MAP_APP_PATH = `app/${APP_ID}`;
29+
export const MAPS_APP_PATH = `app/${APP_ID}`;
30+
export const MAP_PATH = 'map';
3031
export const GIS_API_PATH = `api/${APP_ID}`;
3132
export const INDEX_SETTINGS_API_PATH = `${GIS_API_PATH}/indexSettings`;
3233
export const FONTS_API_PATH = `${GIS_API_PATH}/fonts`;
3334

34-
export const MAP_BASE_URL = `/${MAP_APP_PATH}/${MAP_SAVED_OBJECT_TYPE}`;
35-
36-
export function createMapPath(id: string) {
35+
const MAP_BASE_URL = `/${MAPS_APP_PATH}/${MAP_PATH}`;
36+
export function getNewMapPath() {
37+
return MAP_BASE_URL;
38+
}
39+
export function getExistingMapPath(id: string) {
3740
return `${MAP_BASE_URL}/${id}`;
3841
}
3942

x-pack/plugins/maps/public/embeddable/map_embeddable_factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
IContainer,
1313
} from '../../../../../src/plugins/embeddable/public';
1414
import '../index.scss';
15-
import { createMapPath, MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants';
15+
import { getExistingMapPath, MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants';
1616
import { LayerDescriptor } from '../../common/descriptor_types';
1717
import { MapEmbeddableInput } from './types';
1818
import { lazyLoadMapModules } from '../lazy_load_bundle';
@@ -113,7 +113,7 @@ export class MapEmbeddableFactory implements EmbeddableFactoryDefinition {
113113
{
114114
layerList,
115115
title: savedMap.title,
116-
editUrl: getHttp().basePath.prepend(createMapPath(savedObjectId)),
116+
editUrl: getHttp().basePath.prepend(getExistingMapPath(savedObjectId)),
117117
indexPatterns,
118118
editable: await this.isEditable(),
119119
settings,

x-pack/plugins/maps/public/maps_vis_type_alias.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import { i18n } from '@kbn/i18n';
8-
import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE } from '../common/constants';
8+
import { APP_ID, APP_ICON, MAP_PATH } from '../common/constants';
99
import { getShowMapVisualizationTypes, getVisualizations } from './kibana_services';
1010

1111
export function getMapsVisTypeAlias() {
@@ -28,7 +28,7 @@ The Maps app offers more functionality and is easier to use.`,
2828

2929
return {
3030
aliasApp: APP_ID,
31-
aliasPath: `/${MAP_SAVED_OBJECT_TYPE}`,
31+
aliasPath: `/${MAP_PATH}`,
3232
name: APP_ID,
3333
title: i18n.translate('xpack.maps.visTypeAlias.title', {
3434
defaultMessage: 'Maps',

x-pack/plugins/maps/public/routing/bootstrap/services/saved_gis_map.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
import { getIsLayerTOCOpen, getOpenTOCDetails } from '../../../selectors/ui_selectors';
2020
import { copyPersistentState } from '../../../reducers/util';
2121
import { extractReferences, injectReferences } from '../../../../common/migrations/references';
22-
import { MAP_BASE_URL, MAP_SAVED_OBJECT_TYPE } from '../../../../common/constants';
22+
import { getExistingMapPath, MAP_SAVED_OBJECT_TYPE } from '../../../../common/constants';
2323
import { getStore } from '../../store_operations';
2424

2525
export function createSavedGisMapClass(services) {
@@ -76,7 +76,7 @@ export function createSavedGisMapClass(services) {
7676
}
7777

7878
getFullPath() {
79-
return `${MAP_BASE_URL}/${this.id}`;
79+
return getExistingMapPath(this.id);
8080
}
8181

8282
getLayerList() {

x-pack/plugins/maps/public/routing/page_elements/breadcrumbs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { i18n } from '@kbn/i18n';
88
import { getCoreChrome } from '../../kibana_services';
9-
import { MAP_SAVED_OBJECT_TYPE } from '../../../common/constants';
9+
import { MAP_PATH } from '../../../common/constants';
1010
import _ from 'lodash';
1111
import { getLayerListRaw } from '../../selectors/map_selectors';
1212
import { copyPersistentState } from '../../reducers/util';
@@ -31,7 +31,7 @@ function hasUnsavedChanges(savedMap, initialLayerListConfig) {
3131
}
3232

3333
export const updateBreadcrumbs = (savedMap, initialLayerListConfig, currentPath = '') => {
34-
const isOnMapNow = currentPath.startsWith(`/${MAP_SAVED_OBJECT_TYPE}`);
34+
const isOnMapNow = currentPath.startsWith(`/${MAP_PATH}`);
3535
const breadCrumbs = isOnMapNow
3636
? [
3737
{

x-pack/plugins/maps/server/plugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getFlightsSavedObjects } from './sample_data/flights_saved_objects.js';
1414
// @ts-ignore
1515
import { getWebLogsSavedObjects } from './sample_data/web_logs_saved_objects.js';
1616
import { registerMapsUsageCollector } from './maps_telemetry/collectors/register';
17-
import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE, createMapPath } from '../common/constants';
17+
import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE, getExistingMapPath } from '../common/constants';
1818
import { mapSavedObjects } from './saved_objects';
1919
import { MapsXPackConfig } from '../config';
2020
// @ts-ignore
@@ -58,7 +58,7 @@ export class MapsPlugin implements Plugin {
5858

5959
home.sampleData.addAppLinksToSampleDataset('ecommerce', [
6060
{
61-
path: createMapPath('2c9c1f60-1909-11e9-919b-ffe5949a18d2'),
61+
path: getExistingMapPath('2c9c1f60-1909-11e9-919b-ffe5949a18d2'),
6262
label: sampleDataLinkLabel,
6363
icon: APP_ICON,
6464
},
@@ -80,7 +80,7 @@ export class MapsPlugin implements Plugin {
8080

8181
home.sampleData.addAppLinksToSampleDataset('flights', [
8282
{
83-
path: createMapPath('5dd88580-1906-11e9-919b-ffe5949a18d2'),
83+
path: getExistingMapPath('5dd88580-1906-11e9-919b-ffe5949a18d2'),
8484
label: sampleDataLinkLabel,
8585
icon: APP_ICON,
8686
},
@@ -101,7 +101,7 @@ export class MapsPlugin implements Plugin {
101101
home.sampleData.addSavedObjectsToSampleDataset('logs', getWebLogsSavedObjects());
102102
home.sampleData.addAppLinksToSampleDataset('logs', [
103103
{
104-
path: createMapPath('de71f4f0-1902-11e9-919b-ffe5949a18d2'),
104+
path: getExistingMapPath('de71f4f0-1902-11e9-919b-ffe5949a18d2'),
105105
label: sampleDataLinkLabel,
106106
icon: APP_ICON,
107107
},

x-pack/plugins/maps/server/saved_objects/map.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66
import { SavedObjectsType } from 'src/core/server';
7-
import { APP_ICON, createMapPath } from '../../common/constants';
7+
import { APP_ICON, getExistingMapPath } from '../../common/constants';
88
// @ts-ignore
99
import { migrations } from './migrations';
1010

@@ -31,7 +31,7 @@ export const mapSavedObjects: SavedObjectsType = {
3131
},
3232
getInAppUrl(obj) {
3333
return {
34-
path: createMapPath(obj.id),
34+
path: getExistingMapPath(obj.id),
3535
uiCapabilitiesPath: 'maps.show',
3636
};
3737
},

x-pack/plugins/maps/server/tutorials/ems/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { i18n } from '@kbn/i18n';
88
import { TutorialsCategory } from '../../../../../../src/plugins/home/server';
9-
import { MAP_BASE_URL } from '../../../common/constants';
9+
import { getNewMapPath } from '../../../common/constants';
1010

1111
export function emsBoundariesSpecProvider({
1212
emsLandingPageUrl,
@@ -64,7 +64,7 @@ Indexing EMS administrative boundaries in Elasticsearch allows for search on bou
6464
2. Click `Add layer`, then select `Upload GeoJSON`.\n\
6565
3. Upload the GeoJSON file and click `Import file`.',
6666
values: {
67-
newMapUrl: prependBasePath(MAP_BASE_URL),
67+
newMapUrl: prependBasePath(getNewMapPath()),
6868
},
6969
}),
7070
},

0 commit comments

Comments
 (0)