From 03d936099522d978dca93a4850f3171207e0023d Mon Sep 17 00:00:00 2001 From: Ken Sternberg Date: Thu, 10 Aug 2023 12:37:15 -0700 Subject: [PATCH] Linting. --- .../wizard/ApplicationWizardPageBase.ts | 1 + .../wizard/ApplicationWizardSteps.ts | 9 +- .../wizard/ak-application-wizard.ts | 10 +- ...-application-wizard-application-details.ts | 3 - ...ion-wizard-authentication-method-choice.ts | 4 +- .../applications/wizard/stories/samples.ts | 164 +++++++++--------- web/src/admin/applications/wizard/types.ts | 1 - .../ak-wizard-main/ak-wizard-context.ts | 14 +- .../ak-wizard-main/ak-wizard-frame.ts | 2 +- .../ak-wizard-main/ak-wizard-main.ts | 6 +- web/src/components/ak-wizard-main/index.ts | 2 +- .../ak-wizard-main/stories/ak-demo-wizard.ts | 2 +- .../stories/ak-wizard-main.stories.ts | 7 +- web/src/components/ak-wizard-main/types.ts | 23 ++- 14 files changed, 121 insertions(+), 127 deletions(-) diff --git a/web/src/admin/applications/wizard/ApplicationWizardPageBase.ts b/web/src/admin/applications/wizard/ApplicationWizardPageBase.ts index bde4b04d9..7fe79413d 100644 --- a/web/src/admin/applications/wizard/ApplicationWizardPageBase.ts +++ b/web/src/admin/applications/wizard/ApplicationWizardPageBase.ts @@ -13,6 +13,7 @@ export class ApplicationWizardPageBase extends CustomEmitterElement(AKElement) { return AwadStyles; } + // @ts-expect-error @consume({ context: applicationWizardContext, subscribe: true }) @state() public wizard!: WizardState; diff --git a/web/src/admin/applications/wizard/ApplicationWizardSteps.ts b/web/src/admin/applications/wizard/ApplicationWizardSteps.ts index 078729dd8..2c720165b 100644 --- a/web/src/admin/applications/wizard/ApplicationWizardSteps.ts +++ b/web/src/admin/applications/wizard/ApplicationWizardSteps.ts @@ -1,11 +1,12 @@ import { WizardStep, makeWizardId } from "@goauthentik/components/ak-wizard-main"; -import "./application/ak-application-wizard-application-details"; -import "./auth-method-choice/ak-application-wizard-authentication-method-choice"; -import "./auth-method/ak-application-wizard-authentication-method"; import { msg } from "@lit/localize"; import { html } from "lit"; +import "./application/ak-application-wizard-application-details"; +import "./auth-method-choice/ak-application-wizard-authentication-method-choice"; +import "./auth-method/ak-application-wizard-authentication-method"; + export const steps: WizardStep[] = [ { id: makeWizardId("application"), @@ -39,5 +40,5 @@ export const steps: WizardStep[] = [ nextButtonLabel: msg("Submit"), backButtonLabel: msg("Back"), valid: true, - } + }, ]; diff --git a/web/src/admin/applications/wizard/ak-application-wizard.ts b/web/src/admin/applications/wizard/ak-application-wizard.ts index 9f8d1de84..fcbbd2ba5 100644 --- a/web/src/admin/applications/wizard/ak-application-wizard.ts +++ b/web/src/admin/applications/wizard/ak-application-wizard.ts @@ -1,19 +1,19 @@ -import { CustomListenerElement } from "@goauthentik/elements/utils/eventEmitter"; import "@goauthentik/components/ak-wizard-main"; import { AKElement } from "@goauthentik/elements/Base"; +import { CustomListenerElement } from "@goauthentik/elements/utils/eventEmitter"; import { provide } from "@lit-labs/context"; import { msg } from "@lit/localize"; import { CSSResult, TemplateResult, html } from "lit"; -import { property, customElement, state } from "lit/decorators.js"; +import { customElement, property, state } from "lit/decorators.js"; import PFButton from "@patternfly/patternfly/components/Button/button.css"; import PFRadio from "@patternfly/patternfly/components/Radio/radio.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; -import { WizardState, WizardStateEvent } from "./types" import { steps } from "./ApplicationWizardSteps"; import applicationWizardContext from "./ak-application-wizard-context-name"; +import { WizardState, WizardStateEvent } from "./types"; // my-context.ts @@ -37,7 +37,7 @@ export class ApplicationWizard extends CustomListenerElement(AKElement) { @state() steps = steps; - + @property({ type: Boolean }) open = false; @@ -83,7 +83,7 @@ export class ApplicationWizard extends CustomListenerElement(AKElement) { method.disabled = false; this.steps = newSteps; } - + this.wizardState = newWizardState; } diff --git a/web/src/admin/applications/wizard/application/ak-application-wizard-application-details.ts b/web/src/admin/applications/wizard/application/ak-application-wizard-application-details.ts index 0c4d443ef..27e1346b9 100644 --- a/web/src/admin/applications/wizard/application/ak-application-wizard-application-details.ts +++ b/web/src/admin/applications/wizard/application/ak-application-wizard-application-details.ts @@ -16,7 +16,6 @@ import ApplicationWizardPageBase from "../ApplicationWizardPageBase"; @customElement("ak-application-wizard-application-details") export class ApplicationWizardApplicationDetails extends ApplicationWizardPageBase { - handleChange(ev: Event) { if (!ev.target) { console.warn(`Received event with no target: ${ev}`); @@ -89,6 +88,4 @@ export class ApplicationWizardApplicationDetails extends ApplicationWizardPageBa } } - - export default ApplicationWizardApplicationDetails; diff --git a/web/src/admin/applications/wizard/auth-method-choice/ak-application-wizard-authentication-method-choice.ts b/web/src/admin/applications/wizard/auth-method-choice/ak-application-wizard-authentication-method-choice.ts index a868d4e41..65c3cce6a 100644 --- a/web/src/admin/applications/wizard/auth-method-choice/ak-application-wizard-authentication-method-choice.ts +++ b/web/src/admin/applications/wizard/auth-method-choice/ak-application-wizard-authentication-method-choice.ts @@ -37,8 +37,8 @@ export class ApplicationWizardAuthenticationMethodChoice extends ApplicationWiza type="radio" name="type" id="provider-${type.modelName}" -value=${type.modelName} -?checked=${type.modelName === method} + value=${type.modelName} + ?checked=${type.modelName === method} @change=${this.handleChoice} /> diff --git a/web/src/admin/applications/wizard/stories/samples.ts b/web/src/admin/applications/wizard/stories/samples.ts index dd90c6c52..27b5867aa 100644 --- a/web/src/admin/applications/wizard/stories/samples.ts +++ b/web/src/admin/applications/wizard/stories/samples.ts @@ -252,102 +252,102 @@ export const dummyHasJwks = { }; export const dummySAMLProviderMappings = { - "pagination": { - "next": 0, - "previous": 0, - "count": 7, - "current": 1, - "total_pages": 1, - "start_index": 1, - "end_index": 7 + pagination: { + next: 0, + previous: 0, + count: 7, + current: 1, + total_pages: 1, + start_index: 1, + end_index: 7, }, - "results": [ + results: [ { - "pk": "9f1f23b7-1956-4daa-b08b-338cab9b3953", - "managed": "goauthentik.io/providers/saml/uid", - "name": "authentik default SAML Mapping: User ID", - "expression": "return request.user.pk", - "component": "ak-property-mapping-saml-form", - "verbose_name": "SAML Property Mapping", - "verbose_name_plural": "SAML Property Mappings", - "meta_model_name": "authentik_providers_saml.samlpropertymapping", - "saml_name": "http://schemas.goauthentik.io/2021/02/saml/uid", - "friendly_name": null + pk: "9f1f23b7-1956-4daa-b08b-338cab9b3953", + managed: "goauthentik.io/providers/saml/uid", + name: "authentik default SAML Mapping: User ID", + expression: "return request.user.pk", + component: "ak-property-mapping-saml-form", + verbose_name: "SAML Property Mapping", + verbose_name_plural: "SAML Property Mappings", + meta_model_name: "authentik_providers_saml.samlpropertymapping", + saml_name: "http://schemas.goauthentik.io/2021/02/saml/uid", + friendly_name: null, }, { - "pk": "801b6328-bb0b-4ec6-b52c-f3dc7bb6ec7f", - "managed": "goauthentik.io/providers/saml/username", - "name": "authentik default SAML Mapping: Username", - "expression": "return request.user.username", - "component": "ak-property-mapping-saml-form", - "verbose_name": "SAML Property Mapping", - "verbose_name_plural": "SAML Property Mappings", - "meta_model_name": "authentik_providers_saml.samlpropertymapping", - "saml_name": "http://schemas.goauthentik.io/2021/02/saml/username", - "friendly_name": null + pk: "801b6328-bb0b-4ec6-b52c-f3dc7bb6ec7f", + managed: "goauthentik.io/providers/saml/username", + name: "authentik default SAML Mapping: Username", + expression: "return request.user.username", + component: "ak-property-mapping-saml-form", + verbose_name: "SAML Property Mapping", + verbose_name_plural: "SAML Property Mappings", + meta_model_name: "authentik_providers_saml.samlpropertymapping", + saml_name: "http://schemas.goauthentik.io/2021/02/saml/username", + friendly_name: null, }, { - "pk": "27c4d370-658d-4acf-9f61-cfa6dd020b11", - "managed": "goauthentik.io/providers/saml/ms-windowsaccountname", - "name": "authentik default SAML Mapping: WindowsAccountname (Username)", - "expression": "return request.user.username", - "component": "ak-property-mapping-saml-form", - "verbose_name": "SAML Property Mapping", - "verbose_name_plural": "SAML Property Mappings", - "meta_model_name": "authentik_providers_saml.samlpropertymapping", - "saml_name": "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", - "friendly_name": null + pk: "27c4d370-658d-4acf-9f61-cfa6dd020b11", + managed: "goauthentik.io/providers/saml/ms-windowsaccountname", + name: "authentik default SAML Mapping: WindowsAccountname (Username)", + expression: "return request.user.username", + component: "ak-property-mapping-saml-form", + verbose_name: "SAML Property Mapping", + verbose_name_plural: "SAML Property Mappings", + meta_model_name: "authentik_providers_saml.samlpropertymapping", + saml_name: "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", + friendly_name: null, }, { - "pk": "757b185b-1c21-42b4-a2ee-04d6f7b655b3", - "managed": "goauthentik.io/providers/saml/groups", - "name": "authentik default SAML Mapping: Groups", - "expression": "for group in request.user.ak_groups.all():\n yield group.name", - "component": "ak-property-mapping-saml-form", - "verbose_name": "SAML Property Mapping", - "verbose_name_plural": "SAML Property Mappings", - "meta_model_name": "authentik_providers_saml.samlpropertymapping", - "saml_name": "http://schemas.xmlsoap.org/claims/Group", - "friendly_name": null + pk: "757b185b-1c21-42b4-a2ee-04d6f7b655b3", + managed: "goauthentik.io/providers/saml/groups", + name: "authentik default SAML Mapping: Groups", + expression: "for group in request.user.ak_groups.all():\n yield group.name", + component: "ak-property-mapping-saml-form", + verbose_name: "SAML Property Mapping", + verbose_name_plural: "SAML Property Mappings", + meta_model_name: "authentik_providers_saml.samlpropertymapping", + saml_name: "http://schemas.xmlsoap.org/claims/Group", + friendly_name: null, }, { - "pk": "de67cee7-7c56-4c1d-9466-9ad0e0105092", - "managed": "goauthentik.io/providers/saml/email", - "name": "authentik default SAML Mapping: Email", - "expression": "return request.user.email", - "component": "ak-property-mapping-saml-form", - "verbose_name": "SAML Property Mapping", - "verbose_name_plural": "SAML Property Mappings", - "meta_model_name": "authentik_providers_saml.samlpropertymapping", - "saml_name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", - "friendly_name": null + pk: "de67cee7-7c56-4c1d-9466-9ad0e0105092", + managed: "goauthentik.io/providers/saml/email", + name: "authentik default SAML Mapping: Email", + expression: "return request.user.email", + component: "ak-property-mapping-saml-form", + verbose_name: "SAML Property Mapping", + verbose_name_plural: "SAML Property Mappings", + meta_model_name: "authentik_providers_saml.samlpropertymapping", + saml_name: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", + friendly_name: null, }, { - "pk": "42a936a5-11a9-4442-8748-ec27a8ab9546", - "managed": "goauthentik.io/providers/saml/name", - "name": "authentik default SAML Mapping: Name", - "expression": "return request.user.name", - "component": "ak-property-mapping-saml-form", - "verbose_name": "SAML Property Mapping", - "verbose_name_plural": "SAML Property Mappings", - "meta_model_name": "authentik_providers_saml.samlpropertymapping", - "saml_name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", - "friendly_name": null + pk: "42a936a5-11a9-4442-8748-ec27a8ab9546", + managed: "goauthentik.io/providers/saml/name", + name: "authentik default SAML Mapping: Name", + expression: "return request.user.name", + component: "ak-property-mapping-saml-form", + verbose_name: "SAML Property Mapping", + verbose_name_plural: "SAML Property Mappings", + meta_model_name: "authentik_providers_saml.samlpropertymapping", + saml_name: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", + friendly_name: null, }, { - "pk": "06bee8f0-e5b4-4ce8-959a-308ba0769917", - "managed": "goauthentik.io/providers/saml/upn", - "name": "authentik default SAML Mapping: UPN", - "expression": "return request.user.attributes.get('upn', request.user.email)", - "component": "ak-property-mapping-saml-form", - "verbose_name": "SAML Property Mapping", - "verbose_name_plural": "SAML Property Mappings", - "meta_model_name": "authentik_providers_saml.samlpropertymapping", - "saml_name": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn", - "friendly_name": null - } - ] -} + pk: "06bee8f0-e5b4-4ce8-959a-308ba0769917", + managed: "goauthentik.io/providers/saml/upn", + name: "authentik default SAML Mapping: UPN", + expression: "return request.user.attributes.get('upn', request.user.email)", + component: "ak-property-mapping-saml-form", + verbose_name: "SAML Property Mapping", + verbose_name_plural: "SAML Property Mappings", + meta_model_name: "authentik_providers_saml.samlpropertymapping", + saml_name: "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn", + friendly_name: null, + }, + ], +}; // prettier-ignore export const dummyProviderTypesList = [ diff --git a/web/src/admin/applications/wizard/types.ts b/web/src/admin/applications/wizard/types.ts index 05f0df578..c850b5111 100644 --- a/web/src/admin/applications/wizard/types.ts +++ b/web/src/admin/applications/wizard/types.ts @@ -24,4 +24,3 @@ export interface WizardState { } export type WizardStateEvent = WizardState & { target?: HTMLInputElement }; - diff --git a/web/src/components/ak-wizard-main/ak-wizard-context.ts b/web/src/components/ak-wizard-main/ak-wizard-context.ts index 426683092..399909080 100644 --- a/web/src/components/ak-wizard-main/ak-wizard-context.ts +++ b/web/src/components/ak-wizard-main/ak-wizard-context.ts @@ -4,10 +4,9 @@ import { provide } from "@lit-labs/context"; import { customElement, property, state } from "@lit/reactive-element/decorators.js"; import { LitElement, html } from "lit"; -import type { WizardStep, WizardStepId } from "./types"; -import { WizardStepEvent, } from "./types"; import { akWizardCurrentStepContextName } from "./akWizardCurrentStepContextName"; import { akWizardStepsContextName } from "./akWizardStepsContextName"; +import type { WizardStep, WizardStepId } from "./types"; /** * AkWizardContext @@ -19,12 +18,11 @@ import { akWizardStepsContextName } from "./akWizardStepsContextName"; * */ -@customElement("ak-wizard-context") +@customElement("ak-wizard-context") export class AkWizardContext extends CustomListenerElement(LitElement) { - @property() eventName: string = "ak-wizard-nav"; - + @provide({ context: akWizardStepsContextName }) @property({ attribute: false }) steps: WizardStep[] = []; @@ -40,6 +38,8 @@ export class AkWizardContext extends CustomListenerElement(LitElement) { // This is the only case where currentStep could be anything other than a valid entry. Unless, // of course, a step itself is so badly messed up it can't point to a real object. + + // eslint-disable-next-line @typescript-eslint/no-explicit-any willUpdate(_changedProperties: Map) { if (this.currentStep === undefined) { this.currentStep = this.steps[0]; @@ -53,10 +53,10 @@ export class AkWizardContext extends CustomListenerElement(LitElement) { // before setting the currentStep. Especially since setting the currentStep triggers a second // asynchronous event-- scheduling a re-render of everything interested in the currentStep // object. - handleNavigation(event: CustomEvent<{ step: WizardStepId | WizardStepEvent }>) { + handleNavigation(event: CustomEvent<{ step: WizardStepId }>) { const requestedStep = event.detail.step; if (!requestedStep) { - throw new Error("Request for next step when no next step is available") + throw new Error("Request for next step when no next step is available"); } const step = this.steps.find(({ id }) => id === requestedStep); if (!step) { diff --git a/web/src/components/ak-wizard-main/ak-wizard-frame.ts b/web/src/components/ak-wizard-main/ak-wizard-frame.ts index 70a6f8bf8..77c458bc7 100644 --- a/web/src/components/ak-wizard-main/ak-wizard-frame.ts +++ b/web/src/components/ak-wizard-main/ak-wizard-frame.ts @@ -27,7 +27,7 @@ import type { WizardStep } from "./types"; * @fires ak-wizard-nav - Tell the orchestrator what page the user wishes to move to. This is the * only event that causes this wizard to change its appearance. * - * NOTE: The event name is configurable as an attribute. + * NOTE: The event name is configurable as an attribute. * */ diff --git a/web/src/components/ak-wizard-main/ak-wizard-main.ts b/web/src/components/ak-wizard-main/ak-wizard-main.ts index 905904333..c31df43c3 100644 --- a/web/src/components/ak-wizard-main/ak-wizard-main.ts +++ b/web/src/components/ak-wizard-main/ak-wizard-main.ts @@ -9,8 +9,8 @@ import PFButton from "@patternfly/patternfly/components/Button/button.css"; import PFRadio from "@patternfly/patternfly/components/Radio/radio.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; -import "./ak-wizard-frame"; import "./ak-wizard-context"; +import "./ak-wizard-frame"; import type { WizardStep } from "./types"; /** @@ -42,7 +42,7 @@ export class AkWizardMain extends AKElement { * @attribute */ @property({ type: String }) - prompt = "Show Wizard" + prompt = "Show Wizard"; /** * Mostly a control on the ModalButton that summons the wizard component. @@ -76,7 +76,7 @@ export class AkWizardMain extends AKElement { header=${this.header} description=${ifDefined(this.description)} > - + `; diff --git a/web/src/components/ak-wizard-main/index.ts b/web/src/components/ak-wizard-main/index.ts index 2d4c1a937..30bb39ff1 100644 --- a/web/src/components/ak-wizard-main/index.ts +++ b/web/src/components/ak-wizard-main/index.ts @@ -1,5 +1,5 @@ import "./ak-wizard-main"; -import type { WizardStepId, WizardStep } from "./types" +import type { WizardStep, WizardStepId } from "./types"; import { makeWizardId } from "./types"; export { WizardStepId, WizardStep, makeWizardId }; diff --git a/web/src/components/ak-wizard-main/stories/ak-demo-wizard.ts b/web/src/components/ak-wizard-main/stories/ak-demo-wizard.ts index 00a58dcb5..750a55b77 100644 --- a/web/src/components/ak-wizard-main/stories/ak-demo-wizard.ts +++ b/web/src/components/ak-wizard-main/stories/ak-demo-wizard.ts @@ -9,8 +9,8 @@ import PFButton from "@patternfly/patternfly/components/Button/button.css"; import PFRadio from "@patternfly/patternfly/components/Radio/radio.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; -import "../ak-wizard-frame"; import "../ak-wizard-context"; +import "../ak-wizard-frame"; import type { WizardStep } from "../types"; @customElement("ak-demo-wizard") diff --git a/web/src/components/ak-wizard-main/stories/ak-wizard-main.stories.ts b/web/src/components/ak-wizard-main/stories/ak-wizard-main.stories.ts index 98d4d4cd6..235f55faf 100644 --- a/web/src/components/ak-wizard-main/stories/ak-wizard-main.stories.ts +++ b/web/src/components/ak-wizard-main/stories/ak-wizard-main.stories.ts @@ -3,9 +3,8 @@ import { Meta } from "@storybook/web-components"; import { TemplateResult, html } from "lit"; -import "../ak-wizard-main" +import "../ak-wizard-main"; import AkWizard from "../ak-wizard-main"; - import type { WizardStep } from "../types"; import { makeWizardId } from "../types"; @@ -37,8 +36,6 @@ const container = (testItem: TemplateResult) => ${testItem} `; - - const dummySteps: WizardStep[] = [ { id: makeWizardId("0"), @@ -64,6 +61,6 @@ const dummySteps: WizardStep[] = [ export const OnePageWizard = () => { return container( - html` ` + html` `, ); }; diff --git a/web/src/components/ak-wizard-main/types.ts b/web/src/components/ak-wizard-main/types.ts index b6f4e725e..a1911fb0d 100644 --- a/web/src/components/ak-wizard-main/types.ts +++ b/web/src/components/ak-wizard-main/types.ts @@ -1,20 +1,19 @@ import { TemplateResult } from "lit"; -type PhantomType = {_type: Type} & Data; +type PhantomType = { _type: Type } & Data; -export type WizardStepId = PhantomType<"WizardId", string> +export type WizardStepId = PhantomType<"WizardId", string>; export const makeWizardId = (id: string): WizardStepId => id as WizardStepId; export interface WizardStep { - id: WizardStepId, - nextStep?: WizardStepId, - backStep?: WizardStepId, - label: string, - valid: boolean, - renderer: () => TemplateResult, - disabled: boolean, - nextButtonLabel?: string, - backButtonLabel?: string + id: WizardStepId; + nextStep?: WizardStepId; + backStep?: WizardStepId; + label: string; + valid: boolean; + renderer: () => TemplateResult; + disabled: boolean; + nextButtonLabel?: string; + backButtonLabel?: string; } -