🏷️(frontend) improve props currentDocRole
props of currentDocRole is now more accurate.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { Doc, Role } from './types';
|
||||
|
||||
export const currentDocRole = (doc: Doc): Role => {
|
||||
return doc.abilities.destroy
|
||||
export const currentDocRole = (abilities: Doc['abilities']): Role => {
|
||||
return abilities.destroy
|
||||
? Role.OWNER
|
||||
: doc.abilities.manage_accesses
|
||||
: abilities.manage_accesses
|
||||
? Role.ADMIN
|
||||
: doc.abilities.partial_update
|
||||
: abilities.partial_update
|
||||
? Role.EDITOR
|
||||
: Role.READER;
|
||||
};
|
||||
|
||||
@@ -115,7 +115,7 @@ export const DocToolBox = ({ doc }: DocToolBoxProps) => {
|
||||
<ModalAddMembers
|
||||
onClose={() => setIsModalAddMembersOpen(false)}
|
||||
doc={doc}
|
||||
currentRole={currentDocRole(doc)}
|
||||
currentRole={currentDocRole(doc.abilities)}
|
||||
/>
|
||||
)}
|
||||
{isModalPDFOpen && (
|
||||
|
||||
@@ -162,7 +162,9 @@ export const DocsGrid = () => {
|
||||
renderCell: ({ row }) => {
|
||||
return (
|
||||
<StyledLink href={`/docs/${row.id}`}>
|
||||
<Text $weight="bold">{transRole(currentDocRole(row))}</Text>
|
||||
<Text $weight="bold">
|
||||
{transRole(currentDocRole(row.abilities))}
|
||||
</Text>
|
||||
</StyledLink>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -110,7 +110,7 @@ export const MemberGrid = ({ doc }: MemberGridProps) => {
|
||||
<MemberAction
|
||||
doc={doc}
|
||||
access={row}
|
||||
currentRole={currentDocRole(doc)}
|
||||
currentRole={currentDocRole(doc.abilities)}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user