🛂(frontend) right pad update
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.
This commit is contained in:
@@ -135,4 +135,36 @@ test.describe('Pad Tools', () => {
|
|||||||
const panel = page.getByLabel('Pads panel').first();
|
const panel = page.getByLabel('Pads panel').first();
|
||||||
await expect(panel.locator('li').getByText(randomPad)).toBeHidden();
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -57,16 +57,30 @@ export const PadToolBox = ({ pad }: PadToolBoxProps) => {
|
|||||||
isOpen={isDropOpen}
|
isOpen={isDropOpen}
|
||||||
>
|
>
|
||||||
<Box>
|
<Box>
|
||||||
<Button
|
{pad.abilities.partial_update && (
|
||||||
onClick={() => {
|
<Button
|
||||||
setIsModalUpdateOpen(true);
|
onClick={() => {
|
||||||
setIsDropOpen(false);
|
setIsModalUpdateOpen(true);
|
||||||
}}
|
setIsDropOpen(false);
|
||||||
color="primary-text"
|
}}
|
||||||
icon={<span className="material-icons">edit</span>}
|
color="primary-text"
|
||||||
>
|
icon={<span className="material-icons">edit</span>}
|
||||||
<Text $theme="primary">{t('Update document')}</Text>
|
>
|
||||||
</Button>
|
<Text $theme="primary">{t('Update document')}</Text>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{pad.abilities.destroy && (
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setIsModalUpdateOpen(true);
|
||||||
|
setIsDropOpen(false);
|
||||||
|
}}
|
||||||
|
color="primary-text"
|
||||||
|
icon={<span className="material-icons">edit</span>}
|
||||||
|
>
|
||||||
|
<Text $theme="primary">{t('Update document')}</Text>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsModalRemoveOpen(true);
|
setIsModalRemoveOpen(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user