add description field when adding resource

This commit is contained in:
Ruben Fiszel
2022-12-02 12:35:06 +01:00
parent 32573c1e3c
commit ea86e8c7b5
2 changed files with 31 additions and 15 deletions
+30 -15
View File
@@ -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 != '')
</script>
@@ -319,6 +330,10 @@
initialPath={`u/${$userStore?.username ?? ''}/my_${resource_type}`}
kind="resource"
/>
<label>
<div class="mb-1 font-semibold text-gray-700">Description</div>
<input type="text" bind:value={description} /></label
>
{#if apiTokenApps[resource_type]}
<div class="mb-1 font-semibold text-gray-700 mt-6">Instructions</div>
<div class="pl-10">
+1
View File
@@ -116,6 +116,7 @@
}
})
resourceTypeDrawer.closeDrawer?.()
sendUserToast('Resource type created')
loadResourceTypes()
}