web/user: only render expand element when required (#6641)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L 2023-08-26 23:43:36 +02:00 committed by GitHub
parent dc782498b4
commit 7a90b435cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 19 deletions

View File

@ -43,11 +43,11 @@ export class VersionStatusCard extends AdminStatusCard<Version> {
renderValue(): TemplateResult { renderValue(): TemplateResult {
let text = this.value?.versionCurrent; let text = this.value?.versionCurrent;
let link = "https://goauthentik.io/docs/releases/${this.value?.versionCurrent}"; let link = `https://goauthentik.io/docs/releases/${this.value?.versionCurrent}`;
if (this.value?.buildHash) { if (this.value?.buildHash) {
text = this.value.buildHash?.substring(0, 7); text = this.value.buildHash?.substring(0, 7);
link = "https://github.com/goauthentik/authentik/commit/${this.value.buildHash}"; link = `https://github.com/goauthentik/authentik/commit/${this.value.buildHash}`;
} }
return html`<a href=${link} target="_blank"> ${text} </a>`; return html`<a href=${link} target="_blank">${text}</a>`;
} }
} }

View File

@ -67,6 +67,13 @@ export class LibraryApplication extends AKElement {
return html`<ak-spinner></ak-spinner>`; return html`<ak-spinner></ak-spinner>`;
} }
const me = rootInterface<UserInterface>()?.me; const me = rootInterface<UserInterface>()?.me;
let expandable = false;
if (rootInterface()?.uiConfig?.enabledFeatures.applicationEdit && me?.user.isSuperuser) {
expandable = true;
}
if (this.application.metaPublisher !== "" || this.application.metaDescription !== "") {
expandable = true;
}
return html` <div return html` <div
class="pf-c-card pf-m-hoverable pf-m-compact ${this.selected class="pf-c-card pf-m-hoverable pf-m-compact ${this.selected
? "pf-m-selectable pf-m-selected" ? "pf-m-selectable pf-m-selected"
@ -89,22 +96,25 @@ export class LibraryApplication extends AKElement {
> >
</div> </div>
<div class="expander"></div> <div class="expander"></div>
<ak-expand textOpen=${msg("Less details")} textClosed=${msg("More details")}> ${expandable
<div class="pf-c-content"> ? html`<ak-expand textOpen=${msg("Less details")} textClosed=${msg("More details")}>
<small>${this.application.metaPublisher}</small> <div class="pf-c-content">
</div> <small>${this.application.metaPublisher}</small>
${truncateWords(this.application.metaDescription || "", 10)} </div>
${rootInterface()?.uiConfig?.enabledFeatures.applicationEdit && me?.user.isSuperuser ${truncateWords(this.application.metaDescription || "", 10)}
? html` ${rootInterface()?.uiConfig?.enabledFeatures.applicationEdit &&
<a me?.user.isSuperuser
class="pf-c-button pf-m-control pf-m-small pf-m-block" ? html`
href="/if/admin/#/core/applications/${this.application?.slug}" <a
> class="pf-c-button pf-m-control pf-m-small pf-m-block"
<i class="fas fa-edit"></i>&nbsp;${msg("Edit")} href="/if/admin/#/core/applications/${this.application?.slug}"
</a> >
` <i class="fas fa-edit"></i>&nbsp;${msg("Edit")}
: html``} </a>
</ak-expand> `
: html``}
</ak-expand>`
: html``}
</div>`; </div>`;
} }
} }