Skip to content

Commit

Permalink
[Lens] Fix URL query loss on redirect (#81475)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 committed Oct 27, 2020
1 parent 2dcfe2a commit db0816f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
7 changes: 5 additions & 2 deletions x-pack/plugins/lens/public/app_plugin/mounter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ export async function mountApp(

const redirectTo = (routeProps: RouteComponentProps<{ id?: string }>, savedObjectId?: string) => {
if (!savedObjectId) {
routeProps.history.push('/');
routeProps.history.push({ pathname: '/', search: routeProps.history.location.search });
} else {
routeProps.history.push(`/edit/${savedObjectId}`);
routeProps.history.push({
pathname: `/edit/${savedObjectId}`,
search: routeProps.history.location.search,
});
}
};

Expand Down
23 changes: 23 additions & 0 deletions x-pack/test/functional/apps/lens/persistent_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(timeRange.end).to.equal('Sep 19, 2025 @ 06:31:44.000');
await filterBar.hasFilter('ip', '97.220.3.248', false, true);
});

it('keeps time range and pinned filters after refreshing directly after saving', async () => {
// restore defaults so visualization becomes saveable
await security.testUser.restoreDefaults();
await PageObjects.lens.configureDimension({
dimension: 'lnsXY_xDimensionPanel > lns-empty-dimension',
operation: 'date_histogram',
field: '@timestamp',
});

await PageObjects.lens.configureDimension({
dimension: 'lnsXY_yDimensionPanel > lns-empty-dimension',
operation: 'avg',
field: 'bytes',
});
await PageObjects.lens.save('persistentcontext');
await browser.refresh();
await PageObjects.header.waitUntilLoadingHasFinished();
const timeRange = await PageObjects.timePicker.getTimeConfig();
expect(timeRange.start).to.equal('Sep 7, 2015 @ 06:31:44.000');
expect(timeRange.end).to.equal('Sep 19, 2025 @ 06:31:44.000');
await filterBar.hasFilter('ip', '97.220.3.248', false, true);
});
});
}

0 comments on commit db0816f

Please sign in to comment.