102 lines
3.6 KiB
TypeScript
102 lines
3.6 KiB
TypeScript
|
import { t } from "@lingui/macro";
|
||
|
|
||
|
import { customElement } from "@lit/reactive-element/decorators/custom-element.js";
|
||
|
import { CSSResult, LitElement, TemplateResult, html } from "lit";
|
||
|
import { property } from "lit/decorators.js";
|
||
|
|
||
|
import AKGlobal from "../../authentik.css";
|
||
|
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 { ProvidersApi, TypeCreate } from "@goauthentik/api";
|
||
|
|
||
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
||
|
import "../../elements/forms/ProxyForm";
|
||
|
import "../../elements/wizard/FormWizardPage";
|
||
|
import "../../elements/wizard/Wizard";
|
||
|
import { WizardPage } from "../../elements/wizard/WizardPage";
|
||
|
import "./ldap/LDAPProviderForm";
|
||
|
import "./oauth2/OAuth2ProviderForm";
|
||
|
import "./proxy/ProxyProviderForm";
|
||
|
import "./saml/SAMLProviderForm";
|
||
|
import "./saml/SAMLProviderImportForm";
|
||
|
|
||
|
@customElement("ak-provider-wizard-initial")
|
||
|
export class InitialProviderWizardPage extends WizardPage {
|
||
|
@property({ attribute: false })
|
||
|
providerTypes: TypeCreate[] = [];
|
||
|
|
||
|
static get styles(): CSSResult[] {
|
||
|
return [PFBase, PFButton, AKGlobal, PFRadio];
|
||
|
}
|
||
|
|
||
|
render(): TemplateResult {
|
||
|
return html`
|
||
|
${this.providerTypes.map((type) => {
|
||
|
return html`<div class="pf-c-radio">
|
||
|
<input
|
||
|
class="pf-c-radio__input"
|
||
|
type="radio"
|
||
|
name="type"
|
||
|
id=${type.component}
|
||
|
@change=${() => {
|
||
|
this.host.setSteps("initial", `type-${type.component}`);
|
||
|
this._isValid = true;
|
||
|
}}
|
||
|
/>
|
||
|
<label class="pf-c-radio__label" for=${type.component}>${type.name}</label>
|
||
|
<span class="pf-c-radio__description">${type.description}</span>
|
||
|
</div>`;
|
||
|
})}
|
||
|
`;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@customElement("ak-provider-wizard")
|
||
|
export class ProviderWizard extends LitElement {
|
||
|
static get styles(): CSSResult[] {
|
||
|
return [PFBase, PFButton, AKGlobal, PFRadio];
|
||
|
}
|
||
|
|
||
|
@property()
|
||
|
createText = t`Create`;
|
||
|
|
||
|
@property({ attribute: false })
|
||
|
providerTypes: TypeCreate[] = [];
|
||
|
|
||
|
firstUpdated(): void {
|
||
|
new ProvidersApi(DEFAULT_CONFIG).providersAllTypesList().then((types) => {
|
||
|
this.providerTypes = types;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
render(): TemplateResult {
|
||
|
return html`
|
||
|
<ak-wizard
|
||
|
.steps=${["initial"]}
|
||
|
header=${t`New provider`}
|
||
|
description=${t`Create a new provider.`}
|
||
|
>
|
||
|
<ak-provider-wizard-initial
|
||
|
slot="initial"
|
||
|
.sidebarLabel=${() => t`Select type`}
|
||
|
.providerTypes=${this.providerTypes}
|
||
|
>
|
||
|
</ak-provider-wizard-initial>
|
||
|
${this.providerTypes.map((type) => {
|
||
|
return html`
|
||
|
<ak-wizard-page-form
|
||
|
slot=${`type-${type.component}`}
|
||
|
.sidebarLabel=${() => t`Create ${type.name}`}
|
||
|
>
|
||
|
<ak-proxy-form type=${type.component}></ak-proxy-form>
|
||
|
</ak-wizard-page-form>
|
||
|
`;
|
||
|
})}
|
||
|
<button slot="trigger" class="pf-c-button pf-m-primary">${this.createText}</button>
|
||
|
</ak-wizard>
|
||
|
`;
|
||
|
}
|
||
|
}
|