Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export interface McpServerFormModalProps {
allowedMcpDomains: string[] | null
domainPolicyUnavailable?: boolean
domainPolicyError?: string
/** False locks the URL field: the server refuses a destination change from a non-admin. */
canChangeDestination?: boolean
}

const ENV_VAR_PATTERN = /\{\{[^{}]+\}\}/
Expand Down Expand Up @@ -130,6 +132,7 @@ interface FormattedInputProps {
envVarProps: EnvVarDropdownConfig
availableEnvVars?: Set<string>
className?: string
disabled?: boolean
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
onScroll: (scrollLeft: number) => void
}
Expand All @@ -143,6 +146,7 @@ function FormattedInput({
envVarProps,
availableEnvVars,
className,
disabled,
onChange,
onScroll,
}: FormattedInputProps) {
Expand All @@ -159,12 +163,18 @@ function FormattedInput({
ref={ref}
placeholder={placeholder}
value={value}
disabled={disabled}
onChange={onChange}
onScroll={handleScroll}
onInput={handleScroll}
inputClassName='font-sans text-transparent caret-[var(--text-primary)]'
/>
<div className='pointer-events-none absolute inset-0 flex items-center overflow-hidden px-2 py-1.5 font-sans text-sm'>
<div
className={cn(
'pointer-events-none absolute inset-0 flex items-center overflow-hidden px-2 py-1.5 font-sans text-sm',
disabled && 'opacity-50'
)}
>
<div className='whitespace-nowrap' style={{ transform: `translateX(-${scrollLeft}px)` }}>
{formatDisplayText(value, { availableEnvVars })}
</div>
Expand Down Expand Up @@ -316,6 +326,7 @@ export function McpServerFormModal({
allowedMcpDomains,
domainPolicyUnavailable = false,
domainPolicyError,
canChangeDestination = true,
}: McpServerFormModalProps) {
const urlInputRef = useRef<HTMLInputElement>(null)

Expand Down Expand Up @@ -715,6 +726,9 @@ export function McpServerFormModal({
type='custom'
title='Server URL'
error={isDomainBlocked ? 'Domain not permitted by server policy' : undefined}
hint={
canChangeDestination ? undefined : 'Only workspace admins can change the server URL'
}
>
<FormattedInput
ref={urlInputRef}
Expand All @@ -730,6 +744,7 @@ export function McpServerFormModal({
onClose: resetEnvVarState,
}}
availableEnvVars={availableEnvVars}
disabled={!canChangeDestination}
onChange={(e) => handleInputChange('url', e.target.value)}
onScroll={setUrlScrollLeft}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ export function MCP() {
allowedMcpDomains={allowedMcpDomains}
domainPolicyUnavailable={domainPolicyUnavailable}
domainPolicyError={domainPolicyError}
canChangeDestination={workspacePermissions.canAdmin}
/>
)}
{deleteConfirmModal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,7 @@ export function Table({
label: 'Rename',
icon: Pencil,
onClick: handleStartTableRename,
disabled: userPermissions.canEdit !== true,
},
...(userPermissions.canAdmin
? [
Expand Down
Loading