Skip to content

Commit 0665b93

Browse files
committed
fix(admin): address review feedback on admin tab
- Fix superUserModeEnabled default to false (matches sidebar behavior) - Reset banReason when switching ban target to prevent state bleed - Guard admin section render with session role check for direct URL access
1 parent 6f54337 commit 0665b93

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

apps/sim/app/workspace/[workspaceId]/settings/[section]/settings.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dynamic from 'next/dynamic'
44
import { useSearchParams } from 'next/navigation'
55
import { Skeleton } from '@/components/emcn'
6+
import { useSession } from '@/lib/auth/auth-client'
67
import { AdminSkeleton } from '@/app/workspace/[workspaceId]/settings/components/admin/admin-skeleton'
78
import { ApiKeysSkeleton } from '@/app/workspace/[workspaceId]/settings/components/api-keys/api-key-skeleton'
89
import { BYOKSkeleton } from '@/app/workspace/[workspaceId]/settings/components/byok/byok-skeleton'
@@ -157,9 +158,15 @@ interface SettingsPageProps {
157158
export function SettingsPage({ section }: SettingsPageProps) {
158159
const searchParams = useSearchParams()
159160
const mcpServerId = searchParams.get('mcpServerId')
161+
const { data: session } = useSession()
160162

163+
const isAdminRole = session?.user?.role === 'admin'
161164
const effectiveSection =
162-
!isBillingEnabled && (section === 'subscription' || section === 'team') ? 'general' : section
165+
!isBillingEnabled && (section === 'subscription' || section === 'team')
166+
? 'general'
167+
: section === 'admin' && !isAdminRole
168+
? 'general'
169+
: section
163170

164171
const label =
165172
allNavigationItems.find((item) => item.id === effectiveSection)?.label ?? effectiveSection

apps/sim/app/workspace/[workspaceId]/settings/components/admin/admin.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export function Admin() {
8383
<Label htmlFor='super-user-mode'>Super admin mode</Label>
8484
<Switch
8585
id='super-user-mode'
86-
checked={settings?.superUserModeEnabled ?? true}
86+
checked={settings?.superUserModeEnabled ?? false}
8787
onCheckedChange={handleSuperUserModeToggle}
8888
/>
8989
</div>
@@ -255,7 +255,10 @@ export function Admin() {
255255
<Button
256256
variant='active'
257257
className='h-[28px] px-[8px] text-[12px] text-[var(--text-error)]'
258-
onClick={() => setBanUserId(u.id)}
258+
onClick={() => {
259+
setBanUserId(u.id)
260+
setBanReason('')
261+
}}
259262
disabled={actionPending && pendingUserId === u.id}
260263
>
261264
Ban

0 commit comments

Comments
 (0)