Skip to content

Commit 97d5177

Browse files
committed
add tooltip for server selection
1 parent 1732587 commit 97d5177

2 files changed

Lines changed: 36 additions & 8 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/components/mcp/mcp.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ interface McpDeployProps {
5858
onAddedToServer?: () => void
5959
onSubmittingChange?: (submitting: boolean) => void
6060
onCanSaveChange?: (canSave: boolean) => void
61+
onSaveDisabledReasonChange?: (reason: string | null) => void
6162
onActiveServerChange?: (serverId: string | null) => void
6263
}
6364

@@ -128,6 +129,7 @@ export function McpDeploy({
128129
onAddedToServer,
129130
onSubmittingChange,
130131
onCanSaveChange,
132+
onSaveDisabledReasonChange,
131133
onActiveServerChange,
132134
}: McpDeployProps) {
133135
const params = useParams()
@@ -280,10 +282,24 @@ export function McpDeploy({
280282
hasServerSelectionChanges ||
281283
(hasToolConfigurationChanges && selectedServerIdsForForm.length > 0)
282284

285+
// Explain the greyed Save when the tool name is valid but no server is chosen (and none is saved
286+
// to remove) — the one disabled state with no inline guidance beside the field.
287+
const saveDisabledReason = useMemo(() => {
288+
if (!toolName.trim() || toolNameError) return null
289+
if (selectedServerIdsForForm.length === 0 && selectedServerIds.length === 0) {
290+
return 'Select a server to save this tool'
291+
}
292+
return null
293+
}, [toolName, toolNameError, selectedServerIdsForForm, selectedServerIds])
294+
283295
useEffect(() => {
284296
onCanSaveChange?.(hasChanges && !!toolName.trim() && !toolNameError)
285297
}, [hasChanges, toolName, toolNameError, onCanSaveChange])
286298

299+
useEffect(() => {
300+
onSaveDisabledReasonChange?.(saveDisabledReason)
301+
}, [saveDisabledReason, onSaveDisabledReasonChange])
302+
287303
useEffect(() => {
288304
onActiveServerChange?.(selectedServerIdsForForm[0] ?? null)
289305
}, [selectedServerIdsForForm, onActiveServerChange])

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/components/deploy-modal/deploy-modal.tsx

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
ModalTabsContent,
2121
ModalTabsList,
2222
ModalTabsTrigger,
23+
Tooltip,
2324
} from '@/components/emcn'
2425
import { getBaseUrl } from '@/lib/core/utils/urls'
2526
import { getInputFormatExample as getInputFormatExampleUtil } from '@/lib/workflows/operations/deployment-utils'
@@ -141,6 +142,7 @@ export function DeployModal({
141142
const [undeployTargetWorkflowId, setUndeployTargetWorkflowId] = useState<string | null>(null)
142143
const [mcpToolSubmitting, setMcpToolSubmitting] = useState(false)
143144
const [mcpToolCanSave, setMcpToolCanSave] = useState(false)
145+
const [mcpToolSaveDisabledReason, setMcpToolSaveDisabledReason] = useState<string | null>(null)
144146
const [mcpActiveServerId, setMcpActiveServerId] = useState<string | null>(null)
145147
const [a2aSubmitting, setA2aSubmitting] = useState(false)
146148
const [a2aCanSave, setA2aCanSave] = useState(false)
@@ -673,6 +675,7 @@ export function DeployModal({
673675
isLoadingDeployedState={isLoadingDeployedState}
674676
onSubmittingChange={setMcpToolSubmitting}
675677
onCanSaveChange={setMcpToolCanSave}
678+
onSaveDisabledReasonChange={setMcpToolSaveDisabledReason}
676679
onActiveServerChange={setMcpActiveServerId}
677680
/>
678681
)}
@@ -782,14 +785,23 @@ export function DeployModal({
782785
>
783786
Manage
784787
</Button>
785-
<Button
786-
type='button'
787-
variant='tertiary'
788-
onClick={handleMcpToolFormSubmit}
789-
disabled={mcpToolSubmitting || !mcpToolCanSave}
790-
>
791-
{mcpToolSubmitting ? 'Saving...' : 'Save Tool'}
792-
</Button>
788+
<Tooltip.Root>
789+
<Tooltip.Trigger asChild>
790+
<span>
791+
<Button
792+
type='button'
793+
variant='tertiary'
794+
onClick={handleMcpToolFormSubmit}
795+
disabled={mcpToolSubmitting || !mcpToolCanSave}
796+
>
797+
{mcpToolSubmitting ? 'Saving...' : 'Save Tool'}
798+
</Button>
799+
</span>
800+
</Tooltip.Trigger>
801+
{mcpToolSaveDisabledReason && (
802+
<Tooltip.Content>{mcpToolSaveDisabledReason}</Tooltip.Content>
803+
)}
804+
</Tooltip.Root>
793805
</div>
794806
</ModalFooter>
795807
)}

0 commit comments

Comments
 (0)