1
0
Fork 0
mirror of synced 2024-07-02 21:10:43 +12:00

OIDC icon fix recreated on a new branch

This commit is contained in:
Dean 2023-06-23 14:47:58 +01:00
parent 7c1c410443
commit ceecd85d76
5 changed files with 63 additions and 7 deletions

View file

@ -5,6 +5,7 @@ import {
GoogleInnerConfig,
OIDCConfig,
OIDCInnerConfig,
OIDCLogosConfig,
SCIMConfig,
SCIMInnerConfig,
SettingsConfig,
@ -191,6 +192,10 @@ export function getDefaultGoogleConfig(): GoogleInnerConfig | undefined {
// OIDC
export async function getOIDCLogosDoc(): Promise<OIDCLogosConfig | undefined> {
return getConfig<OIDCLogosConfig>(ConfigType.OIDC_LOGOS)
}
async function getOIDCConfigDoc(): Promise<OIDCConfig | undefined> {
return getConfig<OIDCConfig>(ConfigType.OIDC)
}

View file

@ -99,9 +99,15 @@
bind:this={button}
>
{#if fieldIcon}
<span class="option-extra icon">
<Icon size="S" name={fieldIcon} />
</span>
{#if !useOptionIconImage}
<span class="option-extra icon">
<Icon size="S" name={fieldIcon} />
</span>
{:else}
<span class="option-extra icon field-icon">
<img src={fieldIcon} alt="icon" width="15" height="15" />
</span>
{/if}
{/if}
{#if fieldColour}
<span class="option-extra">
@ -311,4 +317,8 @@
max-width: 170px;
font-size: 12px;
}
.option-extra.icon.field-icon {
display: flex;
}
</style>

View file

@ -12,6 +12,7 @@
export let samePage
$: show = $organisation.oidc
$: oidcLogoCheck = $oidc.logo
let preDefinedIcons = {
Oidc: OidcLogo,
@ -29,9 +30,9 @@
}
})
$: src = !$oidc.logo
$: src = !oidcLogoCheck
? OidcLogo
: preDefinedIcons[$oidc.logo] || `/global/logos_oidc/${$oidc.logo}`
: preDefinedIcons[$oidc.logo] || oidcLogoCheck
</script>
{#if show}

View file

@ -79,6 +79,12 @@ export interface OIDCConfigs {
configs: OIDCInnerConfig[]
}
export interface OIDCLogosInnerConfig {
[key: string]: string
}
export interface OIDCLogosConfig extends Config<OIDCLogosInnerConfig> {}
export interface OIDCInnerConfig {
configUrl: string
clientID: string

View file

@ -28,6 +28,7 @@ import {
SSOConfig,
SSOConfigType,
UserCtx,
OIDCLogosConfig,
} from "@budibase/types"
import * as pro from "@budibase/pro"
@ -280,13 +281,39 @@ export async function save(ctx: UserCtx<Config>) {
}
}
function enrichOIDCLogos(oidcLogos: OIDCLogosConfig) {
if (!oidcLogos) {
return
}
oidcLogos.config = Object.keys(oidcLogos.config).reduce(
(acc: any, key: string) => {
if (!key.endsWith("Etag")) {
const etag = oidcLogos.config[`${key}Etag`]
const objectStoreUrl = objectStore.getGlobalFileUrl(
oidcLogos.type,
key,
etag
)
acc[key] = objectStoreUrl
} else {
acc[key] = oidcLogos.config[key]
}
return acc
},
{}
)
}
export async function find(ctx: UserCtx) {
try {
// Find the config with the most granular scope based on context
const type = ctx.params.type
const scopedConfig = await configs.getConfig(type)
let scopedConfig = await configs.getConfig(type)
if (scopedConfig) {
if (type === ConfigType.OIDC_LOGOS) {
enrichOIDCLogos(scopedConfig)
}
ctx.body = scopedConfig
} else {
// don't throw an error, there simply is nothing to return
@ -301,13 +328,20 @@ export async function publicOidc(ctx: Ctx<void, GetPublicOIDCConfigResponse>) {
try {
// Find the config with the most granular scope based on context
const config = await configs.getOIDCConfig()
const oidcLogoConfig = await configs.getOIDCLogosDoc()
if (oidcLogoConfig) {
enrichOIDCLogos(oidcLogoConfig)
}
if (!config) {
ctx.body = []
} else {
ctx.body = [
{
logo: config.logo,
logo: oidcLogoConfig
? oidcLogoConfig.config[config.logo]
: config.logo,
name: config.name,
uuid: config.uuid,
},