1
0
Fork 0
mirror of synced 2024-07-04 22:11:23 +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, GoogleInnerConfig,
OIDCConfig, OIDCConfig,
OIDCInnerConfig, OIDCInnerConfig,
OIDCLogosConfig,
SCIMConfig, SCIMConfig,
SCIMInnerConfig, SCIMInnerConfig,
SettingsConfig, SettingsConfig,
@ -191,6 +192,10 @@ export function getDefaultGoogleConfig(): GoogleInnerConfig | undefined {
// OIDC // OIDC
export async function getOIDCLogosDoc(): Promise<OIDCLogosConfig | undefined> {
return getConfig<OIDCLogosConfig>(ConfigType.OIDC_LOGOS)
}
async function getOIDCConfigDoc(): Promise<OIDCConfig | undefined> { async function getOIDCConfigDoc(): Promise<OIDCConfig | undefined> {
return getConfig<OIDCConfig>(ConfigType.OIDC) return getConfig<OIDCConfig>(ConfigType.OIDC)
} }

View file

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

View file

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

View file

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

View file

@ -28,6 +28,7 @@ import {
SSOConfig, SSOConfig,
SSOConfigType, SSOConfigType,
UserCtx, UserCtx,
OIDCLogosConfig,
} from "@budibase/types" } from "@budibase/types"
import * as pro from "@budibase/pro" 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) { export async function find(ctx: UserCtx) {
try { try {
// Find the config with the most granular scope based on context // Find the config with the most granular scope based on context
const type = ctx.params.type const type = ctx.params.type
const scopedConfig = await configs.getConfig(type) let scopedConfig = await configs.getConfig(type)
if (scopedConfig) { if (scopedConfig) {
if (type === ConfigType.OIDC_LOGOS) {
enrichOIDCLogos(scopedConfig)
}
ctx.body = scopedConfig ctx.body = scopedConfig
} else { } else {
// don't throw an error, there simply is nothing to return // don't throw an error, there simply is nothing to return
@ -301,13 +328,20 @@ export async function publicOidc(ctx: Ctx<void, GetPublicOIDCConfigResponse>) {
try { try {
// Find the config with the most granular scope based on context // Find the config with the most granular scope based on context
const config = await configs.getOIDCConfig() const config = await configs.getOIDCConfig()
const oidcLogoConfig = await configs.getOIDCLogosDoc()
if (oidcLogoConfig) {
enrichOIDCLogos(oidcLogoConfig)
}
if (!config) { if (!config) {
ctx.body = [] ctx.body = []
} else { } else {
ctx.body = [ ctx.body = [
{ {
logo: config.logo, logo: oidcLogoConfig
? oidcLogoConfig.config[config.logo]
: config.logo,
name: config.name, name: config.name,
uuid: config.uuid, uuid: config.uuid,
}, },