From effa77dc102c57df589c51e6c382caa0f132fa69 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Mon, 27 May 2024 09:35:44 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=82(frontend)=20right=20pad=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Manage the right on the pad update. If a use cannot update a pad, we will not display the update button in the dropdown menu. --- .../__tests__/app-impress/pad-tools.spec.ts | 32 +++++++++++++++++ .../pads/pad-tools/components/PadToolBox.tsx | 34 +++++++++++++------ 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/src/frontend/apps/e2e/__tests__/app-impress/pad-tools.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/pad-tools.spec.ts index 9eb20c20..af6ebd86 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/pad-tools.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/pad-tools.spec.ts @@ -135,4 +135,36 @@ test.describe('Pad Tools', () => { const panel = page.getByLabel('Pads panel').first(); await expect(panel.locator('li').getByText(randomPad)).toBeHidden(); }); + + test('it cannot update if not the owner', async ({ page, browserName }) => { + const [padName] = await createPad( + page, + 'pad-tools-right-management', + browserName, + 1, + true, + ); + + await page.getByText('My account').click(); + await page.getByText('Logout').first().click(); + + await page.getByLabel('Restart login').click(); + + const browserNames = ['chromium', 'webkit']; + const newBrowserName = browserNames.find((name) => name !== browserName)!; + + await keyCloakSignIn(page, newBrowserName); + + const panel = page.getByLabel('Pads panel').first(); + await panel.getByText(padName).click(); + + await page.getByLabel('Open the document options').click(); + + await expect( + page.getByRole('button', { name: 'Generate PDF' }), + ).toBeVisible(); + await expect( + page.getByRole('button', { name: 'Update document' }), + ).toBeHidden(); + }); }); diff --git a/src/frontend/apps/impress/src/features/pads/pad-tools/components/PadToolBox.tsx b/src/frontend/apps/impress/src/features/pads/pad-tools/components/PadToolBox.tsx index 45eefb06..89881f03 100644 --- a/src/frontend/apps/impress/src/features/pads/pad-tools/components/PadToolBox.tsx +++ b/src/frontend/apps/impress/src/features/pads/pad-tools/components/PadToolBox.tsx @@ -57,16 +57,30 @@ export const PadToolBox = ({ pad }: PadToolBoxProps) => { isOpen={isDropOpen} > - + {pad.abilities.partial_update && ( + + )} + {pad.abilities.destroy && ( + + )}