diff --git a/frontend/src/lib/components/AppConnect.svelte b/frontend/src/lib/components/AppConnect.svelte index 2495c2c2c5..c31aa1db59 100644 --- a/frontend/src/lib/components/AppConnect.svelte +++ b/frontend/src/lib/components/AppConnect.svelte @@ -32,7 +32,7 @@ import IconedResourceType from './IconedResourceType.svelte' import { OauthService, ResourceService, VariableService, type TokenResponse } from '$lib/gen' import { page } from '$app/stores' - import { sendUserToast, truncateRev } from '$lib/utils' + import { emptyString, sendUserToast, truncateRev } from '$lib/utils' import { createEventDispatcher } from 'svelte' import Icon from 'svelte-awesome' import Path from './Path.svelte' @@ -54,6 +54,7 @@ let extra_params: [string, string][] = [] let path: string + let description = '' let drawer: Drawer let resource_type = '' @@ -151,21 +152,27 @@ }) ) } - const description = `${manual ? 'Token' : 'OAuth token'} for ${resource_type}` - await VariableService.createVariable({ - workspace: $workspaceStore!, - requestBody: { - path, - value: manual ? args[key] : value, - is_secret: true, - description, - is_oauth: !manual, - account: account - } - }) const resourceValue = args - resourceValue[key] = `$var:${path}` + + if (!manual || containsSecret) { + await VariableService.createVariable({ + workspace: $workspaceStore!, + requestBody: { + path, + value: manual ? args[key] : value, + is_secret: true, + description: emptyString(description) + ? `${manual ? 'Token' : 'OAuth token'} for ${resource_type}` + : description, + is_oauth: !manual, + account: account + } + }) + resourceValue[key] = `$var:${path}` + } else { + } + await ResourceService.createResource({ workspace: $workspaceStore!, requestBody: { @@ -196,13 +203,17 @@ resource_type == 'gcal' || resource_type == 'gdrive' || resource_type == 'gsheets') + + $: containsSecret = + args && Object.keys(args).filter((x) => ['token', 'password', 'api_key'].includes(x)).length > 0 $: disabled = (step == 1 && resource_type == '') || (step == 2 && value == '' && args['token'] == '' && args['password'] == '' && - args['api_key'] == '') || + args['api_key'] == '' && + !containsSecret) || (step == 3 && pathError != '') @@ -319,6 +330,10 @@ initialPath={`u/${$userStore?.username ?? ''}/my_${resource_type}`} kind="resource" /> + {#if apiTokenApps[resource_type]}
Instructions
diff --git a/frontend/src/routes/resources.svelte b/frontend/src/routes/resources.svelte index 33554cce6a..7975c95573 100644 --- a/frontend/src/routes/resources.svelte +++ b/frontend/src/routes/resources.svelte @@ -116,6 +116,7 @@ } }) resourceTypeDrawer.closeDrawer?.() + sendUserToast('Resource type created') loadResourceTypes() }