mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
add deploy modal tabs config to perm groups
This commit is contained in:
@@ -25,6 +25,12 @@ const configSchema = z.object({
|
||||
disableMcpTools: z.boolean().optional(),
|
||||
disableCustomTools: z.boolean().optional(),
|
||||
hideTemplates: z.boolean().optional(),
|
||||
disableInvitations: z.boolean().optional(),
|
||||
hideDeployApi: z.boolean().optional(),
|
||||
hideDeployMcp: z.boolean().optional(),
|
||||
hideDeployA2a: z.boolean().optional(),
|
||||
hideDeployChatbot: z.boolean().optional(),
|
||||
hideDeployTemplate: z.boolean().optional(),
|
||||
})
|
||||
|
||||
const updateSchema = z.object({
|
||||
|
||||
@@ -26,6 +26,12 @@ const configSchema = z.object({
|
||||
disableMcpTools: z.boolean().optional(),
|
||||
disableCustomTools: z.boolean().optional(),
|
||||
hideTemplates: z.boolean().optional(),
|
||||
disableInvitations: z.boolean().optional(),
|
||||
hideDeployApi: z.boolean().optional(),
|
||||
hideDeployMcp: z.boolean().optional(),
|
||||
hideDeployA2a: z.boolean().optional(),
|
||||
hideDeployChatbot: z.boolean().optional(),
|
||||
hideDeployTemplate: z.boolean().optional(),
|
||||
})
|
||||
|
||||
const createSchema = z.object({
|
||||
|
||||
@@ -23,6 +23,7 @@ import { CreateApiKeyModal } from '@/app/workspace/[workspaceId]/w/components/si
|
||||
import { startsWithUuid } from '@/executor/constants'
|
||||
import { useApiKeys } from '@/hooks/queries/api-keys'
|
||||
import { useWorkspaceSettings } from '@/hooks/queries/workspace'
|
||||
import { usePermissionConfig } from '@/hooks/use-permission-config'
|
||||
import { useSettingsModalStore } from '@/stores/modals/settings/store'
|
||||
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||
import { useWorkflowStore } from '@/stores/workflows/workflow/store'
|
||||
@@ -113,16 +114,12 @@ export function DeployModal({
|
||||
const [existingChat, setExistingChat] = useState<ExistingChat | null>(null)
|
||||
const [isLoadingChat, setIsLoadingChat] = useState(false)
|
||||
|
||||
const [formSubmitting, setFormSubmitting] = useState(false)
|
||||
const [formExists, setFormExists] = useState(false)
|
||||
const [isFormValid, setIsFormValid] = useState(false)
|
||||
|
||||
const [chatSuccess, setChatSuccess] = useState(false)
|
||||
const [formSuccess, setFormSuccess] = useState(false)
|
||||
|
||||
const [isCreateKeyModalOpen, setIsCreateKeyModalOpen] = useState(false)
|
||||
const userPermissions = useUserPermissionsContext()
|
||||
const canManageWorkspaceKeys = userPermissions.canAdmin
|
||||
const { config: permissionConfig } = usePermissionConfig()
|
||||
const { data: apiKeysData, isLoading: isLoadingKeys } = useApiKeys(workflowWorkspaceId || '')
|
||||
const { data: workspaceSettingsData, isLoading: isLoadingSettings } = useWorkspaceSettings(
|
||||
workflowWorkspaceId || ''
|
||||
@@ -516,12 +513,6 @@ export function DeployModal({
|
||||
setTimeout(() => setChatSuccess(false), 2000)
|
||||
}
|
||||
|
||||
const handleFormDeployed = async () => {
|
||||
await handlePostDeploymentUpdate()
|
||||
setFormSuccess(true)
|
||||
setTimeout(() => setFormSuccess(false), 2000)
|
||||
}
|
||||
|
||||
const handlePostDeploymentUpdate = async () => {
|
||||
if (!workflowId) return
|
||||
|
||||
@@ -630,17 +621,6 @@ export function DeployModal({
|
||||
deleteTrigger?.click()
|
||||
}, [])
|
||||
|
||||
const handleFormFormSubmit = useCallback(() => {
|
||||
const form = document.getElementById('form-deploy-form') as HTMLFormElement
|
||||
form?.requestSubmit()
|
||||
}, [])
|
||||
|
||||
const handleFormDelete = useCallback(() => {
|
||||
const form = document.getElementById('form-deploy-form')
|
||||
const deleteTrigger = form?.querySelector('[data-delete-trigger]') as HTMLButtonElement
|
||||
deleteTrigger?.click()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<Modal open={open} onOpenChange={handleCloseModal}>
|
||||
@@ -654,12 +634,22 @@ export function DeployModal({
|
||||
>
|
||||
<ModalTabsList activeValue={activeTab}>
|
||||
<ModalTabsTrigger value='general'>General</ModalTabsTrigger>
|
||||
<ModalTabsTrigger value='api'>API</ModalTabsTrigger>
|
||||
<ModalTabsTrigger value='mcp'>MCP</ModalTabsTrigger>
|
||||
<ModalTabsTrigger value='a2a'>A2A</ModalTabsTrigger>
|
||||
<ModalTabsTrigger value='chat'>Chat</ModalTabsTrigger>
|
||||
{!permissionConfig.hideDeployApi && (
|
||||
<ModalTabsTrigger value='api'>API</ModalTabsTrigger>
|
||||
)}
|
||||
{!permissionConfig.hideDeployMcp && (
|
||||
<ModalTabsTrigger value='mcp'>MCP</ModalTabsTrigger>
|
||||
)}
|
||||
{!permissionConfig.hideDeployA2a && (
|
||||
<ModalTabsTrigger value='a2a'>A2A</ModalTabsTrigger>
|
||||
)}
|
||||
{!permissionConfig.hideDeployChatbot && (
|
||||
<ModalTabsTrigger value='chat'>Chat</ModalTabsTrigger>
|
||||
)}
|
||||
{/* <ModalTabsTrigger value='form'>Form</ModalTabsTrigger> */}
|
||||
<ModalTabsTrigger value='template'>Template</ModalTabsTrigger>
|
||||
{!permissionConfig.hideDeployTemplate && (
|
||||
<ModalTabsTrigger value='template'>Template</ModalTabsTrigger>
|
||||
)}
|
||||
</ModalTabsList>
|
||||
|
||||
<ModalBody className='min-h-0 flex-1'>
|
||||
|
||||
@@ -350,6 +350,36 @@ export function AccessControl() {
|
||||
category: 'Collaboration',
|
||||
configKey: 'disableInvitations' as const,
|
||||
},
|
||||
{
|
||||
id: 'hide-deploy-api',
|
||||
label: 'API',
|
||||
category: 'Deploy Tabs',
|
||||
configKey: 'hideDeployApi' as const,
|
||||
},
|
||||
{
|
||||
id: 'hide-deploy-mcp',
|
||||
label: 'MCP',
|
||||
category: 'Deploy Tabs',
|
||||
configKey: 'hideDeployMcp' as const,
|
||||
},
|
||||
{
|
||||
id: 'hide-deploy-a2a',
|
||||
label: 'A2A',
|
||||
category: 'Deploy Tabs',
|
||||
configKey: 'hideDeployA2a' as const,
|
||||
},
|
||||
{
|
||||
id: 'hide-deploy-chatbot',
|
||||
label: 'Chat',
|
||||
category: 'Deploy Tabs',
|
||||
configKey: 'hideDeployChatbot' as const,
|
||||
},
|
||||
{
|
||||
id: 'hide-deploy-template',
|
||||
label: 'Template',
|
||||
category: 'Deploy Tabs',
|
||||
configKey: 'hideDeployTemplate' as const,
|
||||
},
|
||||
],
|
||||
[]
|
||||
)
|
||||
@@ -926,7 +956,12 @@ export function AccessControl() {
|
||||
!editingConfig?.disableMcpTools &&
|
||||
!editingConfig?.disableCustomTools &&
|
||||
!editingConfig?.hideTraceSpans &&
|
||||
!editingConfig?.disableInvitations
|
||||
!editingConfig?.disableInvitations &&
|
||||
!editingConfig?.hideDeployApi &&
|
||||
!editingConfig?.hideDeployMcp &&
|
||||
!editingConfig?.hideDeployA2a &&
|
||||
!editingConfig?.hideDeployChatbot &&
|
||||
!editingConfig?.hideDeployTemplate
|
||||
setEditingConfig((prev) =>
|
||||
prev
|
||||
? {
|
||||
@@ -941,6 +976,11 @@ export function AccessControl() {
|
||||
disableCustomTools: allVisible,
|
||||
hideTraceSpans: allVisible,
|
||||
disableInvitations: allVisible,
|
||||
hideDeployApi: allVisible,
|
||||
hideDeployMcp: allVisible,
|
||||
hideDeployA2a: allVisible,
|
||||
hideDeployChatbot: allVisible,
|
||||
hideDeployTemplate: allVisible,
|
||||
}
|
||||
: prev
|
||||
)
|
||||
@@ -955,7 +995,12 @@ export function AccessControl() {
|
||||
!editingConfig?.disableMcpTools &&
|
||||
!editingConfig?.disableCustomTools &&
|
||||
!editingConfig?.hideTraceSpans &&
|
||||
!editingConfig?.disableInvitations
|
||||
!editingConfig?.disableInvitations &&
|
||||
!editingConfig?.hideDeployApi &&
|
||||
!editingConfig?.hideDeployMcp &&
|
||||
!editingConfig?.hideDeployA2a &&
|
||||
!editingConfig?.hideDeployChatbot &&
|
||||
!editingConfig?.hideDeployTemplate
|
||||
? 'Deselect All'
|
||||
: 'Select All'}
|
||||
</Button>
|
||||
|
||||
@@ -12,6 +12,12 @@ export interface PermissionGroupConfig {
|
||||
disableCustomTools: boolean
|
||||
hideTemplates: boolean
|
||||
disableInvitations: boolean
|
||||
// Deploy Modal Tabs
|
||||
hideDeployApi: boolean
|
||||
hideDeployMcp: boolean
|
||||
hideDeployA2a: boolean
|
||||
hideDeployChatbot: boolean
|
||||
hideDeployTemplate: boolean
|
||||
}
|
||||
|
||||
export const DEFAULT_PERMISSION_GROUP_CONFIG: PermissionGroupConfig = {
|
||||
@@ -27,6 +33,11 @@ export const DEFAULT_PERMISSION_GROUP_CONFIG: PermissionGroupConfig = {
|
||||
disableCustomTools: false,
|
||||
hideTemplates: false,
|
||||
disableInvitations: false,
|
||||
hideDeployApi: false,
|
||||
hideDeployMcp: false,
|
||||
hideDeployA2a: false,
|
||||
hideDeployChatbot: false,
|
||||
hideDeployTemplate: false,
|
||||
}
|
||||
|
||||
export function parsePermissionGroupConfig(config: unknown): PermissionGroupConfig {
|
||||
@@ -50,5 +61,10 @@ export function parsePermissionGroupConfig(config: unknown): PermissionGroupConf
|
||||
disableCustomTools: typeof c.disableCustomTools === 'boolean' ? c.disableCustomTools : false,
|
||||
hideTemplates: typeof c.hideTemplates === 'boolean' ? c.hideTemplates : false,
|
||||
disableInvitations: typeof c.disableInvitations === 'boolean' ? c.disableInvitations : false,
|
||||
hideDeployApi: typeof c.hideDeployApi === 'boolean' ? c.hideDeployApi : false,
|
||||
hideDeployMcp: typeof c.hideDeployMcp === 'boolean' ? c.hideDeployMcp : false,
|
||||
hideDeployA2a: typeof c.hideDeployA2a === 'boolean' ? c.hideDeployA2a : false,
|
||||
hideDeployChatbot: typeof c.hideDeployChatbot === 'boolean' ? c.hideDeployChatbot : false,
|
||||
hideDeployTemplate: typeof c.hideDeployTemplate === 'boolean' ? c.hideDeployTemplate : false,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user