Skip to content

Commit eca0310

Browse files
author
Temporary User
committed
fix(dashboard): hide "Add channel" button for users without CreateChannel permission
Wrap the "Add channel" menu item in PermissionGuard to only show it to users with the CreateChannel permission. Fixes #4056
1 parent 4582200 commit eca0310

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

packages/dashboard/src/lib/components/layout/channel-switcher.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ChevronsUpDown, Languages, Plus } from 'lucide-react';
22

33
import { ChannelCodeLabel } from '@/vdb/components/shared/channel-code-label.js';
4+
import { PermissionGuard } from '@/vdb/components/shared/permission-guard.js';
45
import {
56
DropdownMenu,
67
DropdownMenuContent,
@@ -194,17 +195,19 @@ export function ChannelSwitcher() {
194195
orderedChannels.length > 1 && <DropdownMenuSeparator />}
195196
</div>
196197
))}
197-
<DropdownMenuSeparator />
198-
<DropdownMenuItem className="gap-2 p-2 cursor-pointer" asChild>
199-
<Link to={'/channels/new'}>
200-
<div className="bg-background flex size-6 items-center justify-center rounded-md border">
201-
<Plus className="size-4" />
202-
</div>
203-
<div className="text-muted-foreground font-medium">
204-
<Trans>Add channel</Trans>
205-
</div>
206-
</Link>
207-
</DropdownMenuItem>
198+
<PermissionGuard requires={['CreateChannel']}>
199+
<DropdownMenuSeparator />
200+
<DropdownMenuItem className="gap-2 p-2 cursor-pointer" asChild>
201+
<Link to={'/channels/new'}>
202+
<div className="bg-background flex size-6 items-center justify-center rounded-md border">
203+
<Plus className="size-4" />
204+
</div>
205+
<div className="text-muted-foreground font-medium">
206+
<Trans>Add channel</Trans>
207+
</div>
208+
</Link>
209+
</DropdownMenuItem>
210+
</PermissionGuard>
208211
</DropdownMenuContent>
209212
</DropdownMenu>
210213
</SidebarMenuItem>

0 commit comments

Comments
 (0)