feat/tool-oauth
zxhlyh 10 months ago
parent 67b5d73399
commit e1bb6c00df

@ -4,6 +4,7 @@ import {
useRef, useRef,
useState, useState,
} from 'react' } from 'react'
import { RiExternalLinkLine } from '@remixicon/react'
import { import {
useForm, useForm,
useStore, useStore,
@ -24,6 +25,7 @@ import type {
} from '@/app/components/base/form/types' } from '@/app/components/base/form/types'
import { useToastContext } from '@/app/components/base/toast' import { useToastContext } from '@/app/components/base/toast'
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import { useRenderI18nObject } from '@/hooks/use-i18n'
type OAuthClientSettingsProps = { type OAuthClientSettingsProps = {
pluginPayload: PluginPayload pluginPayload: PluginPayload
@ -127,6 +129,8 @@ const OAuthClientSettings = ({
defaultValues: editValues || defaultValues, defaultValues: editValues || defaultValues,
}) })
const __oauth_client__ = useStore(form.store, s => s.values.__oauth_client__) const __oauth_client__ = useStore(form.store, s => s.values.__oauth_client__)
const helpField = schemas.find(schema => schema.url && schema.help)
const renderI18nObject = useRenderI18nObject()
return ( return (
<Modal <Modal
title={t('plugin.auth.oauthClientSettings')} title={t('plugin.auth.oauthClientSettings')}
@ -155,13 +159,26 @@ const OAuthClientSettings = ({
) )
} }
> >
<AuthForm <>
formFromProps={form} <AuthForm
ref={formRef} formFromProps={form}
formSchemas={schemas} ref={formRef}
defaultValues={editValues || defaultValues} formSchemas={schemas}
disabled={disabled} defaultValues={editValues || defaultValues}
/> disabled={disabled}
/>
{
helpField && __oauth_client__ === 'custom' && (
<a
className='system-xs-regular mt-4 flex h-4 items-center text-text-accent'
href={helpField?.url}
target='_blank'
>
{renderI18nObject(helpField?.help as any)}
<RiExternalLinkLine className='ml-1 h-3 w-3' />
</a>
)}
</>
</Modal> </Modal>
) )
} }

Loading…
Cancel
Save