From 6f1721a728630d9efb47c2c1df38a9a6bd9fe4bb Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 19 Feb 2023 20:17:58 +0100 Subject: [PATCH] web: refactor rendering of source icons closes #4718 Signed-off-by: Jens Langhammer --- web/src/admin/sources/SourceViewPage.ts | 12 ++++++++++++ .../stages/identification/IdentificationStage.ts | 11 ++--------- web/src/user/user-settings/sources/SourceSettings.ts | 10 +++++----- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/web/src/admin/sources/SourceViewPage.ts b/web/src/admin/sources/SourceViewPage.ts index d0050fdf9..3c010bdb0 100644 --- a/web/src/admin/sources/SourceViewPage.ts +++ b/web/src/admin/sources/SourceViewPage.ts @@ -14,6 +14,18 @@ import { ifDefined } from "lit/directives/if-defined.js"; import { Source, SourcesApi } from "@goauthentik/api"; +export function renderSourceIcon(name: string, iconUrl: string | undefined | null): TemplateResult { + const icon = html``; + if (iconUrl) { + if (iconUrl.startsWith("fa://")) { + const url = iconUrl.replaceAll("fa://", ""); + return html``; + } + return html`${name}`; + } + return icon; +} + @customElement("ak-source-view") export class SourceViewPage extends AKElement { @property({ type: String }) diff --git a/web/src/flow/stages/identification/IdentificationStage.ts b/web/src/flow/stages/identification/IdentificationStage.ts index 25f407a39..a30b0c89f 100644 --- a/web/src/flow/stages/identification/IdentificationStage.ts +++ b/web/src/flow/stages/identification/IdentificationStage.ts @@ -1,3 +1,4 @@ +import { renderSourceIcon } from "@goauthentik/admin/sources/SourceViewPage"; import "@goauthentik/elements/Divider"; import "@goauthentik/elements/EmptyState"; import "@goauthentik/elements/forms/FormElement"; @@ -156,15 +157,7 @@ export class IdentificationStage extends BaseStage< } renderSource(source: LoginSource): TemplateResult { - let icon = html``; - if (source.iconUrl) { - if (source.iconUrl.startsWith("fa://")) { - const url = source.iconUrl.replaceAll("fa://", ""); - icon = html``; - } else { - icon = html`${source.name}`; - } - } + const icon = renderSourceIcon(source.name, source.iconUrl); return html`