[Maps] avoid using MAP_SAVED_OBJECT_TYPE constant when defining URL paths (#69723)
* [Maps] avoid using MAP_SAVED_OBJECT_TYPE constant when defining URL paths * rename methods Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
0465e86bf3
commit
be3886b77f
|
@ -26,14 +26,17 @@ export const MAP_SAVED_OBJECT_TYPE = 'map';
|
|||
export const APP_ID = 'maps';
|
||||
export const APP_ICON = 'gisApp';
|
||||
|
||||
export const MAP_APP_PATH = `app/${APP_ID}`;
|
||||
export const MAPS_APP_PATH = `app/${APP_ID}`;
|
||||
export const MAP_PATH = 'map';
|
||||
export const GIS_API_PATH = `api/${APP_ID}`;
|
||||
export const INDEX_SETTINGS_API_PATH = `${GIS_API_PATH}/indexSettings`;
|
||||
export const FONTS_API_PATH = `${GIS_API_PATH}/fonts`;
|
||||
|
||||
export const MAP_BASE_URL = `/${MAP_APP_PATH}/${MAP_SAVED_OBJECT_TYPE}`;
|
||||
|
||||
export function createMapPath(id: string) {
|
||||
const MAP_BASE_URL = `/${MAPS_APP_PATH}/${MAP_PATH}`;
|
||||
export function getNewMapPath() {
|
||||
return MAP_BASE_URL;
|
||||
}
|
||||
export function getExistingMapPath(id: string) {
|
||||
return `${MAP_BASE_URL}/${id}`;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
IContainer,
|
||||
} from '../../../../../src/plugins/embeddable/public';
|
||||
import '../index.scss';
|
||||
import { createMapPath, MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants';
|
||||
import { getExistingMapPath, MAP_SAVED_OBJECT_TYPE, APP_ICON } from '../../common/constants';
|
||||
import { LayerDescriptor } from '../../common/descriptor_types';
|
||||
import { MapEmbeddableInput } from './types';
|
||||
import { lazyLoadMapModules } from '../lazy_load_bundle';
|
||||
|
@ -113,7 +113,7 @@ export class MapEmbeddableFactory implements EmbeddableFactoryDefinition {
|
|||
{
|
||||
layerList,
|
||||
title: savedMap.title,
|
||||
editUrl: getHttp().basePath.prepend(createMapPath(savedObjectId)),
|
||||
editUrl: getHttp().basePath.prepend(getExistingMapPath(savedObjectId)),
|
||||
indexPatterns,
|
||||
editable: await this.isEditable(),
|
||||
settings,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE } from '../common/constants';
|
||||
import { APP_ID, APP_ICON, MAP_PATH } from '../common/constants';
|
||||
import { getShowMapVisualizationTypes, getVisualizations } from './kibana_services';
|
||||
|
||||
export function getMapsVisTypeAlias() {
|
||||
|
@ -28,7 +28,7 @@ The Maps app offers more functionality and is easier to use.`,
|
|||
|
||||
return {
|
||||
aliasApp: APP_ID,
|
||||
aliasPath: `/${MAP_SAVED_OBJECT_TYPE}`,
|
||||
aliasPath: `/${MAP_PATH}`,
|
||||
name: APP_ID,
|
||||
title: i18n.translate('xpack.maps.visTypeAlias.title', {
|
||||
defaultMessage: 'Maps',
|
||||
|
|
|
@ -19,7 +19,7 @@ import {
|
|||
import { getIsLayerTOCOpen, getOpenTOCDetails } from '../../../selectors/ui_selectors';
|
||||
import { copyPersistentState } from '../../../reducers/util';
|
||||
import { extractReferences, injectReferences } from '../../../../common/migrations/references';
|
||||
import { MAP_BASE_URL, MAP_SAVED_OBJECT_TYPE } from '../../../../common/constants';
|
||||
import { getExistingMapPath, MAP_SAVED_OBJECT_TYPE } from '../../../../common/constants';
|
||||
import { getStore } from '../../store_operations';
|
||||
|
||||
export function createSavedGisMapClass(services) {
|
||||
|
@ -76,7 +76,7 @@ export function createSavedGisMapClass(services) {
|
|||
}
|
||||
|
||||
getFullPath() {
|
||||
return `${MAP_BASE_URL}/${this.id}`;
|
||||
return getExistingMapPath(this.id);
|
||||
}
|
||||
|
||||
getLayerList() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { getCoreChrome } from '../../kibana_services';
|
||||
import { MAP_SAVED_OBJECT_TYPE } from '../../../common/constants';
|
||||
import { MAP_PATH } from '../../../common/constants';
|
||||
import _ from 'lodash';
|
||||
import { getLayerListRaw } from '../../selectors/map_selectors';
|
||||
import { copyPersistentState } from '../../reducers/util';
|
||||
|
@ -31,7 +31,7 @@ function hasUnsavedChanges(savedMap, initialLayerListConfig) {
|
|||
}
|
||||
|
||||
export const updateBreadcrumbs = (savedMap, initialLayerListConfig, currentPath = '') => {
|
||||
const isOnMapNow = currentPath.startsWith(`/${MAP_SAVED_OBJECT_TYPE}`);
|
||||
const isOnMapNow = currentPath.startsWith(`/${MAP_PATH}`);
|
||||
const breadCrumbs = isOnMapNow
|
||||
? [
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@ import { getFlightsSavedObjects } from './sample_data/flights_saved_objects.js';
|
|||
// @ts-ignore
|
||||
import { getWebLogsSavedObjects } from './sample_data/web_logs_saved_objects.js';
|
||||
import { registerMapsUsageCollector } from './maps_telemetry/collectors/register';
|
||||
import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE, createMapPath } from '../common/constants';
|
||||
import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE, getExistingMapPath } from '../common/constants';
|
||||
import { mapSavedObjects } from './saved_objects';
|
||||
import { MapsXPackConfig } from '../config';
|
||||
// @ts-ignore
|
||||
|
@ -58,7 +58,7 @@ export class MapsPlugin implements Plugin {
|
|||
|
||||
home.sampleData.addAppLinksToSampleDataset('ecommerce', [
|
||||
{
|
||||
path: createMapPath('2c9c1f60-1909-11e9-919b-ffe5949a18d2'),
|
||||
path: getExistingMapPath('2c9c1f60-1909-11e9-919b-ffe5949a18d2'),
|
||||
label: sampleDataLinkLabel,
|
||||
icon: APP_ICON,
|
||||
},
|
||||
|
@ -80,7 +80,7 @@ export class MapsPlugin implements Plugin {
|
|||
|
||||
home.sampleData.addAppLinksToSampleDataset('flights', [
|
||||
{
|
||||
path: createMapPath('5dd88580-1906-11e9-919b-ffe5949a18d2'),
|
||||
path: getExistingMapPath('5dd88580-1906-11e9-919b-ffe5949a18d2'),
|
||||
label: sampleDataLinkLabel,
|
||||
icon: APP_ICON,
|
||||
},
|
||||
|
@ -101,7 +101,7 @@ export class MapsPlugin implements Plugin {
|
|||
home.sampleData.addSavedObjectsToSampleDataset('logs', getWebLogsSavedObjects());
|
||||
home.sampleData.addAppLinksToSampleDataset('logs', [
|
||||
{
|
||||
path: createMapPath('de71f4f0-1902-11e9-919b-ffe5949a18d2'),
|
||||
path: getExistingMapPath('de71f4f0-1902-11e9-919b-ffe5949a18d2'),
|
||||
label: sampleDataLinkLabel,
|
||||
icon: APP_ICON,
|
||||
},
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { SavedObjectsType } from 'src/core/server';
|
||||
import { APP_ICON, createMapPath } from '../../common/constants';
|
||||
import { APP_ICON, getExistingMapPath } from '../../common/constants';
|
||||
// @ts-ignore
|
||||
import { migrations } from './migrations';
|
||||
|
||||
|
@ -31,7 +31,7 @@ export const mapSavedObjects: SavedObjectsType = {
|
|||
},
|
||||
getInAppUrl(obj) {
|
||||
return {
|
||||
path: createMapPath(obj.id),
|
||||
path: getExistingMapPath(obj.id),
|
||||
uiCapabilitiesPath: 'maps.show',
|
||||
};
|
||||
},
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { TutorialsCategory } from '../../../../../../src/plugins/home/server';
|
||||
import { MAP_BASE_URL } from '../../../common/constants';
|
||||
import { getNewMapPath } from '../../../common/constants';
|
||||
|
||||
export function emsBoundariesSpecProvider({
|
||||
emsLandingPageUrl,
|
||||
|
@ -64,7 +64,7 @@ Indexing EMS administrative boundaries in Elasticsearch allows for search on bou
|
|||
2. Click `Add layer`, then select `Upload GeoJSON`.\n\
|
||||
3. Upload the GeoJSON file and click `Import file`.',
|
||||
values: {
|
||||
newMapUrl: prependBasePath(MAP_BASE_URL),
|
||||
newMapUrl: prependBasePath(getNewMapPath()),
|
||||
},
|
||||
}),
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue