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

[Lens] Use proper way to generate absolute short URL #155512

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Changes from all 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
9 changes: 3 additions & 6 deletions x-pack/plugins/lens/public/app_plugin/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,14 @@ export function App({
}
if (locator && shortUrls) {
// This is a stripped down version of what the share URL plugin is doing
const relativeUrl = await shortUrls.create({ locator, params });
const absoluteShortUrl = application.getUrlForApp('', {
path: `/r/s/${relativeUrl.data.slug}`,
absolute: true,
});
const shortUrl = await shortUrls.createWithLocator({ locator, params });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the above comment is not useful anymore because the new code seems to use a cleaner API

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is technically still true. I would just keep it as the share plugin has a flag to enable the shortURL feature which is not useful for the Lens case. There's also a comment in the top_nav module about not using that.

const absoluteShortUrl = await shortUrl.locator.getUrl(shortUrl.params, { absolute: true });
shareURLCache.current = { params: cacheKey, url: absoluteShortUrl };
return absoluteShortUrl;
}
return '';
},
[locator, application, shortUrls]
[locator, shortUrls]
);

const returnToOriginSwitchLabelForContext =
Expand Down