add env vars to auth variables section in rest config
This commit is contained in:
parent
7162a9c9dc
commit
c591830516
|
@ -16,6 +16,7 @@
|
||||||
runtimeToReadableMap,
|
runtimeToReadableMap,
|
||||||
} from "builderStore/dataBinding"
|
} from "builderStore/dataBinding"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
import { getEnvironmentBindings } from "builderStore/dataBinding"
|
||||||
|
|
||||||
export let datasource
|
export let datasource
|
||||||
export let queries
|
export let queries
|
||||||
|
@ -93,6 +94,7 @@
|
||||||
headings
|
headings
|
||||||
bind:object={datasource.config.staticVariables}
|
bind:object={datasource.config.staticVariables}
|
||||||
on:change
|
on:change
|
||||||
|
bindings={getEnvironmentBindings()}
|
||||||
/>
|
/>
|
||||||
</Layout>
|
</Layout>
|
||||||
<div />
|
<div />
|
||||||
|
|
|
@ -1,9 +1,22 @@
|
||||||
<script>
|
<script>
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { ModalContent, Layout, Select, Body, Input } from "@budibase/bbui"
|
import {
|
||||||
|
ModalContent,
|
||||||
|
Layout,
|
||||||
|
Select,
|
||||||
|
Body,
|
||||||
|
Input,
|
||||||
|
EnvDropdown,
|
||||||
|
Modal,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import { AUTH_TYPE_LABELS, AUTH_TYPES } from "./authTypes"
|
import { AUTH_TYPE_LABELS, AUTH_TYPES } from "./authTypes"
|
||||||
import BindableCombobox from "components/common/bindings/BindableCombobox.svelte"
|
import BindableCombobox from "components/common/bindings/BindableCombobox.svelte"
|
||||||
import { getAuthBindings } from "builderStore/dataBinding"
|
import {
|
||||||
|
getAuthBindings,
|
||||||
|
getEnvironmentBindings,
|
||||||
|
} from "builderStore/dataBinding"
|
||||||
|
import { environment, licensing, auth } from "stores/portal"
|
||||||
|
import CreateEditVariableModal from "components/portal/environment/CreateEditVariableModal.svelte"
|
||||||
|
|
||||||
export let configs
|
export let configs
|
||||||
export let currentConfig
|
export let currentConfig
|
||||||
|
@ -28,7 +41,16 @@
|
||||||
let hasErrors = false
|
let hasErrors = false
|
||||||
let hasChanged = false
|
let hasChanged = false
|
||||||
|
|
||||||
onMount(() => {
|
let createVariableModal
|
||||||
|
let formFieldkey
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
await environment.loadVariables()
|
||||||
|
|
||||||
|
if ($auth.user) {
|
||||||
|
await licensing.init()
|
||||||
|
}
|
||||||
|
|
||||||
if (currentConfig) {
|
if (currentConfig) {
|
||||||
deconstructConfig()
|
deconstructConfig()
|
||||||
}
|
}
|
||||||
|
@ -146,6 +168,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const save = data => {
|
||||||
|
environment.createVariable(data)
|
||||||
|
form.basic[formFieldkey] = `{{ env.${data.name} }}`
|
||||||
|
createVariableModal.hide()
|
||||||
|
}
|
||||||
|
|
||||||
const onFieldChange = () => {
|
const onFieldChange = () => {
|
||||||
checkErrors()
|
checkErrors()
|
||||||
checkChanged()
|
checkChanged()
|
||||||
|
@ -154,6 +182,16 @@
|
||||||
const onConfirmInternal = () => {
|
const onConfirmInternal = () => {
|
||||||
onConfirm(constructConfig())
|
onConfirm(constructConfig())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function handleUpgradePanel() {
|
||||||
|
await environment.upgradePanelOpened()
|
||||||
|
$licensing.goToUpgradePage()
|
||||||
|
}
|
||||||
|
|
||||||
|
function showModal(key) {
|
||||||
|
formFieldkey = key
|
||||||
|
createVariableModal.show()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
|
@ -189,26 +227,39 @@
|
||||||
error={blurred.type ? errors.type : null}
|
error={blurred.type ? errors.type : null}
|
||||||
/>
|
/>
|
||||||
{#if form.type === AUTH_TYPES.BASIC}
|
{#if form.type === AUTH_TYPES.BASIC}
|
||||||
<Input
|
<EnvDropdown
|
||||||
label="Username"
|
label="Username"
|
||||||
bind:value={form.basic.username}
|
bind:value={form.basic.username}
|
||||||
on:change={onFieldChange}
|
on:change={onFieldChange}
|
||||||
on:blur={() => (blurred.basic.username = true)}
|
on:blur={() => (blurred.basic.username = true)}
|
||||||
error={blurred.basic.username ? errors.basic.username : null}
|
error={blurred.basic.username ? errors.basic.username : null}
|
||||||
|
showModal={() => showModal("configKey")}
|
||||||
|
variables={$environment.variables}
|
||||||
|
environmentVariablesEnabled={$licensing.environmentVariablesEnabled}
|
||||||
|
{handleUpgradePanel}
|
||||||
/>
|
/>
|
||||||
<Input
|
<EnvDropdown
|
||||||
label="Password"
|
label="Password"
|
||||||
bind:value={form.basic.password}
|
bind:value={form.basic.password}
|
||||||
on:change={onFieldChange}
|
on:change={onFieldChange}
|
||||||
on:blur={() => (blurred.basic.password = true)}
|
on:blur={() => (blurred.basic.password = true)}
|
||||||
error={blurred.basic.password ? errors.basic.password : null}
|
error={blurred.basic.password ? errors.basic.password : null}
|
||||||
|
showModal={() => showModal("configKey")}
|
||||||
|
variables={$environment.variables}
|
||||||
|
environmentVariablesEnabled={$licensing.environmentVariablesEnabled}
|
||||||
|
{handleUpgradePanel}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if form.type === AUTH_TYPES.BEARER}
|
{#if form.type === AUTH_TYPES.BEARER}
|
||||||
<BindableCombobox
|
<BindableCombobox
|
||||||
label="Token"
|
label="Token"
|
||||||
value={form.bearer.token}
|
value={form.bearer.token}
|
||||||
bindings={getAuthBindings()}
|
bindings={[
|
||||||
|
...getAuthBindings(),
|
||||||
|
...($licensing.environmentVariablesEnabled
|
||||||
|
? getEnvironmentBindings()
|
||||||
|
: []),
|
||||||
|
]}
|
||||||
on:change={e => {
|
on:change={e => {
|
||||||
form.bearer.token = e.detail
|
form.bearer.token = e.detail
|
||||||
onFieldChange()
|
onFieldChange()
|
||||||
|
@ -226,3 +277,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
</Layout>
|
</Layout>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
|
<Modal bind:this={createVariableModal}>
|
||||||
|
<CreateEditVariableModal {save} />
|
||||||
|
</Modal>
|
||||||
|
|
Loading…
Reference in New Issue