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

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

Merged
merged 2 commits into from
Jun 23, 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
11 changes: 5 additions & 6 deletions x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ export const KBN_IS_CENTROID_FEATURE = '__kbn_is_centroid_feature__';

export const MVT_TOKEN_PARAM_NAME = 'token';

const MAP_BASE_URL = `/${MAPS_APP_PATH}/${MAP_PATH}`;
export function getNewMapPath() {
return MAP_BASE_URL;
return `/${MAPS_APP_PATH}/${MAP_PATH}`;
}
export function getExistingMapPath(id: string) {
return `${MAP_BASE_URL}/${id}`;
export function getFullPath(id: string | undefined) {
return `/${MAPS_APP_PATH}${getEditPath(id)}`;
}
export function getEditPath(id: string) {
return `/${MAP_PATH}/${id}`;
export function getEditPath(id: string | undefined) {
return id ? `/${MAP_PATH}/${id}` : `/${MAP_PATH}`;
}

export enum LAYER_TYPE {
Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/maps/public/embeddable/map_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ import {
} from '../selectors/map_selectors';
import {
APP_ID,
getExistingMapPath,
getEditPath,
getFullPath,
MAP_SAVED_OBJECT_TYPE,
MAP_PATH,
RawValue,
} from '../../common/constants';
import { RenderToolTipContent } from '../classes/tooltips/tooltip_property';
Expand Down Expand Up @@ -180,13 +180,13 @@ export class MapEmbeddable
: '';
const input = this.getInput();
const title = input.hidePanelTitles ? '' : input.title || savedMapTitle;
const savedObjectId = (input as MapByReferenceInput).savedObjectId;
const savedObjectId = 'savedObjectId' in input ? input.savedObjectId : undefined;
this.updateOutput({
...this.getOutput(),
defaultTitle: savedMapTitle,
title,
editPath: `/${MAP_PATH}/${savedObjectId}`,
editUrl: getHttp().basePath.prepend(getExistingMapPath(savedObjectId)),
editPath: getEditPath(savedObjectId),
editUrl: getHttp().basePath.prepend(getFullPath(savedObjectId)),
indexPatterns: await this._getIndexPatterns(),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { getTopNavConfig } from '../top_nav_config';
import { MapQuery } from '../../../../common/descriptor_types';
import { goToSpecifiedPath } from '../../../render_app';
import { MapSavedObjectAttributes } from '../../../../common/map_saved_object_type';
import { getExistingMapPath, APP_ID } from '../../../../common/constants';
import { getFullPath, APP_ID } from '../../../../common/constants';
import {
getInitialQuery,
getInitialRefreshConfig,
Expand Down Expand Up @@ -356,7 +356,7 @@ export class MapApp extends React.Component<Props, State> {
const savedObjectId = this.props.savedMap.getSavedObjectId();
if (savedObjectId) {
getCoreChrome().recentlyAccessed.add(
getExistingMapPath(savedObjectId),
getFullPath(savedObjectId),
this.props.savedMap.getTitle(),
savedObjectId
);
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/maps/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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, getExistingMapPath } from '../common/constants';
import { APP_ID, APP_ICON, MAP_SAVED_OBJECT_TYPE, getFullPath } from '../common/constants';
import { mapSavedObjects, mapsTelemetrySavedObjects } from './saved_objects';
import { MapsXPackConfig } from '../config';
// @ts-ignore
Expand Down Expand Up @@ -77,7 +77,7 @@ export class MapsPlugin implements Plugin {

home.sampleData.addAppLinksToSampleDataset('ecommerce', [
{
path: getExistingMapPath('2c9c1f60-1909-11e9-919b-ffe5949a18d2'),
path: getFullPath('2c9c1f60-1909-11e9-919b-ffe5949a18d2'),
label: sampleDataLinkLabel,
icon: APP_ICON,
},
Expand All @@ -99,7 +99,7 @@ export class MapsPlugin implements Plugin {

home.sampleData.addAppLinksToSampleDataset('flights', [
{
path: getExistingMapPath('5dd88580-1906-11e9-919b-ffe5949a18d2'),
path: getFullPath('5dd88580-1906-11e9-919b-ffe5949a18d2'),
label: sampleDataLinkLabel,
icon: APP_ICON,
},
Expand All @@ -120,7 +120,7 @@ export class MapsPlugin implements Plugin {
home.sampleData.addSavedObjectsToSampleDataset('logs', getWebLogsSavedObjects());
home.sampleData.addAppLinksToSampleDataset('logs', [
{
path: getExistingMapPath('de71f4f0-1902-11e9-919b-ffe5949a18d2'),
path: getFullPath('de71f4f0-1902-11e9-919b-ffe5949a18d2'),
label: sampleDataLinkLabel,
icon: APP_ICON,
},
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/maps/server/saved_objects/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { SavedObjectsType } from 'src/core/server';
import { APP_ICON, getExistingMapPath } from '../../common/constants';
import { APP_ICON, getFullPath } from '../../common/constants';
// @ts-ignore
import { savedObjectMigrations } from './saved_object_migrations';

Expand Down Expand Up @@ -34,7 +34,7 @@ export const mapSavedObjects: SavedObjectsType = {
},
getInAppUrl(obj) {
return {
path: getExistingMapPath(obj.id),
path: getFullPath(obj.id),
uiCapabilitiesPath: 'maps.show',
};
},
Expand Down