🩹(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

@@ -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,
};