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] implement save and return from dashboard #74303

Merged
merged 18 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from 15 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: 11 additions & 0 deletions test/functional/services/dashboard/panel_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ export function DashboardPanelActionsProvider({ getService, getPageObjects }: Ft
await PageObjects.common.waitForTopNavToBeVisible();
}

async editPanelByTitle(title?: string) {
log.debug(`editPanelByTitle(${title})`);
if (title) {
const panelOptions = await this.getPanelHeading(title);
await this.openContextMenu(panelOptions);
} else {
await this.openContextMenu();
}
await testSubjects.clickWhenNotDisabled(EDIT_PANEL_DATA_TEST_SUBJ);
}

async clickExpandPanelToggle() {
await testSubjects.click(TOGGLE_EXPAND_PANEL_DATA_TEST_SUBJ);
}
Expand Down
11 changes: 11 additions & 0 deletions x-pack/plugins/maps/public/kibana_services.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import { DataPublicPluginStart } from 'src/plugins/data/public';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { IndexPatternsService } from 'src/plugins/data/public/index_patterns';
import { NavigateToAppOptions } from 'kibana/public';
import { MapsConfigType } from '../config';
import { MapsLegacyConfigType } from '../../../../src/plugins/maps_legacy/public';
import { EmbeddableStart } from '../../../../src/plugins/embeddable/public';

export function getLicenseId(): any;
export function getInspector(): any;
Expand Down Expand Up @@ -77,3 +79,12 @@ export function setKibanaCommonConfig(config: MapsLegacyConfigType): void;
export function setMapAppConfig(config: MapsConfigType): void;
export function setKibanaVersion(version: string): void;
export function setIsGoldPlus(isGoldPlus: boolean): void;
export function setEmbeddableService(embeddableService: EmbeddableStart): void;
export function getEmbeddableService(): EmbeddableStart;
export function setNavigateToApp(
navigateToApp: (appId: string, options?: NavigateToAppOptions | undefined) => Promise<void>
): void;
export const navigateToApp: (
appId: string,
options?: NavigateToAppOptions | undefined
) => Promise<void>;
13 changes: 13 additions & 0 deletions x-pack/plugins/maps/public/kibana_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,16 @@ export const setIsGoldPlus = (igp) => {
export const getIsGoldPlus = () => {
return isGoldPlus;
};

let _embeddableService;
nreese marked this conversation as resolved.
Show resolved Hide resolved
export const setEmbeddableService = (embeddableService) => {
_embeddableService = embeddableService;
};
export const getEmbeddableService = () => {
return _embeddableService;
};

export let navigateToApp;
export function setNavigateToApp(_navigateToApp) {
navigateToApp = _navigateToApp;
}
4 changes: 4 additions & 0 deletions x-pack/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ import {
setUiActions,
setUiSettings,
setVisualizations,
setEmbeddableService,
setNavigateToApp,
} from './kibana_services';
import { featureCatalogueEntry } from './feature_catalogue_entry';
// @ts-ignore
Expand Down Expand Up @@ -113,6 +115,8 @@ export const bindStartCoreAndPlugins = (core: CoreStart, plugins: any) => {
setUiActions(plugins.uiActions);
setNavigation(plugins.navigation);
setCoreI18n(core.i18n);
setEmbeddableService(plugins.embeddable);
setNavigateToApp(core.application.navigateToApp);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface ISavedGisMap extends SavedObject {
layerListJSON?: string;
mapStateJSON?: string;
uiStateJSON?: string;
description?: string;
nreese marked this conversation as resolved.
Show resolved Hide resolved
getLayerList(): LayerDescriptor[];
syncWithStore(): void;
}
Expand Down
17 changes: 15 additions & 2 deletions x-pack/plugins/maps/public/routing/maps_router.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { Router, Switch, Route, Redirect } from 'react-router-dom';
import { getCoreI18n, getToasts } from '../kibana_services';
import { getCoreI18n, getToasts, getEmbeddableService } from '../kibana_services';
import {
createKbnUrlStateStorage,
withNotifyOnErrors,
Expand Down Expand Up @@ -39,6 +39,11 @@ const App = ({ history, appBasePath, onAppLeave }) => {
const store = getStore();
const I18nContext = getCoreI18n().Context;

const stateTransfer = getEmbeddableService()?.getStateTransfer(history);

const { originatingApp } =
stateTransfer?.getIncomingEditorState({ keysToRemoveAfterFetch: ['originatingApp'] }) || {};

return (
<I18nContext>
<Provider store={store}>
Expand All @@ -50,13 +55,21 @@ const App = ({ history, appBasePath, onAppLeave }) => {
<LoadMapAndRender
savedMapId={props.match.params.savedMapId}
onAppLeave={onAppLeave}
stateTransfer={stateTransfer}
originatingApp={originatingApp}
/>
)}
/>
<Route
exact
path={`/map`}
render={() => <LoadMapAndRender onAppLeave={onAppLeave} />}
render={() => (
<LoadMapAndRender
onAppLeave={onAppLeave}
stateTransfer={stateTransfer}
originatingApp={originatingApp}
/>
)}
/>
// Redirect other routes to list, or if hash-containing, their non-hash equivalents
<Route
Expand Down
6 changes: 0 additions & 6 deletions x-pack/plugins/maps/public/routing/routes/maps_app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
updateFlyout,
enableFullScreen,
openMapSettings,
removePreviewLayers,
} from '../../../actions';
import { FLYOUT_STATE } from '../../../reducers/ui';
import { getMapsCapabilities } from '../../../kibana_services';
Expand Down Expand Up @@ -76,11 +75,6 @@ function mapDispatchToProps(dispatch) {
dispatch(updateFlyout(FLYOUT_STATE.NONE));
dispatch(setReadOnly(!getMapsCapabilities().save));
},
closeFlyout: () => {
dispatch(setSelectedLayer(null));
dispatch(updateFlyout(FLYOUT_STATE.NONE));
dispatch(removePreviewLayers());
},
enableFullScreen: () => dispatch(enableFullScreen()),
openMapSettings: () => dispatch(openMapSettings()),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ export const LoadMapAndRender = class extends React.Component {
return <Redirect to="/" />;
}

return savedMap ? <MapsAppView savedMap={savedMap} onAppLeave={this.props.onAppLeave} /> : null;
return savedMap ? (
<MapsAppView
savedMap={savedMap}
onAppLeave={this.props.onAppLeave}
stateTransfer={this.props.stateTransfer}
originatingApp={this.props.originatingApp}
/>
) : null;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export class MapsAppView extends React.Component {
initialized: false,
savedQuery: '',
initialLayerListConfig: null,
// tracking originatingApp in state so the connection can be broken by users
originatingApp: props.originatingApp,
};
}

Expand Down Expand Up @@ -303,11 +305,15 @@ export class MapsAppView extends React.Component {
savedMap: this.props.savedMap,
isOpenSettingsDisabled: this.props.isOpenSettingsDisabled,
isSaveDisabled: this.props.isSaveDisabled,
closeFlyout: this.props.closeFlyout,
enableFullScreen: this.props.enableFullScreen,
openMapSettings: this.props.openMapSettings,
inspectorAdapters: this.props.inspectorAdapters,
setBreadcrumbs: this._setBreadcrumbs,
stateTransfer: this.props.stateTransfer,
originatingApp: this.state.originatingApp,
cutOriginatingAppConnection: () => {
this.setState({ originatingApp: undefined });
},
});

const { TopNavMenu } = getNavigation().ui;
Expand Down
Loading