refac
This commit is contained in:
1 parent
d241df8d79
commit
2e6d61e6d0
1 file changed
+12
-12
@@ -77,11 +77,15 @@
|
|||||||
'bg-transparent outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-700';
|
'bg-transparent outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-700';
|
||||||
const selectClass =
|
const selectClass =
|
||||||
'bg-transparent pr-5 outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-700';
|
'bg-transparent pr-5 outline-hidden placeholder:text-gray-300 dark:placeholder:text-gray-700';
|
||||||
const isMcpOAuth = () => type === 'mcp' && ['oauth_2.1', 'oauth_2.1_static'].includes(auth_type);
|
const oauthAuthTypes = ['oauth_2.1', 'oauth_2.1_static'];
|
||||||
const verifyLabel = () =>
|
const verifyLabel = () =>
|
||||||
isMcpOAuth() ? $i18n.t('Check OAuth Discovery') : $i18n.t('Verify Connection');
|
oauthAuthTypes.includes(auth_type)
|
||||||
|
? $i18n.t('Check OAuth Discovery')
|
||||||
|
: $i18n.t('Verify Connection');
|
||||||
const verifySuccessMessage = () =>
|
const verifySuccessMessage = () =>
|
||||||
isMcpOAuth() ? $i18n.t('OAuth discovery successful') : $i18n.t('Connection successful');
|
oauthAuthTypes.includes(auth_type)
|
||||||
|
? $i18n.t('OAuth discovery successful')
|
||||||
|
: $i18n.t('Connection successful');
|
||||||
|
|
||||||
const authorizeOAuthHandler = () => {
|
const authorizeOAuthHandler = () => {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
@@ -213,7 +217,7 @@
|
|||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
...(isMcpOAuth()
|
...(oauthAuthTypes.includes(auth_type)
|
||||||
? {
|
? {
|
||||||
...(oauthServerUrl ? { oauth_server_url: oauthServerUrl } : {}),
|
...(oauthServerUrl ? { oauth_server_url: oauthServerUrl } : {}),
|
||||||
...(oauthScope ? { oauth_scope: oauthScope } : {}),
|
...(oauthScope ? { oauth_scope: oauthScope } : {}),
|
||||||
@@ -335,11 +339,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (type === 'mcp' && oauthAuthTypes.includes(auth_type) && !oauthClientInfo) {
|
||||||
type === 'mcp' &&
|
|
||||||
['oauth_2.1', 'oauth_2.1_static'].includes(auth_type) &&
|
|
||||||
!oauthClientInfo
|
|
||||||
) {
|
|
||||||
toast.error($i18n.t('Please register the OAuth client'));
|
toast.error($i18n.t('Please register the OAuth client'));
|
||||||
loading = false;
|
loading = false;
|
||||||
return;
|
return;
|
||||||
@@ -392,7 +392,7 @@
|
|||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
description: description,
|
description: description,
|
||||||
...(type === 'mcp' && ['oauth_2.1', 'oauth_2.1_static'].includes(auth_type)
|
...(type === 'mcp' && oauthAuthTypes.includes(auth_type)
|
||||||
? {
|
? {
|
||||||
...(oauthScope ? { oauth_scope: oauthScope } : {}),
|
...(oauthScope ? { oauth_scope: oauthScope } : {}),
|
||||||
oauth_resource_parameter: oauthResourceParameter
|
oauth_resource_parameter: oauthResourceParameter
|
||||||
@@ -684,7 +684,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if isMcpOAuth()}
|
{#if oauthAuthTypes.includes(auth_type)}
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
{#if oauthClientInfo}
|
{#if oauthClientInfo}
|
||||||
<div class="flex flex-col justify-end items-center shrink-0">
|
<div class="flex flex-col justify-end items-center shrink-0">
|
||||||
@@ -916,7 +916,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if type === 'mcp' && ['oauth_2.1', 'oauth_2.1_static'].includes(auth_type)}
|
{#if type === 'mcp' && oauthAuthTypes.includes(auth_type)}
|
||||||
<div class="flex gap-2 mt-2">
|
<div class="flex gap-2 mt-2">
|
||||||
<div class="flex flex-col w-full">
|
<div class="flex flex-col w-full">
|
||||||
<label for="oauth-scope" class={`mb-0.5 text-xs text-gray-500`}
|
<label for="oauth-scope" class={`mb-0.5 text-xs text-gray-500`}
|
||||||
|
|||||||
Reference in new issue
Block a user