🛂(frontend) disabled role not allowed to be assigned
We disable roles that the current user is not allowed to assign when sharing a document. This prevents users from selecting roles they cannot actually assign, improving the user experience and reducing confusion.
This commit is contained in:
committed by
Manuel Raynaud
parent
1292c33a58
commit
b069310bf0
@@ -132,5 +132,6 @@ export interface AccessRequest {
|
||||
partial_update: boolean;
|
||||
retrieve: boolean;
|
||||
accept: boolean;
|
||||
set_role_to: Role[];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,12 +90,14 @@ export const DocRoleDropdown = ({
|
||||
const roles: DropdownMenuOption[] = Object.keys(translatedRoles).map(
|
||||
(key, index) => {
|
||||
const isLast = index === Object.keys(translatedRoles).length - 1;
|
||||
const isRoleAllowed = rolesAllowed?.includes(key as Role) ?? true;
|
||||
|
||||
return {
|
||||
label: transRole(key as Role),
|
||||
callback: () => onSelectRole?.(key as Role),
|
||||
isSelected: currentRole === (key as Role),
|
||||
showSeparator: isLast,
|
||||
disabled: isLastOwner && key !== 'owner',
|
||||
disabled: (isLastOwner && key !== 'owner') || !isRoleAllowed,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
@@ -77,6 +77,7 @@ const DocShareAccessRequestItem = ({ doc, accessRequest }: Props) => {
|
||||
currentRole={role}
|
||||
onSelectRole={setRole}
|
||||
canUpdate={doc.abilities.accesses_manage}
|
||||
rolesAllowed={accessRequest.abilities.set_role_to}
|
||||
/>
|
||||
<Button
|
||||
color="tertiary"
|
||||
|
||||
Reference in New Issue
Block a user