mirror of
https://github.com/langgenius/dify.git
synced 2026-03-26 08:00:29 -04:00
Made-with: Cursor # Conflicts: # api/core/agent/cot_chat_agent_runner.py # api/core/agent/fc_agent_runner.py # api/core/memory/token_buffer_memory.py # api/core/variables/segments.py # api/core/workflow/file/file_manager.py # api/core/workflow/nodes/agent/agent_node.py # api/core/workflow/nodes/llm/llm_utils.py # api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py # api/core/workflow/workflow_entry.py # api/factories/variable_factory.py # api/pyproject.toml # api/services/variable_truncator.py # api/uv.lock # web/app/components/app/app-publisher/index.tsx # web/app/components/app/overview/settings/index.tsx # web/app/components/apps/app-card.tsx # web/app/components/apps/index.tsx # web/app/components/apps/list.tsx # web/app/components/base/chat/chat-with-history/header-in-mobile.tsx # web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx # web/app/components/base/features/new-feature-panel/file-upload/setting-content.tsx # web/app/components/base/features/new-feature-panel/moderation/moderation-setting-modal.tsx # web/app/components/base/features/new-feature-panel/text-to-speech/param-config-content.tsx # web/app/components/base/message-log-modal/index.tsx # web/app/components/base/switch/index.tsx # web/app/components/base/tab-slider-plain/index.tsx # web/app/components/explore/try-app/app-info/index.tsx # web/app/components/plugins/plugin-detail-panel/tool-selector/components/reasoning-config-form.tsx # web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/edit-card/required-switch.tsx # web/app/components/workflow/nodes/llm/panel.tsx # web/contract/router.ts # web/eslint-suppressions.json # web/i18n/fa-IR/workflow.json
79 lines
2.8 KiB
TypeScript
79 lines
2.8 KiB
TypeScript
'use client'
|
|
import type { FC } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import AlertTriangle from '@/app/components/base/icons/src/vender/solid/alertsAndFeedback/AlertTriangle'
|
|
import Input from '@/app/components/base/input'
|
|
import Switch from '@/app/components/base/switch'
|
|
import { API_PREFIX } from '@/config'
|
|
import { cn } from '@/utils/classnames'
|
|
|
|
type AuthenticationSectionProps = {
|
|
isDynamicRegistration: boolean
|
|
onDynamicRegistrationChange: (value: boolean) => void
|
|
clientID: string
|
|
onClientIDChange: (value: string) => void
|
|
credentials: string
|
|
onCredentialsChange: (value: string) => void
|
|
}
|
|
|
|
const AuthenticationSection: FC<AuthenticationSectionProps> = ({
|
|
isDynamicRegistration,
|
|
onDynamicRegistrationChange,
|
|
clientID,
|
|
onClientIDChange,
|
|
credentials,
|
|
onCredentialsChange,
|
|
}) => {
|
|
const { t } = useTranslation()
|
|
|
|
return (
|
|
<>
|
|
<div>
|
|
<div className="mb-1 flex h-6 items-center">
|
|
<Switch
|
|
className="mr-2"
|
|
value={isDynamicRegistration}
|
|
onChange={onDynamicRegistrationChange}
|
|
/>
|
|
<span className="text-text-secondary system-sm-medium">{t('mcp.modal.useDynamicClientRegistration', { ns: 'tools' })}</span>
|
|
</div>
|
|
{!isDynamicRegistration && (
|
|
<div className="mt-2 flex gap-2 rounded-lg bg-state-warning-hover p-3">
|
|
<AlertTriangle className="mt-0.5 h-4 w-4 shrink-0 text-text-warning" />
|
|
<div className="text-text-secondary system-xs-regular">
|
|
<div className="mb-1">{t('mcp.modal.redirectUrlWarning', { ns: 'tools' })}</div>
|
|
<code className="block break-all rounded bg-state-warning-active px-2 py-1 text-text-secondary system-xs-medium">
|
|
{`${API_PREFIX}/mcp/oauth/callback`}
|
|
</code>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</div>
|
|
<div>
|
|
<div className={cn('mb-1 flex h-6 items-center', isDynamicRegistration && 'opacity-50')}>
|
|
<span className="text-text-secondary system-sm-medium">{t('mcp.modal.clientID', { ns: 'tools' })}</span>
|
|
</div>
|
|
<Input
|
|
value={clientID}
|
|
onChange={e => onClientIDChange(e.target.value)}
|
|
placeholder={t('mcp.modal.clientID', { ns: 'tools' })}
|
|
disabled={isDynamicRegistration}
|
|
/>
|
|
</div>
|
|
<div>
|
|
<div className={cn('mb-1 flex h-6 items-center', isDynamicRegistration && 'opacity-50')}>
|
|
<span className="text-text-secondary system-sm-medium">{t('mcp.modal.clientSecret', { ns: 'tools' })}</span>
|
|
</div>
|
|
<Input
|
|
value={credentials}
|
|
onChange={e => onCredentialsChange(e.target.value)}
|
|
placeholder={t('mcp.modal.clientSecretPlaceholder', { ns: 'tools' })}
|
|
disabled={isDynamicRegistration}
|
|
/>
|
|
</div>
|
|
</>
|
|
)
|
|
}
|
|
|
|
export default AuthenticationSection
|