web: updating with forms and fixes for eslint complaints.

This commit is contained in:
Ken Sternberg 2023-09-21 14:51:14 -07:00
parent 0a43ea286e
commit a25df9aadc
9 changed files with 27 additions and 26 deletions

View file

@ -93,15 +93,15 @@ export class ApplicationWizardCommitApplication extends BasePanel {
this.response = undefined; this.response = undefined;
this.commitState = runningState; this.commitState = runningState;
const provider = providerModelsList.find( const provider = providerModelsList.find(
({ formName }) => formName === this.wizard.providerModel ({ formName }) => formName === this.wizard.providerModel,
); );
if (!provider) { if (!provider) {
throw new Error( throw new Error(
`Could not determine provider model from user request: ${JSON.stringify( `Could not determine provider model from user request: ${JSON.stringify(
this.wizard, this.wizard,
null, null,
2 2,
)}` )}`,
); );
} }
@ -117,7 +117,7 @@ export class ApplicationWizardCommitApplication extends BasePanel {
} }
async send( async send(
data: TransactionApplicationRequest data: TransactionApplicationRequest,
): Promise<TransactionApplicationResponse | void> { ): Promise<TransactionApplicationResponse | void> {
this.errors = []; this.errors = [];
@ -153,7 +153,7 @@ export class ApplicationWizardCommitApplication extends BasePanel {
${this.errors.length > 0 ${this.errors.length > 0
? html`<ul> ? html`<ul>
${this.errors.map( ${this.errors.map(
(msg) => html`<li><code>${msg}</code></li>` (msg) => html`<li><code>${msg}</code></li>`,
)} )}
</ul>` </ul>`
: nothing} : nothing}

View file

@ -1,22 +1,24 @@
import "@goauthentik/admin/common/ak-flow-search/ak-flow-search-no-default"; import "@goauthentik/admin/common/ak-flow-search/ak-flow-search-no-default";
import "@goauthentik/components/ak-file-input"; import "@goauthentik/components/ak-file-input";
import { AkFileInput } from "@goauthentik/components/ak-file-input";
import "@goauthentik/components/ak-text-input"; import "@goauthentik/components/ak-text-input";
import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/HorizontalFormElement";
import { msg } from "@lit/localize"; import { msg } from "@lit/localize";
import { customElement } from "@lit/reactive-element/decorators/custom-element.js"; import { customElement } from "@lit/reactive-element/decorators/custom-element.js";
import { html } from "lit"; import { html } from "lit";
import { query } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js"; import { ifDefined } from "lit/directives/if-defined.js";
import { FlowsInstancesListDesignationEnum, ProvidersSamlImportMetadataCreateRequest } from "@goauthentik/api"; import {
FlowsInstancesListDesignationEnum,
ProvidersSamlImportMetadataCreateRequest,
} from "@goauthentik/api";
import BaseProviderPanel from "../BaseProviderPanel"; import BaseProviderPanel from "../BaseProviderPanel";
import { query } from "lit/decorators.js";
import { AkFileInput } from "@goauthentik/components/ak-file-input";
@customElement("ak-application-wizard-authentication-by-saml-import") @customElement("ak-application-wizard-authentication-by-saml-import")
export class ApplicationWizardProviderSamlImport extends BaseProviderPanel { export class ApplicationWizardProviderSamlImport extends BaseProviderPanel {
@query('ak-file-input[name="metadata"]') @query('ak-file-input[name="metadata"]')
fileInput!: AkFileInput; fileInput!: AkFileInput;
@ -32,7 +34,7 @@ export class ApplicationWizardProviderSamlImport extends BaseProviderPanel {
this.dispatchWizardUpdate({ this.dispatchWizardUpdate({
update: { update: {
provider: { provider: {
file file,
}, },
}, },
status: this.form.checkValidity() ? "valid" : "invalid", status: this.form.checkValidity() ? "valid" : "invalid",
@ -44,7 +46,9 @@ export class ApplicationWizardProviderSamlImport extends BaseProviderPanel {
} }
render() { render() {
const provider = this.wizard.provider as ProvidersSamlImportMetadataCreateRequest | undefined; const provider = this.wizard.provider as
| ProvidersSamlImportMetadataCreateRequest
| undefined;
return html` <form class="pf-c-form pf-m-horizontal" @input=${this.handleChange}> return html` <form class="pf-c-form pf-m-horizontal" @input=${this.handleChange}>
<ak-text-input <ak-text-input

View file

@ -2,11 +2,11 @@ import {
ApplicationRequest, ApplicationRequest,
LDAPProviderRequest, LDAPProviderRequest,
OAuth2ProviderRequest, OAuth2ProviderRequest,
ProvidersSamlImportMetadataCreateRequest,
ProxyProviderRequest, ProxyProviderRequest,
RadiusProviderRequest, RadiusProviderRequest,
SAMLProviderRequest, SAMLProviderRequest,
SCIMProviderRequest, SCIMProviderRequest,
ProvidersSamlImportMetadataCreateRequest,
} from "@goauthentik/api"; } from "@goauthentik/api";
export type OneOfProvider = export type OneOfProvider =

View file

@ -7,7 +7,6 @@ import { CustomListenerElement } from "@goauthentik/elements/utils/eventEmitter"
import { html } from "lit"; import { html } from "lit";
import { property, query } from "lit/decorators.js"; import { property, query } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js";
import { FlowsApi, FlowsInstancesListDesignationEnum } from "@goauthentik/api"; import { FlowsApi, FlowsInstancesListDesignationEnum } from "@goauthentik/api";
import type { Flow, FlowsInstancesListRequest } from "@goauthentik/api"; import type { Flow, FlowsInstancesListRequest } from "@goauthentik/api";

View file

@ -248,13 +248,8 @@ export class OAuth2ProviderFormPage extends ModelForm<OAuth2Provider, number> {
<ak-form-element-horizontal label=${msg("Signing Key")} name="signingKey"> <ak-form-element-horizontal label=${msg("Signing Key")} name="signingKey">
<!-- NOTE: 'null' cast to 'undefined' on signingKey to satisfy Lit requirements --> <!-- NOTE: 'null' cast to 'undefined' on signingKey to satisfy Lit requirements -->
<ak-crypto-certificate-search <ak-crypto-certificate-search
<<<<<<< HEAD
certificate=${ifDefined(this.instance?.signingKey ?? undefined)} certificate=${ifDefined(this.instance?.signingKey ?? undefined)}
singleton singleton
=======
certificate=${ifDefined(this.instance?.signingKey || "")}
?singleton=${!this.instance}
>>>>>>> main
></ak-crypto-certificate-search> ></ak-crypto-certificate-search>
<p class="pf-c-form__helper-text">${msg("Key used to sign the tokens.")}</p> <p class="pf-c-form__helper-text">${msg("Key used to sign the tokens.")}</p>
</ak-form-element-horizontal> </ak-form-element-horizontal>

View file

@ -42,7 +42,7 @@ export class AkFileInput extends AKElement {
@query('input[type="file"]') @query('input[type="file"]')
input!: HTMLInputElement; input!: HTMLInputElement;
get files() { get files() {
return this.input.files; return this.input.files;
} }

View file

@ -1,5 +1,8 @@
import { AKElement } from "@goauthentik/elements/Base"; import { AKElement } from "@goauthentik/elements/Base";
import { CustomEmitterElement, CustomListenerElement } from "@goauthentik/elements/utils/eventEmitter"; import {
CustomEmitterElement,
CustomListenerElement,
} from "@goauthentik/elements/utils/eventEmitter";
import { html } from "lit"; import { html } from "lit";
import { customElement, property, query, state } from "lit/decorators.js"; import { customElement, property, query, state } from "lit/decorators.js";
@ -167,7 +170,7 @@ export class AkWizardMain extends CustomEmitterElement(CustomListenerElement(AKE
case "close": { case "close": {
this.currentStep = 0; this.currentStep = 0;
this.frame.open = false; this.frame.open = false;
this.dispatchCustomEvent('ak-wizard-closed'); this.dispatchCustomEvent("ak-wizard-closed");
} }
} }
} }

View file

@ -83,7 +83,7 @@ export class SearchSelect<T> extends CustomEmitterElement(AKElement) {
this.open = false; this.open = false;
this.shadowRoot this.shadowRoot
?.querySelectorAll<HTMLInputElement>( ?.querySelectorAll<HTMLInputElement>(
".pf-c-form-control.pf-c-select__toggle-typeahead" ".pf-c-form-control.pf-c-select__toggle-typeahead",
) )
.forEach((input) => { .forEach((input) => {
input.blur(); input.blur();
@ -264,7 +264,7 @@ export class SearchSelect<T> extends CustomEmitterElement(AKElement) {
</ul> </ul>
</div>`, </div>`,
this.dropdownContainer, this.dropdownContainer,
{ host: this } { host: this },
); );
} }
@ -306,7 +306,7 @@ export class SearchSelect<T> extends CustomEmitterElement(AKElement) {
// Check if we're losing focus to one of our dropdown items, and if such don't blur // Check if we're losing focus to one of our dropdown items, and if such don't blur
if (ev.relatedTarget instanceof HTMLButtonElement) { if (ev.relatedTarget instanceof HTMLButtonElement) {
const parentMenu = ev.relatedTarget.closest( const parentMenu = ev.relatedTarget.closest(
"ul.pf-c-dropdown__menu.pf-m-static" "ul.pf-c-dropdown__menu.pf-m-static",
); );
if (parentMenu && parentMenu.id === this.dropdownUID) { if (parentMenu && parentMenu.id === this.dropdownUID) {
return; return;

View file

@ -67,7 +67,7 @@ export class LibraryPage extends AKElement {
this.filteredApps = this.apps?.results; this.filteredApps = this.apps?.results;
if (this.filteredApps === undefined) { if (this.filteredApps === undefined) {
throw new Error( throw new Error(
"Application.results should never be undefined when passed to the Library Page." "Application.results should never be undefined when passed to the Library Page.",
); );
} }
this.addEventListener(SEARCH_UPDATED, this.searchUpdated); this.addEventListener(SEARCH_UPDATED, this.searchUpdated);
@ -146,7 +146,7 @@ export class LibraryPage extends AKElement {
this.apps, this.apps,
html`${this.filteredApps.find(appHasLaunchUrl) html`${this.filteredApps.find(appHasLaunchUrl)
? this.renderApps() ? this.renderApps()
: this.renderEmptyState()}` : this.renderEmptyState()}`,
)} )}
</section> </section>
</main>`; </main>`;