mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-25 19:15:18 +02:00
Merge pull request #1428 from guangyang1206/fix/extract-shared-haspermission-helper-1366
refactor: extract shared hasPermission helper (MODSetter/SurfSense#1366)
This commit is contained in:
commit
ee87747b37
3 changed files with 41 additions and 8 deletions
|
|
@ -31,7 +31,7 @@ import {
|
|||
deleteMemberMutationAtom,
|
||||
updateMemberMutationAtom,
|
||||
} from "@/atoms/members/members-mutation.atoms";
|
||||
import { membersAtom, myAccessAtom } from "@/atoms/members/members-query.atoms";
|
||||
import { membersAtom, myAccessAtom, canPerform } from "@/atoms/members/members-query.atoms";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
|
|
@ -126,14 +126,9 @@ export function TeamContent({ searchSpaceId }: TeamContentProps) {
|
|||
const { data: access = null, isLoading: accessLoading } = useAtomValue(myAccessAtom);
|
||||
|
||||
const hasPermission = useCallback(
|
||||
(permission: string) => {
|
||||
if (!access) return false;
|
||||
if (access.is_owner) return true;
|
||||
return access.permissions?.includes(permission) ?? false;
|
||||
},
|
||||
(permission: string) => canPerform(access, permission),
|
||||
[access]
|
||||
);
|
||||
|
||||
const { data: members = [], isLoading: membersLoading } = useAtomValue(membersAtom);
|
||||
|
||||
const { mutateAsync: updateMember } = useAtomValue(updateMemberMutationAtom);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue