diff --git a/src/frontend/apps/e2e/__tests__/app-impress/common.ts b/src/frontend/apps/e2e/__tests__/app-impress/common.ts
index 0aea93c5..e82d17be 100644
--- a/src/frontend/apps/e2e/__tests__/app-impress/common.ts
+++ b/src/frontend/apps/e2e/__tests__/app-impress/common.ts
@@ -28,6 +28,7 @@ export const createPad = async (
padName: string,
browserName: string,
length: number,
+ isPublic: boolean = false,
) => {
const panel = page.getByLabel('Pads panel').first();
const buttonCreate = page.getByRole('button', { name: 'Create the pad' });
@@ -37,6 +38,11 @@ export const createPad = async (
for (let i = 0; i < randomPads.length; i++) {
await panel.getByRole('button', { name: 'Add a pad' }).click();
await page.getByText('Pad name').fill(randomPads[i]);
+
+ if (isPublic) {
+ await page.getByText('Is it public ?').click();
+ }
+
await expect(buttonCreate).toBeEnabled();
await buttonCreate.click();
await expect(panel.locator('li').getByText(randomPads[i])).toBeVisible();
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 be17b20c..1fc32645 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
@@ -47,4 +47,59 @@ test.describe('Pad Tools', () => {
expect(pdfText).toContain('La directrice'); // This is the template text
expect(pdfText).toContain('Hello World'); // This is the pad text
});
+
+ test('it updates the pad', async ({ page, browserName }) => {
+ const [randomPad] = await createPad(
+ page,
+ 'pad-update',
+ browserName,
+ 1,
+ true,
+ );
+ await expect(page.locator('h2').getByText(randomPad)).toBeVisible();
+
+ await page.getByLabel('Open the document options').click();
+ await page
+ .getByRole('button', {
+ name: 'Update document',
+ })
+ .click();
+
+ await expect(
+ page.locator('h2').getByText(`Update document "${randomPad}"`),
+ ).toBeVisible();
+
+ await expect(
+ page.getByRole('checkbox', { name: 'Is it public ?' }),
+ ).toBeChecked();
+
+ await page.getByText('Pad name').fill(`${randomPad}-updated`);
+ await page.getByText('Is it public ?').click();
+
+ await page
+ .getByRole('button', {
+ name: 'Validate the modification',
+ })
+ .click();
+
+ await expect(
+ page.getByText('The document has been updated.'),
+ ).toBeVisible();
+
+ const panel = page.getByLabel('Pads panel').first();
+ await expect(
+ panel.locator('li').getByText(`${randomPad}-updated`),
+ ).toBeVisible();
+
+ await page.getByLabel('Open the document options').click();
+ await page
+ .getByRole('button', {
+ name: 'Update document',
+ })
+ .click();
+
+ await expect(
+ page.getByRole('checkbox', { name: 'Is it public ?' }),
+ ).not.toBeChecked();
+ });
});
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 41bc6204..1c5bf1b8 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
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { Box, DropButton, IconOptions, Text } from '@/components';
import { Pad } from '@/features/pads/pad';
+import { ModalUpdatePad } from '@/features/pads/pads-create';
import { TemplatesOrdering, useTemplates } from '../api/useTemplates';
@@ -18,6 +19,7 @@ export const PadToolBox = ({ pad }: PadToolBoxProps) => {
const { data: templates } = useTemplates({
ordering: TemplatesOrdering.BY_CREATED_ON_DESC,
});
+ const [isModalUpdateOpen, setIsModalUpdateOpen] = useState(false);
const [isModalPDFOpen, setIsModalPDFOpen] = useState(false);
const [isDropOpen, setIsDropOpen] = useState(false);
@@ -44,13 +46,23 @@ export const PadToolBox = ({ pad }: PadToolBoxProps) => {
button={
}
onOpenChange={(isOpen) => setIsDropOpen(isOpen)}
isOpen={isDropOpen}
>
+
);
};
diff --git a/src/frontend/apps/impress/src/features/pads/pads-create/assets/icon-edit.svg b/src/frontend/apps/impress/src/features/pads/pads-create/assets/icon-edit.svg
new file mode 100644
index 00000000..5e316214
--- /dev/null
+++ b/src/frontend/apps/impress/src/features/pads/pads-create/assets/icon-edit.svg
@@ -0,0 +1,6 @@
+
diff --git a/src/frontend/apps/impress/src/features/pads/pads-create/components/ModalUpdatePad.tsx b/src/frontend/apps/impress/src/features/pads/pads-create/components/ModalUpdatePad.tsx
new file mode 100644
index 00000000..dfdc1970
--- /dev/null
+++ b/src/frontend/apps/impress/src/features/pads/pads-create/components/ModalUpdatePad.tsx
@@ -0,0 +1,116 @@
+import {
+ Button,
+ Modal,
+ ModalSize,
+ Switch,
+ VariantType,
+ useToastProvider,
+} from '@openfun/cunningham-react';
+import { t } from 'i18next';
+import { useState } from 'react';
+
+import { Box, Text } from '@/components';
+import useCunninghamTheme from '@/cunningham/useCunninghamTheme';
+import { KEY_PAD, Pad } from '@/features/pads/pad';
+import { KEY_LIST_PAD } from '@/features/pads/pads-panel';
+
+import { useUpdatePad } from '../api/useUpdatePad';
+import IconEdit from '../assets/icon-edit.svg';
+
+import { InputPadName } from './InputPadName';
+
+interface ModalUpdatePadProps {
+ onClose: () => void;
+ pad: Pad;
+}
+
+export const ModalUpdatePad = ({ onClose, pad }: ModalUpdatePadProps) => {
+ const { colorsTokens } = useCunninghamTheme();
+ const [title, setTitle] = useState(pad.title);
+ const { toast } = useToastProvider();
+ const [padPublic, setPadPublic] = useState(pad.is_public);
+
+ const {
+ mutate: updatePad,
+ isError,
+ isPending,
+ error,
+ } = useUpdatePad({
+ onSuccess: () => {
+ toast(t('The document has been updated.'), VariantType.SUCCESS, {
+ duration: 4000,
+ });
+ onClose();
+ },
+ listInvalideQueries: [KEY_PAD, KEY_LIST_PAD],
+ });
+
+ return (
+ onClose()}
+ >
+ {t('Cancel')}
+
+ }
+ onClose={() => onClose()}
+ rightActions={
+
+ }
+ size={ModalSize.MEDIUM}
+ title={
+
+
+
+ {t('Update document "{{documentTitle}}"', {
+ documentTitle: pad.title,
+ })}
+
+
+ }
+ >
+
+
+ {t('Enter the new name of the selected document.')}
+
+
+
+
+ setPadPublic(!padPublic)}
+ />
+
+
+
+ );
+};
diff --git a/src/frontend/apps/impress/src/features/pads/pads-create/components/index.ts b/src/frontend/apps/impress/src/features/pads/pads-create/components/index.ts
index 0fd79adc..22282015 100644
--- a/src/frontend/apps/impress/src/features/pads/pads-create/components/index.ts
+++ b/src/frontend/apps/impress/src/features/pads/pads-create/components/index.ts
@@ -1 +1,2 @@
export * from './CardCreatePad';
+export * from './ModalUpdatePad';