Merge branch 'master' into BUDI-9127/validate
This commit is contained in:
commit
198961c70f
|
@ -684,6 +684,7 @@
|
||||||
|
|
||||||
<AuthPicker
|
<AuthPicker
|
||||||
bind:authConfigId={query.fields.authConfigId}
|
bind:authConfigId={query.fields.authConfigId}
|
||||||
|
bind:authConfigType={query.fields.authConfigType}
|
||||||
{authConfigs}
|
{authConfigs}
|
||||||
datasourceId={datasource._id}
|
datasourceId={datasource._id}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,21 +3,36 @@
|
||||||
ActionButton,
|
ActionButton,
|
||||||
Body,
|
Body,
|
||||||
Button,
|
Button,
|
||||||
|
Divider,
|
||||||
List,
|
List,
|
||||||
ListItem,
|
ListItem,
|
||||||
PopoverAlignment,
|
PopoverAlignment,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import { appStore } from "@/stores/builder"
|
import { appStore, oauth2 } from "@/stores/builder"
|
||||||
import DetailPopover from "@/components/common/DetailPopover.svelte"
|
import DetailPopover from "@/components/common/DetailPopover.svelte"
|
||||||
|
import { featureFlag } from "@/helpers"
|
||||||
|
import { FeatureFlag, RestAuthType } from "@budibase/types"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
|
type Config = { label: string; value: string }
|
||||||
|
|
||||||
export let authConfigId: string | undefined
|
export let authConfigId: string | undefined
|
||||||
export let authConfigs: { label: string; value: string }[]
|
export let authConfigType: RestAuthType | undefined
|
||||||
|
export let authConfigs: Config[]
|
||||||
export let datasourceId: string
|
export let datasourceId: string
|
||||||
|
|
||||||
let popover: DetailPopover
|
let popover: DetailPopover
|
||||||
|
let allConfigs: Config[]
|
||||||
|
|
||||||
$: authConfig = authConfigs.find(c => c.value === authConfigId)
|
$: allConfigs = [
|
||||||
|
...authConfigs,
|
||||||
|
...$oauth2.configs.map(c => ({
|
||||||
|
label: c.name,
|
||||||
|
value: c.id,
|
||||||
|
})),
|
||||||
|
]
|
||||||
|
$: authConfig = allConfigs.find(c => c.value === authConfigId)
|
||||||
|
|
||||||
function addBasicConfiguration() {
|
function addBasicConfiguration() {
|
||||||
$goto(
|
$goto(
|
||||||
|
@ -25,16 +40,28 @@
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectConfiguration(id: string) {
|
function addOAuth2Configuration() {
|
||||||
|
$goto(`/builder/app/${$appStore.appId}/settings/oauth2`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectConfiguration(id: string, type?: RestAuthType) {
|
||||||
if (authConfigId === id) {
|
if (authConfigId === id) {
|
||||||
authConfigId = undefined
|
authConfigId = undefined
|
||||||
|
authConfigType = undefined
|
||||||
} else {
|
} else {
|
||||||
authConfigId = id
|
authConfigId = id
|
||||||
|
authConfigType = type
|
||||||
}
|
}
|
||||||
popover.hide()
|
popover.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
$: title = !authConfig ? "Authentication" : `Auth: ${authConfig.label}`
|
$: title = !authConfig ? "Authentication" : `Auth: ${authConfig.label}`
|
||||||
|
|
||||||
|
$: oauth2Enabled = featureFlag.isEnabled(FeatureFlag.OAUTH2_CONFIG)
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
oauth2.fetch()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DetailPopover bind:this={popover} {title} align={PopoverAlignment.Right}>
|
<DetailPopover bind:this={popover} {title} align={PopoverAlignment.Right}>
|
||||||
|
@ -68,4 +95,29 @@
|
||||||
>Add config</Button
|
>Add config</Button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if oauth2Enabled}
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<Body size="S" color="var(--spectrum-global-color-gray-700)">
|
||||||
|
OAuth 2.0 (Token-Based Authentication)
|
||||||
|
</Body>
|
||||||
|
|
||||||
|
{#if $oauth2.configs.length}
|
||||||
|
<List>
|
||||||
|
{#each $oauth2.configs as config}
|
||||||
|
<ListItem
|
||||||
|
title={config.name}
|
||||||
|
on:click={() => selectConfiguration(config.id, RestAuthType.OAUTH2)}
|
||||||
|
selected={config.id === authConfigId}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</List>
|
||||||
|
{/if}
|
||||||
|
<div>
|
||||||
|
<Button secondary icon="Add" on:click={addOAuth2Configuration}
|
||||||
|
>Add OAuth2</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</DetailPopover>
|
</DetailPopover>
|
||||||
|
|
|
@ -29,7 +29,11 @@
|
||||||
await oauth2.delete(row.id)
|
await oauth2.delete(row.id)
|
||||||
notifications.success(`Config '${row.name}' deleted successfully`)
|
notifications.success(`Config '${row.name}' deleted successfully`)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
notifications.error("Error deleting config")
|
let message = "Error deleting config"
|
||||||
|
if (e.message) {
|
||||||
|
message += ` - ${e.message}`
|
||||||
|
}
|
||||||
|
notifications.error(message)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
notifications.success("Settings saved.")
|
notifications.success("Settings saved.")
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
notifications.error(e.message)
|
notifications.error(`Failed to save config - ${e.message}`)
|
||||||
return keepOpen
|
return keepOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue