Skip to content

Commit

Permalink
remove more html``
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <[email protected]>
  • Loading branch information
BeryJu committed Aug 16, 2024
1 parent fe87822 commit 811acd5
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 31 deletions.
5 changes: 3 additions & 2 deletions web/src/flow/FlowExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,13 @@ export class FlowExecutor extends Interface implements StageHost {
alt="authentik Logo"
/>
</div>`;
const fallback = html`${logo}<ak-empty-state loading> </ak-empty-state>`;
if (!this.challenge) {
return html`${logo}<ak-empty-state loading> </ak-empty-state>`;
return fallback;
}
return html`
${this.loading ? html`<ak-loading-overlay></ak-loading-overlay>` : nothing} ${logo}
${until(this.renderChallenge())}
${until(this.renderChallenge(), fallback)}
`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BaseStage, StageHost, SubmitOptions } from "@goauthentik/flow/stages/ba
import { PasswordManagerPrefill } from "@goauthentik/flow/stages/identification/IdentificationStage";

import { msg } from "@lit/localize";
import { CSSResult, TemplateResult, css, html } from "lit";
import { CSSResult, TemplateResult, css, html, nothing } from "lit";
import { customElement, state } from "lit/decorators.js";

import PFButton from "@patternfly/patternfly/components/Button/button.css";
Expand Down Expand Up @@ -112,7 +112,7 @@ export class AuthenticatorValidateStage
`);
}

renderDevicePickerSingle(deviceChallenge: DeviceChallenge): TemplateResult {
renderDevicePickerSingle(deviceChallenge: DeviceChallenge) {
switch (deviceChallenge.deviceClass) {
case DeviceClassesEnum.Duo:
return html`<i class="fas fa-mobile-alt"></i>
Expand Down Expand Up @@ -147,7 +147,7 @@ export class AuthenticatorValidateStage
default:
break;
}
return html``;
return nothing;
}

renderDevicePicker(): TemplateResult {
Expand Down Expand Up @@ -192,9 +192,9 @@ export class AuthenticatorValidateStage
</ul>`;
}

renderDeviceChallenge(): TemplateResult {
renderDeviceChallenge() {
if (!this.selectedDeviceChallenge) {
return html``;
return nothing;
}
switch (this.selectedDeviceChallenge?.deviceClass) {
case DeviceClassesEnum.Static:
Expand Down Expand Up @@ -224,7 +224,7 @@ export class AuthenticatorValidateStage
>
</ak-stage-authenticator-validate-duo>`;
}
return html``;
return nothing;
}

render(): TemplateResult {
Expand Down
6 changes: 3 additions & 3 deletions web/src/flow/stages/authenticator_validate/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AuthenticatorValidateStage } from "@goauthentik/flow/stages/authenticat
import { BaseStage, FlowInfoChallenge, PendingUserChallenge } from "@goauthentik/flow/stages/base";

import { msg } from "@lit/localize";
import { CSSResult, TemplateResult, css, html } from "lit";
import { CSSResult, css, html, nothing } from "lit";
import { property } from "lit/decorators.js";

import PFButton from "@patternfly/patternfly/components/Button/button.css";
Expand Down Expand Up @@ -48,9 +48,9 @@ export class BaseDeviceStage<
return this.host?.submit(payload) || Promise.resolve();
}

renderReturnToDevicePicker(): TemplateResult {
renderReturnToDevicePicker() {
if (!this.showBackButton) {
return html``;
return nothing;
}
return html`<button
class="pf-c-button pf-m-secondary pf-m-block"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class WebAuthnAuthenticatorRegisterStage extends BaseStage<
? html`<p class="pf-m-block">
${this.challenge.responseErrors["response"][0].string}
</p>`
: html``}
: nothing}
<div class="pf-c-form__group pf-m-action">
${!this.registerRunning
? html` <button
Expand Down
6 changes: 3 additions & 3 deletions web/src/flow/stages/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AKElement } from "@goauthentik/elements/Base";
import { KeyUnknown } from "@goauthentik/elements/forms/Form";

import { msg } from "@lit/localize";
import { TemplateResult, html, nothing } from "lit";
import { html, nothing } from "lit";
import { property } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";

Expand Down Expand Up @@ -99,9 +99,9 @@ export class BaseStage<
</div>`;
}

renderUserInfo(): TemplateResult {
renderUserInfo() {
if (!this.challenge.pendingUser || !this.challenge.pendingUserAvatar) {
return html``;
return nothing;
}
return html`
<ak-form-static
Expand Down
8 changes: 4 additions & 4 deletions web/src/flow/stages/consent/ConsentStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "@goauthentik/flow/FormStatic";
import { BaseStage } from "@goauthentik/flow/stages/base";

import { msg } from "@lit/localize";
import { CSSResult, TemplateResult, html } from "lit";
import { CSSResult, TemplateResult, html, nothing } from "lit";
import { customElement } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";

Expand Down Expand Up @@ -56,7 +56,7 @@ export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeRe
${this.renderPermissions(this.challenge.permissions)}
</ul>
`
: html``}
: nothing}
</div>
`;
}
Expand All @@ -76,7 +76,7 @@ export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeRe
${this.renderPermissions(this.challenge.permissions)}
</ul>
`
: html``}
: nothing}
</div>
<div class="pf-c-form__group pf-u-mt-md">
${this.challenge.additionalPermissions.length > 0
Expand All @@ -88,7 +88,7 @@ export class ConsentStage extends BaseStage<ConsentChallenge, ConsentChallengeRe
${this.renderPermissions(this.challenge.additionalPermissions)}
</ul>
`
: html``}
: nothing}
</div>
`;
}
Expand Down
4 changes: 2 additions & 2 deletions web/src/flow/stages/identification/IdentificationStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ export class IdentificationStage extends BaseStage<
</li>`;
}

renderFooter(): TemplateResult {
renderFooter() {
if (!this.challenge?.enrollUrl && !this.challenge?.recoveryUrl) {
return html``;
return nothing;
}
return html`<div class="pf-c-login__main-footer-band">
${this.challenge.enrollUrl
Expand Down
8 changes: 4 additions & 4 deletions web/src/flow/stages/prompt/PromptStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "@goauthentik/elements/forms/FormElement";
import { BaseStage } from "@goauthentik/flow/stages/base";

import { msg } from "@lit/localize";
import { CSSResult, TemplateResult, css, html } from "lit";
import { CSSResult, TemplateResult, css, html, nothing } from "lit";
import { customElement } from "lit/decorators.js";
import { unsafeHTML } from "lit/directives/unsafe-html.js";

Expand Down Expand Up @@ -222,9 +222,9 @@ ${prompt.initialValue}</textarea
}
}

renderPromptHelpText(prompt: StagePrompt): TemplateResult {
renderPromptHelpText(prompt: StagePrompt) {
if (prompt.subText === "") {
return html``;
return nothing;
}
return html`<p class="pf-c-form__helper-text">${unsafeHTML(prompt.subText)}</p>`;
}
Expand Down Expand Up @@ -253,7 +253,7 @@ ${prompt.initialValue}</textarea
<label class="pf-c-check__label" for="${prompt.fieldKey}">${prompt.label}</label>
${prompt.required
? html`<p class="pf-c-form__helper-text">${msg("Required.")}</p>`
: html``}
: nothing}
<p class="pf-c-form__helper-text">${unsafeHTML(prompt.subText)}</p>
</div>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ export class UserSettingsPromptStage extends PromptStage {
${this.challenge.fields.map((prompt) => {
return this.renderField(prompt);
})}
${"non_field_errors" in (this.challenge?.responseErrors || {})
? this.renderNonFieldErrors(
this.challenge?.responseErrors?.non_field_errors || [],
)
: html``}
${this.renderContinue()}
${this.renderNonFieldErrors()} ${this.renderContinue()}
</form>
</div>
<footer class="pf-c-login__main-footer">
Expand Down

0 comments on commit 811acd5

Please sign in to comment.