[Maps] remove undefined from map embeddable by_value URL (#102949)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Nathan Reese 2021-06-23 08:45:02 -06:00 committed by GitHub
parent 4fa939d9c9
commit 91295fddd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 19 deletions

View file

@ -58,15 +58,14 @@ export const KBN_IS_CENTROID_FEATURE = '__kbn_is_centroid_feature__';
export const MVT_TOKEN_PARAM_NAME = 'token'; export const MVT_TOKEN_PARAM_NAME = 'token';
const MAP_BASE_URL = `/${MAPS_APP_PATH}/${MAP_PATH}`;
export function getNewMapPath() { export function getNewMapPath() {
return MAP_BASE_URL; return `/${MAPS_APP_PATH}/${MAP_PATH}`;
} }
export function getExistingMapPath(id: string) { export function getFullPath(id: string | undefined) {
return `${MAP_BASE_URL}/${id}`; return `/${MAPS_APP_PATH}${getEditPath(id)}`;
} }
export function getEditPath(id: string) { export function getEditPath(id: string | undefined) {
return `/${MAP_PATH}/${id}`; return id ? `/${MAP_PATH}/${id}` : `/${MAP_PATH}`;
} }
export enum LAYER_TYPE { export enum LAYER_TYPE {

View file

@ -54,9 +54,9 @@ import {
} from '../selectors/map_selectors'; } from '../selectors/map_selectors';
import { import {
APP_ID, APP_ID,
getExistingMapPath, getEditPath,
getFullPath,
MAP_SAVED_OBJECT_TYPE, MAP_SAVED_OBJECT_TYPE,
MAP_PATH,
RawValue, RawValue,
} from '../../common/constants'; } from '../../common/constants';
import { RenderToolTipContent } from '../classes/tooltips/tooltip_property'; import { RenderToolTipContent } from '../classes/tooltips/tooltip_property';
@ -180,13 +180,13 @@ export class MapEmbeddable
: ''; : '';
const input = this.getInput(); const input = this.getInput();
const title = input.hidePanelTitles ? '' : input.title || savedMapTitle; const title = input.hidePanelTitles ? '' : input.title || savedMapTitle;
const savedObjectId = (input as MapByReferenceInput).savedObjectId; const savedObjectId = 'savedObjectId' in input ? input.savedObjectId : undefined;
this.updateOutput({ this.updateOutput({
...this.getOutput(), ...this.getOutput(),
defaultTitle: savedMapTitle, defaultTitle: savedMapTitle,
title, title,
editPath: `/${MAP_PATH}/${savedObjectId}`, editPath: getEditPath(savedObjectId),
editUrl: getHttp().basePath.prepend(getExistingMapPath(savedObjectId)), editUrl: getHttp().basePath.prepend(getFullPath(savedObjectId)),
indexPatterns: await this._getIndexPatterns(), indexPatterns: await this._getIndexPatterns(),
}); });
} }

View file

@ -44,7 +44,7 @@ import { getTopNavConfig } from '../top_nav_config';
import { MapQuery } from '../../../../common/descriptor_types'; import { MapQuery } from '../../../../common/descriptor_types';
import { goToSpecifiedPath } from '../../../render_app'; import { goToSpecifiedPath } from '../../../render_app';
import { MapSavedObjectAttributes } from '../../../../common/map_saved_object_type'; import { MapSavedObjectAttributes } from '../../../../common/map_saved_object_type';
import { getExistingMapPath, APP_ID } from '../../../../common/constants'; import { getFullPath, APP_ID } from '../../../../common/constants';
import { import {
getInitialQuery, getInitialQuery,
getInitialRefreshConfig, getInitialRefreshConfig,
@ -356,7 +356,7 @@ export class MapApp extends React.Component<Props, State> {
const savedObjectId = this.props.savedMap.getSavedObjectId(); const savedObjectId = this.props.savedMap.getSavedObjectId();
if (savedObjectId) { if (savedObjectId) {
getCoreChrome().recentlyAccessed.add( getCoreChrome().recentlyAccessed.add(
getExistingMapPath(savedObjectId), getFullPath(savedObjectId),
this.props.savedMap.getTitle(), this.props.savedMap.getTitle(),
savedObjectId savedObjectId
); );

View file

@ -22,7 +22,7 @@ import { getFlightsSavedObjects } from './sample_data/flights_saved_objects.js';
// @ts-ignore // @ts-ignore
import { getWebLogsSavedObjects } from './sample_data/web_logs_saved_objects.js'; import { getWebLogsSavedObjects } from './sample_data/web_logs_saved_objects.js';
import { registerMapsUsageCollector } from './maps_telemetry/collectors/register'; import { registerMapsUsageCollector } from './maps_telemetry/collectors/register';
import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE, getExistingMapPath } from '../common/constants'; import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE, getFullPath } from '../common/constants';
import { mapSavedObjects, mapsTelemetrySavedObjects } from './saved_objects'; import { mapSavedObjects, mapsTelemetrySavedObjects } from './saved_objects';
import { MapsXPackConfig } from '../config'; import { MapsXPackConfig } from '../config';
// @ts-ignore // @ts-ignore
@ -77,7 +77,7 @@ export class MapsPlugin implements Plugin {
home.sampleData.addAppLinksToSampleDataset('ecommerce', [ home.sampleData.addAppLinksToSampleDataset('ecommerce', [
{ {
path: getExistingMapPath('2c9c1f60-1909-11e9-919b-ffe5949a18d2'), path: getFullPath('2c9c1f60-1909-11e9-919b-ffe5949a18d2'),
label: sampleDataLinkLabel, label: sampleDataLinkLabel,
icon: APP_ICON, icon: APP_ICON,
}, },
@ -99,7 +99,7 @@ export class MapsPlugin implements Plugin {
home.sampleData.addAppLinksToSampleDataset('flights', [ home.sampleData.addAppLinksToSampleDataset('flights', [
{ {
path: getExistingMapPath('5dd88580-1906-11e9-919b-ffe5949a18d2'), path: getFullPath('5dd88580-1906-11e9-919b-ffe5949a18d2'),
label: sampleDataLinkLabel, label: sampleDataLinkLabel,
icon: APP_ICON, icon: APP_ICON,
}, },
@ -120,7 +120,7 @@ export class MapsPlugin implements Plugin {
home.sampleData.addSavedObjectsToSampleDataset('logs', getWebLogsSavedObjects()); home.sampleData.addSavedObjectsToSampleDataset('logs', getWebLogsSavedObjects());
home.sampleData.addAppLinksToSampleDataset('logs', [ home.sampleData.addAppLinksToSampleDataset('logs', [
{ {
path: getExistingMapPath('de71f4f0-1902-11e9-919b-ffe5949a18d2'), path: getFullPath('de71f4f0-1902-11e9-919b-ffe5949a18d2'),
label: sampleDataLinkLabel, label: sampleDataLinkLabel,
icon: APP_ICON, icon: APP_ICON,
}, },

View file

@ -6,7 +6,7 @@
*/ */
import { SavedObjectsType } from 'src/core/server'; import { SavedObjectsType } from 'src/core/server';
import { APP_ICON, getExistingMapPath } from '../../common/constants'; import { APP_ICON, getFullPath } from '../../common/constants';
// @ts-ignore // @ts-ignore
import { savedObjectMigrations } from './saved_object_migrations'; import { savedObjectMigrations } from './saved_object_migrations';
@ -34,7 +34,7 @@ export const mapSavedObjects: SavedObjectsType = {
}, },
getInAppUrl(obj) { getInAppUrl(obj) {
return { return {
path: getExistingMapPath(obj.id), path: getFullPath(obj.id),
uiCapabilitiesPath: 'maps.show', uiCapabilitiesPath: 'maps.show',
}; };
}, },