🩹(frontend) add computed_link_reach on PUT link-configuration

By default a document is "restricted", a restricted
document cannot have a role "editor" or "reader".
With inheritance, a child document could have a computed
link reach different than "restricted" though.

We pass the computed link reach when we update the
link role, to be sure if follows the parent computed
link reach.
This commit is contained in:
Anthony LC
2025-08-14 12:57:12 +02:00
parent 63a2bde11e
commit cc4c67d15b
4 changed files with 18 additions and 9 deletions

View File

@@ -38,6 +38,7 @@ and this project adheres to
- 🐛(backend) allow editor to delete subpages #1296
- 🐛(frontend) fix dnd conflict with tree and Blocknote #1328
- 🐛(frontend) fix display bug on homepage #1332
- 🐛link role update #1287
## [3.5.0] - 2025-07-31

View File

@@ -52,6 +52,12 @@ test.describe('Inherited share accesses', () => {
await expect(docVisibilityCard.getByText('Connected')).toBeVisible();
await expect(docVisibilityCard.getByText('Reading')).toBeVisible();
await docVisibilityCard.getByText('Reading').click();
await page.getByRole('menuitem', { name: 'Editing' }).click();
await expect(docVisibilityCard.getByText('Reading')).toBeHidden();
await expect(docVisibilityCard.getByText('Editing')).toBeVisible();
// Verify inherited link
await docVisibilityCard.getByText('Connected').click();
await expect(
@@ -61,17 +67,13 @@ test.describe('Inherited share accesses', () => {
// Update child link
await page.getByRole('menuitem', { name: 'Public' }).click();
await docVisibilityCard.getByText('Reading').click();
await page.getByRole('menuitem', { name: 'Editing' }).click();
await expect(docVisibilityCard.getByText('Connected')).toBeHidden();
await expect(docVisibilityCard.getByText('Reading')).toBeHidden();
await expect(
docVisibilityCard.getByText('Public', {
exact: true,
}),
).toBeVisible();
await expect(docVisibilityCard.getByText('Editing')).toBeVisible();
await expect(
docVisibilityCard.getByText(
'The link sharing rules differ from the parent document',

View File

@@ -6,8 +6,8 @@ import { APIError, errorCauses, fetchAPI } from '@/api';
import { Doc, KEY_DOC } from '@/docs/doc-management';
import { useBroadcastStore } from '@/stores';
export type UpdateDocLinkParams = Pick<Doc, 'id'> &
Partial<Pick<Doc, 'link_role' | 'link_reach'>>;
export type UpdateDocLinkParams = Pick<Doc, 'id' | 'link_reach'> &
Partial<Pick<Doc, 'link_role'>>;
export const updateDocLink = async ({
id,

View File

@@ -17,6 +17,7 @@ import {
LinkReach,
LinkRole,
getDocLinkReach,
getDocLinkRole,
useDocUtils,
useUpdateDocLink,
} from '@/docs/doc-management';
@@ -36,7 +37,7 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => {
const { spacingsTokens, colorsTokens } = useCunninghamTheme();
const canManage = doc.abilities.accesses_manage;
const docLinkReach = getDocLinkReach(doc);
const docLinkRole = doc.computed_link_role ?? LinkRole.READER;
const docLinkRole = getDocLinkRole(doc);
const { isDesynchronized } = useDocUtils(doc);
const { linkModeTranslations, linkReachChoices, linkReachTranslations } =
useTranslatedShareSettings();
@@ -85,7 +86,12 @@ export const DocVisibility = ({ doc }: DocVisibilityProps) => {
const isDisabled = !options.includes(key);
return {
label: linkModeTranslations[key],
callback: () => updateDocLink({ id: doc.id, link_role: key }),
callback: () =>
updateDocLink({
id: doc.id,
link_role: key,
link_reach: docLinkReach,
}),
isSelected: docLinkRole === key,
disabled: isDisabled,
};