fix(frontend): use normal password mask for the sensitive fields of the resource editor

This commit is contained in:
Ruben Fiszel
2024-05-01 20:26:44 +02:00
parent 7df4f02529
commit c8b439df5b
6 changed files with 29 additions and 5 deletions

View File

@@ -186,5 +186,13 @@
fixedOverflowWidgets={false}
/>
{:else}
<SchemaForm noDelete {linkedSecretCandidates} bind:linkedSecret isValid {schema} bind:args />
<SchemaForm
onlyMaskPassword
noDelete
{linkedSecretCandidates}
bind:linkedSecret
isValid
{schema}
bind:args
/>
{/if}

View File

@@ -138,9 +138,15 @@
}
return r
}
$: linkedSecret = linkedSecretCandidates?.sort(
(ua, ub) => linkedSecretValue(ub) - linkedSecretValue(ua)
)?.[0]
function forceSecretValue(resourceType: string): string | undefined {
if (resourceType == 'git_repository') {
return 'url'
}
}
$: linkedSecret =
forceSecretValue(resourceType) ??
linkedSecretCandidates?.sort((ua, ub) => linkedSecretValue(ub) - linkedSecretValue(ua))?.[0]
let scopes: string[] = []
let extra_params: [string, string][] = []

View File

@@ -28,6 +28,7 @@
import FileUpload from './common/fileUpload/FileUpload.svelte'
import autosize from '$lib/autosize'
import PasswordArgInput from './PasswordArgInput.svelte'
import Password from './Password.svelte'
export let label: string = ''
export let value: any
@@ -70,6 +71,7 @@
export let showSchemaExplorer = false
export let simpleTooltip: string | undefined = undefined
export let customErrorMessage: string | undefined = undefined
export let onlyMaskPassword = false
let seeEditable: boolean = enum_ != undefined || pattern != undefined
const dispatch = createEventDispatcher()
@@ -651,7 +653,11 @@
<div class="flex flex-col w-full">
<div class="flex flex-row w-full items-center justify-between relative">
{#if password || extra?.['password'] == true}
<PasswordArgInput {disabled} bind:value />
{#if onlyMaskPassword}
<Password {disabled} bind:password={value} placeholder={defaultValue ?? ''} />
{:else}
<PasswordArgInput {disabled} bind:value />
{/if}
{:else}
{#key extra?.['minRows']}
<textarea

View File

@@ -203,6 +203,7 @@
<Skeleton layout={[[4]]} />
{:else if !viewJsonSchema && resourceSchema && resourceSchema?.properties}
<SchemaForm
onlyMaskPassword
noDelete
disabled={!can_write}
compact

View File

@@ -33,6 +33,7 @@
export let disablePortal = false
export let showSchemaExplorer = false
export let showReset = false
export let onlyMaskPassword = false
let clazz: string = ''
export { clazz as class }
@@ -156,6 +157,7 @@
extra={schema.properties[argName]}
{showSchemaExplorer}
simpleTooltip={schemaFieldTooltip[argName]}
{onlyMaskPassword}
>
<svelte:fragment slot="actions">
{#if linkedSecretCandidates?.includes(argName)}

View File

@@ -218,6 +218,7 @@
<Alert type="warning" title="Adding a form to the approval page is an EE feature" />
{:else}
<SchemaForm
onlyMaskPassword
noVariablePicker
bind:isValid={valid}
schema={mergeSchema(schema, enum_payload)}