Skip to content

Commit

Permalink
🐛 Fix reporting for dirty state
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Apr 4, 2023
1 parent 23286a3 commit fe0d606
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
3 changes: 2 additions & 1 deletion x-pack/plugins/lens/public/app_plugin/lens_top_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,8 @@ export const LensTopNavMenu = ({
currentDoc,
adHocDataViews: adHocDataViews.map((dataView) => dataView.toSpec()),
},
shareUrlEnabled
shareUrlEnabled,
isCurrentStateDirty
);
const sharingData = {
activeData,
Expand Down
26 changes: 15 additions & 11 deletions x-pack/plugins/lens/public/app_plugin/share_action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export function getLocatorParams(
visualization,
adHocDataViews,
currentDoc,
}: ShareableConfiguration
}: ShareableConfiguration,
isDirty: boolean
) {
const references = extractReferencesFromState({
activeDatasources: Object.keys(datasourceStates).reduce(
Expand Down Expand Up @@ -95,26 +96,29 @@ export function getLocatorParams(
return {
shareURL: snapshotParams,
// for reporting use the shorten version when available
reporting: currentDoc?.savedObjectId
? {
filters,
query,
resolvedDateRange: getResolvedDateRange(data.query.timefilter.timefilter),
savedObjectId: currentDoc?.savedObjectId,
}
: snapshotParams,
reporting:
currentDoc?.savedObjectId && !isDirty
? {
filters,
query,
resolvedDateRange: getResolvedDateRange(data.query.timefilter.timefilter),
savedObjectId: currentDoc?.savedObjectId,
}
: snapshotParams,
};
}

export async function getShareURL(
shortUrlService: (params: LensAppLocatorParams) => Promise<string>,
services: Pick<LensAppServices, 'application' | 'data'>,
configuration: ShareableConfiguration,
shareUrlEnabled: boolean
shareUrlEnabled: boolean,
isDirty: boolean
) {
const { shareURL: locatorParams, reporting: reportingLocatorParams } = getLocatorParams(
services.data,
configuration
configuration,
isDirty
);
return {
shareableUrl: await (shareUrlEnabled ? shortUrlService(locatorParams) : undefined),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const reportingScreenshotShareProvider = ({
});

const jobProviderOptions: JobParamsProviderOptions = {
shareableUrl: shareableUrlForSavedObject ?? shareableUrl,
shareableUrl: isDirty ? shareableUrl : shareableUrlForSavedObject ?? shareableUrl,
objectType,
sharingData,
};
Expand Down

0 comments on commit fe0d606

Please sign in to comment.