simplify adding manual resources

This commit is contained in:
Ruben Fiszel
2022-12-01 22:51:27 +01:00
parent fed2b2105d
commit 2514a2df9a
2 changed files with 36 additions and 34 deletions
+35 -34
View File
@@ -111,7 +111,7 @@
}
async function next() {
if (step < 3 && manual) {
if (step == 1 && manual) {
step += 1
} else if (step == 1 && !manual) {
const url = new URL(`/api/oauth/connect/${resource_type}`, $page.url.origin)
@@ -312,30 +312,34 @@
</Button>
{/each}
</div>
{:else if step == 2}
{#if manual}
{#if apiTokenApps[resource_type]}
<div class="mb-1 font-semibold text-gray-700 mt-6">Instructions</div>
<div class="pl-10">
<ol class="list-decimal">
{#each apiTokenApps[resource_type].instructions as step}
<li>
{@html step}
</li>
{/each}
</ol>
</div>
{#if apiTokenApps[resource_type].img}
<div class="mt-4">
<img alt="connect" src={apiTokenApps[resource_type].img} />
</div>
{/if}
{/if}
<div class="mt-4">
<ApiConnectForm password={key} {resource_type} bind:args />
{:else if step == 2 && manual}
<Path
bind:error={pathError}
bind:path
initialPath={`u/${$userStore?.username ?? ''}/my_${resource_type}`}
kind="resource"
/>
{#if apiTokenApps[resource_type]}
<div class="mb-1 font-semibold text-gray-700 mt-6">Instructions</div>
<div class="pl-10">
<ol class="list-decimal">
{#each apiTokenApps[resource_type].instructions as step}
<li>
{@html step}
</li>
{/each}
</ol>
</div>
{#if apiTokenApps[resource_type].img}
<div class="mt-4">
<img alt="connect" src={apiTokenApps[resource_type].img} />
</div>
{/if}
{/if}
<div class="mt-4">
<ApiConnectForm password={key} {resource_type} bind:args />
</div>
{:else}
<Path
bind:error={pathError}
@@ -344,19 +348,16 @@
kind="resource"
/>
{#if apiTokenApps[resource_type] || !manual}
{manual}
{apiTokenApps[resource_type]}
<ul class="mt-10 bg-white">
<li>
1. A secret variable containing the {apiTokenApps[resource_type]?.key ?? 'token'}<span
class="font-bold">{truncateRev(value, 5, '*****')}</span
>
1. A secret variable containing the {apiTokenApps[resource_type]?.key ?? 'token'}
<span class="font-bold">{truncateRev(value, 5, '*****')}</span>
will be stored a
<span class="font-mono">{path}</span>.
<span class="font-mono whitespace-nowrap">{path}</span>.
</li>
<li class="mt-4">
2. The resource containing that token will be stored at the same path<span
class="font-mono">{path}</span
2. The resource containing that token will be stored at the same path <span
class="font-mono whitespace-nowrap">{path}</span
>. The Variable and Resource will be "linked together", they will be deleted and renamed
together.
</li></ul
@@ -375,10 +376,10 @@
<Button {disabled} on:click={next}>
{#if step == 1 && !manual}
Connect
{:else if step == 3}
Add resource
{:else}
{:else if step == 1 && manual}
Next
{:else}
Save
{/if}
</Button>
{/if}
@@ -61,6 +61,7 @@
if (rawValue) {
try {
value = JSON.parse(rawValue)
error = ''
} catch (err) {
error = err.toString()
}