diff --git a/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts b/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts index 6540d54c..e8631c45 100644 --- a/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-impress/doc-header.spec.ts @@ -434,7 +434,9 @@ test.describe('Doc Header', () => { test('it pins a document', async ({ page, browserName }) => { const [docTitle] = await createDoc(page, `Pin doc`, browserName); - await page.getByLabel('Open the document options').click(); + await page + .getByRole('button', { name: 'Open the document options' }) + .click(); // Pin await page.getByText('push_pin').click(); @@ -453,11 +455,15 @@ test.describe('Doc Header', () => { await expect(leftPanelFavorites.getByText(docTitle)).toBeVisible(); await row.getByText(docTitle).click(); - await page.getByLabel('Open the document options').click(); + await page + .getByRole('button', { name: 'Open the document options' }) + .click(); // Unpin await page.getByText('Unpin').click(); - await page.getByLabel('Open the document options').click(); + await page + .getByRole('button', { name: 'Open the document options' }) + .click(); await expect(page.getByText('push_pin')).toBeVisible(); await page.goto('/'); diff --git a/src/frontend/apps/impress/src/features/docs/doc-management/types.tsx b/src/frontend/apps/impress/src/features/docs/doc-management/types.tsx index 7c8c2ea8..c6fd9f2c 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-management/types.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-management/types.tsx @@ -60,7 +60,7 @@ export interface Doc { path: string; is_favorite: boolean; link_reach: LinkReach; - link_role: LinkRole; + link_role?: LinkRole; nb_accesses_direct: number; nb_accesses_ancestors: number; computed_link_reach: LinkReach; diff --git a/src/frontend/apps/impress/src/features/docs/doc-management/utils.ts b/src/frontend/apps/impress/src/features/docs/doc-management/utils.ts index 1f1a68b9..2d43b68f 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-management/utils.ts +++ b/src/frontend/apps/impress/src/features/docs/doc-management/utils.ts @@ -1,7 +1,7 @@ import emojiRegex from 'emoji-regex'; import * as Y from 'yjs'; -import { Doc, LinkReach, LinkRole } from './types'; +import { Doc, LinkReach } from './types'; export const base64ToYDoc = (base64: string) => { const uint8Array = Buffer.from(base64, 'base64'); @@ -18,7 +18,7 @@ export const getDocLinkReach = (doc: Doc): LinkReach => { return doc.computed_link_reach ?? doc.link_reach; }; -export const getDocLinkRole = (doc: Doc): LinkRole => { +export const getDocLinkRole = (doc: Doc): Doc['link_role'] => { return doc.computed_link_role ?? doc.link_role; }; diff --git a/src/frontend/apps/impress/src/features/docs/doc-share/components/DocVisibility.tsx b/src/frontend/apps/impress/src/features/docs/doc-share/components/DocVisibility.tsx index dbcd3d2d..1315bc82 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-share/components/DocVisibility.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-share/components/DocVisibility.tsx @@ -54,6 +54,10 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => { const linkReachOptions: DropdownMenuOption[] = useMemo(() => { return Object.values(LinkReach).map((key) => { const isDisabled = doc.abilities.link_select_options[key] === undefined; + let linkRole = undefined; + if (key !== LinkReach.RESTRICTED) { + linkRole = docLinkRole; + } return { label: linkReachTranslations[key], @@ -61,6 +65,7 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => { updateDocLink({ id: doc.id, link_reach: key, + link_role: linkRole, }), isSelected: docLinkReach === key, disabled: isDisabled, @@ -70,6 +75,7 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => { doc.abilities.link_select_options, doc.id, docLinkReach, + docLinkRole, linkReachTranslations, updateDocLink, ]); @@ -78,7 +84,8 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => { (option) => option.disabled, ); - const showLinkRoleOptions = doc.computed_link_reach !== LinkReach.RESTRICTED; + const showLinkRoleOptions = + docLinkReach !== LinkReach.RESTRICTED && docLinkRole; const linkRoleOptions: DropdownMenuOption[] = useMemo(() => { const options = doc.abilities.link_select_options[docLinkReach] ?? []; @@ -175,26 +182,24 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => { {showLinkRoleOptions && ( - {docLinkReach !== LinkReach.RESTRICTED && ( - - - {linkModeTranslations[docLinkRole]} - - - )} + + + {linkModeTranslations[docLinkRole]} + + )}