Skip to content

Commit

Permalink
web/legible/disambiguate-footer-links
Browse files Browse the repository at this point in the history
# What

- Replaces the "brand links" box at the bottom of FlowExecutor with a component for showing brand
  links.

# Why

- Confusion arose about what "footer links" mean in any given context, and breaking this out,
  labeling it "brand-links," reduces that confusion. It also isolates and reduces the testable
  surface area of the Executor.
  • Loading branch information
kensternberg-authentik committed Nov 21, 2024
1 parent 9809b94 commit c3b33fd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 20 deletions.
24 changes: 4 additions & 20 deletions web/src/flow/FlowExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
TITLE_DEFAULT,
} from "@goauthentik/common/constants";
import { globalAK } from "@goauthentik/common/global";
import { purify } from "@goauthentik/common/purify";
import { configureSentry } from "@goauthentik/common/sentry";
import { first } from "@goauthentik/common/utils";
import { WebsocketClient } from "@goauthentik/common/ws";
Expand All @@ -14,6 +13,7 @@ import "@goauthentik/elements/LoadingOverlay";
import "@goauthentik/elements/ak-locale-context";
import { DefaultBrand } from "@goauthentik/elements/sidebar/SidebarBrand";
import { themeImage } from "@goauthentik/elements/utils/images";
import "@goauthentik/flow/components/ak-brand-footer";
import "@goauthentik/flow/sources/apple/AppleLoginInit";
import "@goauthentik/flow/sources/plex/PlexLoginInit";
import "@goauthentik/flow/stages/FlowErrorStage";
Expand Down Expand Up @@ -516,25 +516,9 @@ export class FlowExecutor extends Interface implements StageHost {
${until(this.renderChallenge())}
</div>
<footer class="pf-c-login__footer">
<ul class="pf-c-list pf-m-inline">
${this.brand?.uiFooterLinks?.map((link) => {
if (link.href) {
return html`${purify(
html`<li>
<a href="${link.href}"
>${link.name}</a
>
</li>`,
)}`;
}
return html`<li>
<span>${link.name}</span>
</li>`;
})}
<li>
<span>${msg("Powered by authentik")}</span>
</li>
</ul>
<ak-brand-links
.links=${this.brand?.uiFooterLinks ?? []}
></ak-brand-links>
</footer>
</div>
</div>
Expand Down
51 changes: 51 additions & 0 deletions web/src/flow/components/ak-brand-footer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { purify } from "@goauthentik/common/purify";
import { AKElement } from "@goauthentik/elements/Base.js";

import { msg } from "@lit/localize";
import { css, html } from "lit";
import { customElement, property } from "lit/decorators.js";
import { map } from "lit/directives/map.js";

import PFList from "@patternfly/patternfly/components/List/list.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";

import { FooterLink } from "@goauthentik/api";

const styles = css`
.pf-c-list a {
color: unset;
}
ul.pf-c-list.pf-m-inline {
justify-content: center;
padding: calc(var(--pf-global--spacer--xs) / 2) 0px;
}
`;

const salesMark: FooterLink = { name: msg("Powered by authentik"), href: "" };

@customElement("ak-brand-links")
export class BrandLinks extends AKElement {
static get styles() {
return [PFBase, PFList, styles];
}

@property({ type: Array, attribute: false })
links: FooterLink[] = [];

render() {
const links = [...(this.links ?? []), salesMark];
return html` <ul class="pf-c-list pf-m-inline">
${map(links, (link) =>
link.href
? purify(html`<li><a href="${link.href}">${link.name}</a></li>`)
: html`<li><span>${link.name}</span></li>`,
)}
</ul>`;
}
}

declare global {
interface HTMLElementTagNameMap {
"ak-brand-links": BrandLinks;
}
}

0 comments on commit c3b33fd

Please sign in to comment.