diff --git a/src/plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts b/src/plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts
index 919429ca049e7..b1dfe2044d8a5 100644
--- a/src/plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts
+++ b/src/plugins/vis_type_timelion/public/helpers/arg_value_suggestions.ts
@@ -9,7 +9,11 @@
import { get } from 'lodash';
import { getIndexPatterns } from './plugin_services';
import { TimelionFunctionArgs } from '../../common/types';
-import { indexPatterns as indexPatternsUtils } from '../../../data/public';
+import {
+ IndexPatternField,
+ indexPatterns as indexPatternsUtils,
+ KBN_FIELD_TYPES,
+} from '../../../data/public';
export interface Location {
min: number;
@@ -30,6 +34,8 @@ export interface FunctionArg {
};
}
+const isRuntimeField = (field: IndexPatternField) => Boolean(field.runtimeField);
+
export function getArgValueSuggestions() {
const indexPatterns = getIndexPatterns();
@@ -85,18 +91,15 @@ export function getArgValueSuggestions() {
const valueSplit = partial.split(':');
return indexPattern.fields
- .getAll()
- .filter((field) => {
- return (
+ .getByType(KBN_FIELD_TYPES.NUMBER)
+ .filter(
+ (field) =>
+ !isRuntimeField(field) &&
field.aggregatable &&
- 'number' === field.type &&
containsFieldName(valueSplit[1], field) &&
!indexPatternsUtils.isNestedField(field)
- );
- })
- .map((field) => {
- return { name: `${valueSplit[0]}:${field.name}`, help: field.type };
- });
+ )
+ .map((field) => ({ name: `${valueSplit[0]}:${field.name}`, help: field.type }));
},
async split(partial: string, functionArgs: FunctionArg[]) {
const indexPattern = await getIndexPattern(functionArgs);
@@ -106,17 +109,21 @@ export function getArgValueSuggestions() {
return indexPattern.fields
.getAll()
- .filter((field) => {
- return (
+ .filter(
+ (field) =>
+ !isRuntimeField(field) &&
field.aggregatable &&
- ['number', 'boolean', 'date', 'ip', 'string'].includes(field.type) &&
+ [
+ KBN_FIELD_TYPES.NUMBER,
+ KBN_FIELD_TYPES.BOOLEAN,
+ KBN_FIELD_TYPES.DATE,
+ KBN_FIELD_TYPES.IP,
+ KBN_FIELD_TYPES.STRING,
+ ].includes(field.type as KBN_FIELD_TYPES) &&
containsFieldName(partial, field) &&
!indexPatternsUtils.isNestedField(field)
- );
- })
- .map((field) => {
- return { name: field.name, help: field.type };
- });
+ )
+ .map((field) => ({ name: field.name, help: field.type }));
},
async timefield(partial: string, functionArgs: FunctionArg[]) {
const indexPattern = await getIndexPattern(functionArgs);
@@ -125,17 +132,14 @@ export function getArgValueSuggestions() {
}
return indexPattern.fields
- .getAll()
- .filter((field) => {
- return (
- 'date' === field.type &&
+ .getByType(KBN_FIELD_TYPES.DATE)
+ .filter(
+ (field) =>
+ !isRuntimeField(field) &&
containsFieldName(partial, field) &&
!indexPatternsUtils.isNestedField(field)
- );
- })
- .map((field) => {
- return { name: field.name };
- });
+ )
+ .map((field) => ({ name: field.name }));
},
},
};
diff --git a/x-pack/plugins/maps/public/render_app.tsx b/x-pack/plugins/maps/public/render_app.tsx
index b62ac6518a374..bf122c13e9418 100644
--- a/x-pack/plugins/maps/public/render_app.tsx
+++ b/x-pack/plugins/maps/public/render_app.tsx
@@ -73,13 +73,13 @@ export async function renderApp({
...withNotifyOnErrors(getToasts()),
});
+ const stateTransfer = getEmbeddableService().getStateTransfer();
+
setAppChrome();
function renderMapApp(routeProps: RouteComponentProps<{ savedMapId?: string }>) {
- const stateTransfer = getEmbeddableService()?.getStateTransfer();
-
const { embeddableId, originatingApp, valueInput } =
- stateTransfer?.getIncomingEditorState() || {};
+ stateTransfer.getIncomingEditorState() || {};
let mapEmbeddableInput;
if (routeProps.match.params.savedMapId) {
@@ -119,7 +119,7 @@ export async function renderApp({
const newPath = hash.substr(1);
return ;
} else if (pathname === '/' || pathname === '') {
- return ;
+ return ;
} else {
return ;
}
diff --git a/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx b/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx
index 087fd82300ce3..03990fd477ee3 100644
--- a/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx
+++ b/x-pack/plugins/maps/public/routes/list_page/load_list_and_render.tsx
@@ -10,8 +10,9 @@ import { Redirect } from 'react-router-dom';
import { getSavedObjectsClient, getToasts } from '../../kibana_services';
import { MapsListView } from './maps_list_view';
import { MAP_SAVED_OBJECT_TYPE } from '../../../common/constants';
+import { EmbeddableStateTransfer } from '../../../../../../src/plugins/embeddable/public';
-export class LoadListAndRender extends React.Component {
+export class LoadListAndRender extends React.Component<{ stateTransfer: EmbeddableStateTransfer }> {
_isMounted: boolean = false;
state = {
mapsLoaded: false,
@@ -20,6 +21,7 @@ export class LoadListAndRender extends React.Component {
componentDidMount() {
this._isMounted = true;
+ this.props.stateTransfer.clearEditorState();
this._loadMapsList();
}
diff --git a/x-pack/test/functional/apps/maps/embeddable/save_and_return.js b/x-pack/test/functional/apps/maps/embeddable/save_and_return.js
index 13aa08cbbeb38..cd38d808ca510 100644
--- a/x-pack/test/functional/apps/maps/embeddable/save_and_return.js
+++ b/x-pack/test/functional/apps/maps/embeddable/save_and_return.js
@@ -82,6 +82,19 @@ export default function ({ getPageObjects, getService }) {
const panelCount = await PageObjects.dashboard.getPanelCount();
expect(panelCount).to.equal(2);
});
+
+ it('should lose its connection to the dashboard when creating new map', async () => {
+ await PageObjects.maps.gotoMapListingPage();
+ await PageObjects.maps.openNewMap();
+ await PageObjects.maps.expectMissingSaveAndReturnButton();
+
+ // return to origin should not be present in save modal
+ await testSubjects.click('mapSaveButton');
+ const redirectToOriginCheckboxExists = await testSubjects.exists(
+ 'returnToOriginModeSwitch'
+ );
+ expect(redirectToOriginCheckboxExists).to.be(false);
+ });
});
describe('save as', () => {
diff --git a/x-pack/test/functional/page_objects/gis_page.ts b/x-pack/test/functional/page_objects/gis_page.ts
index 7767499cb6bd3..7f321e65278a4 100644
--- a/x-pack/test/functional/page_objects/gis_page.ts
+++ b/x-pack/test/functional/page_objects/gis_page.ts
@@ -170,6 +170,10 @@ export function GisPageProvider({ getService, getPageObjects }: FtrProviderConte
await testSubjects.click('mapSaveAndReturnButton');
}
+ async expectMissingSaveAndReturnButton() {
+ await testSubjects.missingOrFail('mapSaveAndReturnButton');
+ }
+
async expectMissingSaveButton() {
await testSubjects.missingOrFail('mapSaveButton');
}