From dbbf2c25ea767af7ba2a77fa73e253e4d6e43402 Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:30:05 -0300 Subject: [PATCH] [v10.3.x] ShareModal: Remove shareView param when creating a sharing URL (#81983) * ShareModal: Remove shareView param when creating a sharing URL (#81976) (cherry picked from commit eab7990349d70da5b7461cdb582c14ae4a2c4a43) * fix ShareLink test --------- Co-authored-by: Ezequiel Victorero --- .../components/ShareModal/ShareLink.test.tsx | 11 +++++++++++ .../features/dashboard/components/ShareModal/utils.ts | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx b/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx index 87d8072f153..ef5d4820460 100644 --- a/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx +++ b/public/app/features/dashboard/components/ShareModal/ShareLink.test.tsx @@ -162,6 +162,17 @@ describe('ShareModal', () => { `http://localhost:3000/goto/${mockUid}` ); }); + + it('should generate render url without shareView param', async () => { + mockLocationHref('http://dashboards.grafana.com/d/abcdefghi/my-dash?shareView=link'); + render(); + + const base = '/render/d-solo/abcdefghi/my-dash'; + const params = '?from=1000&to=2000&orgId=1&panelId=22&width=1000&height=500&tz=UTC'; + expect( + await screen.findByRole('link', { name: selectors.pages.SharePanelModal.linkToRenderedImage }) + ).toHaveAttribute('href', base + params); + }); }); }); diff --git a/public/app/features/dashboard/components/ShareModal/utils.ts b/public/app/features/dashboard/components/ShareModal/utils.ts index 1d760b40052..196af5376d4 100644 --- a/public/app/features/dashboard/components/ShareModal/utils.ts +++ b/public/app/features/dashboard/components/ShareModal/utils.ts @@ -52,6 +52,10 @@ export function buildParams({ // Token is unique to the authenticated identity and should not be shared with the URL, // so we are stripping it from the query params as a safety measure. searchParams.delete('auth_token'); + + // The shareView param is used to indicate that the sharing modal is open and should never be included in the URL + searchParams.delete('shareView'); + return searchParams; }