Type RestAuthenticaionModal

This commit is contained in:
Adria Navarro 2025-03-24 12:12:26 +01:00
parent 3b047b166c
commit 9966175abd
2 changed files with 13 additions and 15 deletions

View File

@ -9,10 +9,10 @@
export let value = "" export let value = ""
export let bindings = [] export let bindings = []
export let placeholder export let placeholder = undefined
export let label export let label
export let disabled = false export let disabled = false
export let options export let options = undefined
export let appendBindingsAsOptions = true export let appendBindingsAsOptions = true
export let error export let error

View File

@ -1,4 +1,4 @@
<script> <script lang="ts">
import { onMount } from "svelte" import { onMount } from "svelte"
import { import {
ModalContent, ModalContent,
@ -21,17 +21,17 @@
export let onConfirm export let onConfirm
export let onRemove export let onRemove
let form = { let form: any = {
basic: {}, basic: {},
bearer: {}, bearer: {},
} }
let errors = { let errors: any = {
basic: {}, basic: {},
bearer: {}, bearer: {},
} }
let blurred = { let blurred: any = {
basic: {}, basic: {},
bearer: {}, bearer: {},
} }
@ -39,8 +39,8 @@
let hasErrors = false let hasErrors = false
let hasChanged = false let hasChanged = false
let createVariableModal let createVariableModal: Modal
let formFieldkey let formFieldkey: string
onMount(async () => { onMount(async () => {
try { try {
@ -79,7 +79,7 @@
* map the form into a new config to save by type * map the form into a new config to save by type
*/ */
const constructConfig = () => { const constructConfig = () => {
const newConfig = { const newConfig: any = {
name: form.name, name: form.name,
type: form.type, type: form.type,
} }
@ -123,7 +123,7 @@
errors.name = errors.name =
// check for duplicate excluding the current config // check for duplicate excluding the current config
configs.find( configs.find(
c => c.name === form.name && c.name !== currentConfig?.name (c: any) => c.name === form.name && c.name !== currentConfig?.name
) !== undefined ) !== undefined
? "Name must be unique" ? "Name must be unique"
: null : null
@ -169,12 +169,12 @@
} }
} }
const save = async data => { const save = async (data: any) => {
try { try {
await environment.createVariable(data) await environment.createVariable(data)
form.basic[formFieldkey] = `{{ env.${data.name} }}` form.basic[formFieldkey] = `{{ env.${data.name} }}`
createVariableModal.hide() createVariableModal.hide()
} catch (err) { } catch (err: any) {
notifications.error(`Failed to create variable: ${err.message}`) notifications.error(`Failed to create variable: ${err.message}`)
} }
} }
@ -193,7 +193,7 @@
$licensing.goToUpgradePage() $licensing.goToUpgradePage()
} }
function showModal(key) { function showModal(key: any) {
formFieldkey = key formFieldkey = key
createVariableModal.show() createVariableModal.show()
} }
@ -274,10 +274,8 @@
blurred.bearer.token = true blurred.bearer.token = true
onFieldChange() onFieldChange()
}} }}
allowJS={false}
placeholder="Token" placeholder="Token"
appendBindingsAsOptions={true} appendBindingsAsOptions={true}
drawerEnabled={false}
error={blurred.bearer.token ? errors.bearer.token : null} error={blurred.bearer.token ? errors.bearer.token : null}
/> />
{/if} {/if}