web: refactor rendering of source icons

closes #4718

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer
2023-02-19 20:17:58 +01:00
parent 99baf1a29e
commit 6f1721a728
3 changed files with 19 additions and 14 deletions

View File

@ -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`<i class="fas fa-share-square" title="${name}"></i>`;
if (iconUrl) {
if (iconUrl.startsWith("fa://")) {
const url = iconUrl.replaceAll("fa://", "");
return html`<i class="fas ${url}" title="${name}"></i>`;
}
return html`<img src="${iconUrl}" alt="${name}" />`;
}
return icon;
}
@customElement("ak-source-view")
export class SourceViewPage extends AKElement {
@property({ type: String })