Merge branch 'master' into BUDI-9127/support-header-and-body-method

This commit is contained in:
Adria Navarro 2025-03-19 18:49:25 +01:00 committed by GitHub
commit bf47d56a09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 63 additions and 6 deletions

View File

@ -684,6 +684,7 @@
<AuthPicker
bind:authConfigId={query.fields.authConfigId}
bind:authConfigType={query.fields.authConfigType}
{authConfigs}
datasourceId={datasource._id}
/>

View File

@ -3,21 +3,36 @@
ActionButton,
Body,
Button,
Divider,
List,
ListItem,
PopoverAlignment,
} from "@budibase/bbui"
import { goto } from "@roxi/routify"
import { appStore } from "@/stores/builder"
import { appStore, oauth2 } from "@/stores/builder"
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 authConfigs: { label: string; value: string }[]
export let authConfigType: RestAuthType | undefined
export let authConfigs: Config[]
export let datasourceId: string
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() {
$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) {
authConfigId = undefined
authConfigType = undefined
} else {
authConfigId = id
authConfigType = type
}
popover.hide()
}
$: title = !authConfig ? "Authentication" : `Auth: ${authConfig.label}`
$: oauth2Enabled = featureFlag.isEnabled(FeatureFlag.OAUTH2_CONFIG)
onMount(() => {
oauth2.fetch()
})
</script>
<DetailPopover bind:this={popover} {title} align={PopoverAlignment.Right}>
@ -68,4 +95,29 @@
>Add config</Button
>
</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>

View File

@ -29,7 +29,11 @@
await oauth2.delete(row.id)
notifications.success(`Config '${row.name}' deleted successfully`)
} catch (e: any) {
notifications.error("Error deleting config")
let message = "Error deleting config"
if (e.message) {
message += ` - ${e.message}`
}
notifications.error(message)
}
},
})

View File

@ -114,7 +114,7 @@
notifications.success("Settings saved.")
}
} catch (e: any) {
notifications.error(e.message)
notifications.error(`Failed to save config - ${e.message}`)
return keepOpen
}
}