import { truncateWords } from "@goauthentik/common/utils"; import { AKElement, rootInterface } from "@goauthentik/elements/Base"; import { UserInterface } from "@goauthentik/user/UserInterface"; import { msg } from "@lit/localize"; import { CSSResult, TemplateResult, css, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import PFAvatar from "@patternfly/patternfly/components/Avatar/avatar.css"; import PFButton from "@patternfly/patternfly/components/Button/button.css"; import PFCard from "@patternfly/patternfly/components/Card/card.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; import { Application } from "@goauthentik/api"; @customElement("ak-library-app") export class LibraryApplication extends AKElement { @property({ attribute: false }) application?: Application; @property({ type: Boolean }) selected = false; @property() background = ""; static get styles(): CSSResult[] { return [ PFBase, PFCard, PFButton, PFAvatar, css` .pf-c-card { height: 100%; } i.pf-icon { height: 36px; display: flex; flex-direction: column; justify-content: center; } .pf-c-avatar { --pf-c-avatar--BorderRadius: 0; } .pf-c-card__header { min-height: 60px; justify-content: space-between; } .pf-c-card__header a { display: flex; flex-direction: column; justify-content: center; margin-right: 0.25em; } `, ]; } renderIcon(): TemplateResult { if (this.application?.metaIcon) { if (this.application.metaIcon.startsWith("fa://")) { const icon = this.application.metaIcon.replaceAll("fa://", ""); return html``; } return html`${msg(`; } return html``; } render(): TemplateResult { if (!this.application) { return html``; } const me = rootInterface()?.me; return html`
${this.renderIcon()} ${rootInterface()?.uiConfig?.enabledFeatures.applicationEdit && me?.user.isSuperuser ? html` ` : html``}

${this.application.name}

${this.application.metaPublisher}
${truncateWords(this.application.metaDescription || "", 35)}
`; } }