Skip to content

Commit b1fec2a

Browse files
committed
added perms enforcement to workflow block header as well
1 parent b359357 commit b1fec2a

File tree

1 file changed

+13
-5
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input

1 file changed

+13
-5
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import {
3030
type OAuthProvider,
3131
type OAuthService,
3232
} from '@/lib/oauth'
33+
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
3334
import {
3435
CheckboxList,
3536
Code,
@@ -769,9 +770,10 @@ function WorkflowToolDeployBadge({
769770
}) {
770771
const { isDeployed, needsRedeploy, isLoading, refetch } = useChildDeployment(workflowId)
771772
const [isDeploying, setIsDeploying] = useState(false)
773+
const userPermissions = useUserPermissionsContext()
772774

773775
const deployWorkflow = useCallback(async () => {
774-
if (isDeploying || !workflowId) return
776+
if (isDeploying || !workflowId || !userPermissions.canAdmin) return
775777

776778
try {
777779
setIsDeploying(true)
@@ -796,7 +798,7 @@ function WorkflowToolDeployBadge({
796798
} finally {
797799
setIsDeploying(false)
798800
}
799-
}, [isDeploying, workflowId, refetch, onDeploySuccess])
801+
}, [isDeploying, workflowId, refetch, onDeploySuccess, userPermissions.canAdmin])
800802

801803
if (isLoading || (isDeployed && !needsRedeploy)) {
802804
return null
@@ -811,13 +813,13 @@ function WorkflowToolDeployBadge({
811813
<Tooltip.Trigger asChild>
812814
<Badge
813815
variant={!isDeployed ? 'red' : 'amber'}
814-
className='cursor-pointer'
816+
className={userPermissions.canAdmin ? 'cursor-pointer' : 'cursor-not-allowed'}
815817
size='sm'
816818
dot
817819
onClick={(e: React.MouseEvent) => {
818820
e.stopPropagation()
819821
e.preventDefault()
820-
if (!isDeploying) {
822+
if (!isDeploying && userPermissions.canAdmin) {
821823
deployWorkflow()
822824
}
823825
}}
@@ -826,7 +828,13 @@ function WorkflowToolDeployBadge({
826828
</Badge>
827829
</Tooltip.Trigger>
828830
<Tooltip.Content>
829-
<span className='text-sm'>{!isDeployed ? 'Click to deploy' : 'Click to redeploy'}</span>
831+
<span className='text-sm'>
832+
{!userPermissions.canAdmin
833+
? 'Admin permission required to deploy'
834+
: !isDeployed
835+
? 'Click to deploy'
836+
: 'Click to redeploy'}
837+
</span>
830838
</Tooltip.Content>
831839
</Tooltip.Root>
832840
)

0 commit comments

Comments
 (0)