Skip to content

Commit

Permalink
Transfer custom timerange
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed Apr 18, 2023
1 parent f892fac commit 54e3fc6
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class EditInLensAction implements Action<EditInLensContext> {
searchQuery,
isEmbeddable: true,
description: vis.description || embeddable.getOutput().description,
panelTimeRange: embeddable.getInput()?.timeRange,
};
if (navigateToLensConfig) {
if (this.currentAppId) {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/visualizations/public/visualize_app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export interface VisInstance {
embeddableHandler: VisualizeEmbeddableContract;
panelTitle?: string;
panelDescription?: string;
panelTimeRange?: TimeRange;
}

export type SavedVisInstance = VisInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export const getTopNavConfig = (
title: visInstance?.panelTitle || vis.title,
visTypeTitle: vis.type.title,
description: visInstance?.panelDescription || vis.description,
panelTimeRange: visInstance?.panelTimeRange || undefined,
isEmbeddable: Boolean(originatingApp),
};
if (navigateToLensConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export const getVisualizationInstanceFromInput = async (
savedSearch,
panelTitle: input?.title ?? '',
panelDescription: input?.description ?? '',
panelTimeRange: input?.timeRange ?? undefined,
};
};

Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/lens/public/app_plugin/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import './app.scss';
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
import { i18n } from '@kbn/i18n';
import type { TimeRange } from '@kbn/es-query';
import { EuiBreadcrumb, EuiConfirmModal } from '@elastic/eui';
import { useExecutionContext, useKibana } from '@kbn/kibana-react-plugin/public';
import { OnSaveProps } from '@kbn/saved-objects-plugin/public';
Expand Down Expand Up @@ -52,6 +53,7 @@ export type SaveProps = Omit<OnSaveProps, 'onTitleDuplicate' | 'newDescription'>
onTitleDuplicate?: OnSaveProps['onTitleDuplicate'];
newDescription?: string;
newTags?: string[];
panelTimeRange?: TimeRange;
};

export function App({
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ export const LensTopNavMenu = ({
isTitleDuplicateConfirmed: false,
returnToOrigin: true,
newDescription: contextFromEmbeddable ? initialContext.description : '',
panelTimeRange: contextFromEmbeddable ? initialContext.panelTimeRange : undefined,
},
{
saveToLibrary:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,17 @@ export const runSaveLensVisualization = async (
}
}
try {
const newInput = (await attributeService.wrapAttributes(
let newInput = (await attributeService.wrapAttributes(
docToSave,
options.saveToLibrary,
originalInput
)) as LensEmbeddableInput;
if (saveProps.panelTimeRange) {
newInput = {
...newInput,
timeRange: saveProps.panelTimeRange,
};
}

if (saveProps.returnToOrigin && redirectToOrigin) {
// disabling the validation on app leave because the document has been saved.
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/lens/public/app_plugin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { History } from 'history';
import type { OnSaveProps } from '@kbn/saved-objects-plugin/public';
import { Observable } from 'rxjs';
import { SpacesApi } from '@kbn/spaces-plugin/public';
import type { TimeRange } from '@kbn/es-query';
import type {
ApplicationStart,
AppMountParameters,
Expand Down Expand Up @@ -94,6 +95,7 @@ export type RunSave = (
onTitleDuplicate?: OnSaveProps['onTitleDuplicate'];
newDescription?: string;
newTags?: string[];
panelTimeRange?: TimeRange;
},
options: {
saveToLibrary: boolean;
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export type VisualizeEditorContext<T extends Configuration = Configuration> = {
searchFilters?: Filter[];
title?: string;
description?: string;
panelTimeRange?: TimeRange;
visTypeTitle?: string;
isEmbeddable?: boolean;
} & NavigateToLensContext<T>;
Expand Down

0 comments on commit 54e3fc6

Please sign in to comment.