ShareModal: delete shareView query param from url (#92243)

This commit is contained in:
Lucy Chen 2024-08-21 18:36:20 -04:00 committed by GitHub
parent 733ae1f099
commit 2ad9d8cafe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -28,7 +28,16 @@ describe('dashboard utils', () => {
expect(url).toBe('/d/dash-1/dash-1-slug/panel-edit/2?orgId=1&filter=A');
});
it('Can getUrl with params removed and addded', () => {
it('Can getURL without shareView param', async () => {
const url = getDashboardUrl({
uid: 'dash-1',
currentQueryParams: '?orgId=1&filter=A&shareView=link',
});
expect(url).toBe('/d/dash-1?orgId=1&filter=A');
});
it('Can getUrl with params removed and added', () => {
const url = getDashboardUrl({
uid: 'dash-1',
currentQueryParams: '?orgId=1&filter=A',

View File

@ -62,6 +62,8 @@ export function getDashboardUrl(options: DashboardUrlOptions) {
const params = options.currentQueryParams ? locationSearchToObject(options.currentQueryParams) : {};
delete params['shareView'];
if (options.updateQuery) {
for (const key in options.updateQuery) {
// removing params with null | undefined