feat: gate custom step creation tab by permission
Viewers who cannot create steps will only see the "Browse Library" tab in the CustomStepModal, hiding the "Type My Own" creation form. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { X } from 'lucide-react'
|
import { X } from 'lucide-react'
|
||||||
import { cn } from '@/lib/utils'
|
import { cn } from '@/lib/utils'
|
||||||
|
import { usePermissions } from '@/hooks/usePermissions'
|
||||||
import { StepForm } from './StepForm'
|
import { StepForm } from './StepForm'
|
||||||
import { StepLibraryBrowser } from './StepLibraryBrowser'
|
import { StepLibraryBrowser } from './StepLibraryBrowser'
|
||||||
import type { Step, StepCreate } from '@/types/step'
|
import type { Step, StepCreate } from '@/types/step'
|
||||||
@@ -30,7 +31,8 @@ interface CustomStepModalProps {
|
|||||||
type Tab = 'create' | 'browse'
|
type Tab = 'create' | 'browse'
|
||||||
|
|
||||||
export function CustomStepModal({ isOpen, onClose, onInsertStep }: CustomStepModalProps) {
|
export function CustomStepModal({ isOpen, onClose, onInsertStep }: CustomStepModalProps) {
|
||||||
const [activeTab, setActiveTab] = useState<Tab>('create')
|
const { canCreateSteps } = usePermissions()
|
||||||
|
const [activeTab, setActiveTab] = useState<Tab>(canCreateSteps ? 'create' : 'browse')
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
|
|
||||||
@@ -78,17 +80,19 @@ export function CustomStepModal({ isOpen, onClose, onInsertStep }: CustomStepMod
|
|||||||
|
|
||||||
{/* Tabs */}
|
{/* Tabs */}
|
||||||
<div className="flex border-b border-border">
|
<div className="flex border-b border-border">
|
||||||
<button
|
{canCreateSteps && (
|
||||||
onClick={() => setActiveTab('create')}
|
<button
|
||||||
className={cn(
|
onClick={() => setActiveTab('create')}
|
||||||
'flex-1 px-4 py-3 text-sm font-medium transition-colors',
|
className={cn(
|
||||||
activeTab === 'create'
|
'flex-1 px-4 py-3 text-sm font-medium transition-colors',
|
||||||
? 'border-b-2 border-primary bg-primary/5 text-primary'
|
activeTab === 'create'
|
||||||
: 'text-muted-foreground hover:bg-muted/50 hover:text-foreground'
|
? 'border-b-2 border-primary bg-primary/5 text-primary'
|
||||||
)}
|
: 'text-muted-foreground hover:bg-muted/50 hover:text-foreground'
|
||||||
>
|
)}
|
||||||
Type My Own
|
>
|
||||||
</button>
|
Type My Own
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
<button
|
<button
|
||||||
onClick={() => setActiveTab('browse')}
|
onClick={() => setActiveTab('browse')}
|
||||||
className={cn(
|
className={cn(
|
||||||
|
|||||||
Reference in New Issue
Block a user