diff --git a/web/src/app/app/settings/users/[userId]/_overview/UserDefaultAccess.tsx b/web/src/app/app/settings/users/[userId]/_overview/UserDefaultAccess.tsx index 929944e23..dbd085234 100644 --- a/web/src/app/app/settings/users/[userId]/_overview/UserDefaultAccess.tsx +++ b/web/src/app/app/settings/users/[userId]/_overview/UserDefaultAccess.tsx @@ -1,16 +1,20 @@ -import { OrganizationUser, useUpdateUser } from '@/api'; +import { type BusterUser, type OrganizationUser, useUpdateUser } from '@/api'; import React from 'react'; import { Text, Title } from '@/components/text'; import { Card, Select } from 'antd'; import { useMemoizedFn } from 'ahooks'; +import { AppTooltip } from '@/components'; export const UserDefaultAccess: React.FC<{ user: OrganizationUser; isAdmin: boolean; + myUser: BusterUser; refetchUser: () => void; -}> = ({ user, isAdmin, refetchUser }) => { +}> = ({ user, isAdmin, myUser, refetchUser }) => { const { mutateAsync, isPending } = useUpdateUser(); + const userIsMe = user.id === myUser.id; + const onChange = useMemoizedFn(async (value: string) => { await mutateAsync({ userId: user.id, role: value as OrganizationUser['role'] }); refetchUser(); @@ -25,6 +29,7 @@ export const UserDefaultAccess: React.FC<{ onChange={onChange} isLoading={isPending} isAdmin={isAdmin} + userIsMe={userIsMe} /> ); @@ -42,25 +47,38 @@ const DefaultAccessCard = React.memo( role, onChange, isLoading, - isAdmin + isAdmin, + userIsMe }: { role: OrganizationUser['role']; onChange: (role: OrganizationUser['role']) => void; isLoading: boolean; isAdmin: boolean; + userIsMe: boolean; }) => { + const isDisabled = !isAdmin || userIsMe; + return (
Default Access - +
); diff --git a/web/src/app/app/settings/users/[userId]/_overview/UserOverviewController.tsx b/web/src/app/app/settings/users/[userId]/_overview/UserOverviewController.tsx index 241c66de0..8ae4c904e 100644 --- a/web/src/app/app/settings/users/[userId]/_overview/UserOverviewController.tsx +++ b/web/src/app/app/settings/users/[userId]/_overview/UserOverviewController.tsx @@ -10,12 +10,13 @@ import { UserDatasetSearch } from './UserDatasetSearch'; export const UserOverviewController = React.memo(({ userId }: { userId: string }) => { const { data: user, refetch: refetchUser } = useGetUser({ userId }); const isAdmin = useUserConfigContextSelector((x) => x.isAdmin); + const myUser = useUserConfigContextSelector((x) => x.user); - if (!user) return null; + if (!user || !myUser) return null; return ( <> - + diff --git a/web/src/app/app/settings/users/[userId]/permission-groups/UserPermissionGroupsListContainer.tsx b/web/src/app/app/settings/users/[userId]/permission-groups/UserPermissionGroupsListContainer.tsx index 58136ff6f..e7c71e53a 100644 --- a/web/src/app/app/settings/users/[userId]/permission-groups/UserPermissionGroupsListContainer.tsx +++ b/web/src/app/app/settings/users/[userId]/permission-groups/UserPermissionGroupsListContainer.tsx @@ -1,8 +1,4 @@ -import { - useUpdateUserPermissionGroups, - useUpdateUserTeams, - type BusterUserPermissionGroup -} from '@/api/buster_rest'; +import { useUpdateUserPermissionGroups, type BusterUserPermissionGroup } from '@/api/buster_rest'; import { PermissionAssignedCell } from '@/app/app/_components/PermissionComponents'; import { BusterInfiniteList,