stages/deny: migrate to web
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
c1c47c5f30
commit
1d72019645
|
@ -1,16 +0,0 @@
|
||||||
"""authentik flows deny forms"""
|
|
||||||
from django import forms
|
|
||||||
|
|
||||||
from authentik.stages.deny.models import DenyStage
|
|
||||||
|
|
||||||
|
|
||||||
class DenyStageForm(forms.ModelForm):
|
|
||||||
"""Form to create/edit DenyStage instances"""
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
|
|
||||||
model = DenyStage
|
|
||||||
fields = ["name"]
|
|
||||||
widgets = {
|
|
||||||
"name": forms.TextInput(),
|
|
||||||
}
|
|
|
@ -25,10 +25,8 @@ class DenyStage(Stage):
|
||||||
return DenyStageView
|
return DenyStageView
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def form(self) -> Type[ModelForm]:
|
def component(self) -> str:
|
||||||
from authentik.stages.deny.forms import DenyStageForm
|
return "ak-stage-deny-form"
|
||||||
|
|
||||||
return DenyStageForm
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
import { DenyStage, StagesApi } from "authentik-api";
|
||||||
|
import { gettext } from "django";
|
||||||
|
import { customElement, property } from "lit-element";
|
||||||
|
import { html, TemplateResult } from "lit-html";
|
||||||
|
import { DEFAULT_CONFIG } from "../../../api/Config";
|
||||||
|
import { Form } from "../../../elements/forms/Form";
|
||||||
|
import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
|
import "../../../elements/forms/HorizontalFormElement";
|
||||||
|
|
||||||
|
@customElement("ak-stage-deny-form")
|
||||||
|
export class DenyStageForm extends Form<DenyStage> {
|
||||||
|
|
||||||
|
set stageUUID(value: string) {
|
||||||
|
new StagesApi(DEFAULT_CONFIG).stagesDenyRead({
|
||||||
|
stageUuid: value,
|
||||||
|
}).then(stage => {
|
||||||
|
this.stage = stage;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@property({attribute: false})
|
||||||
|
stage?: DenyStage;
|
||||||
|
|
||||||
|
getSuccessMessage(): string {
|
||||||
|
if (this.stage) {
|
||||||
|
return gettext("Successfully updated stage.");
|
||||||
|
} else {
|
||||||
|
return gettext("Successfully created stage.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
send = (data: DenyStage): Promise<DenyStage> => {
|
||||||
|
if (this.stage) {
|
||||||
|
return new StagesApi(DEFAULT_CONFIG).stagesDenyUpdate({
|
||||||
|
stageUuid: this.stage.pk || "",
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return new StagesApi(DEFAULT_CONFIG).stagesDenyCreate({
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
renderForm(): TemplateResult {
|
||||||
|
return html`<form class="pf-c-form pf-m-horizontal">
|
||||||
|
<ak-form-element-horizontal
|
||||||
|
label=${gettext("Name")}
|
||||||
|
?required=${true}
|
||||||
|
name="name">
|
||||||
|
<input type="text" value="${ifDefined(this.stage?.name || "")}" class="pf-c-form-control" required>
|
||||||
|
</ak-form-element-horizontal>
|
||||||
|
</form>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ import { ifDefined } from "lit-html/directives/if-defined";
|
||||||
import "../../../elements/forms/HorizontalFormElement";
|
import "../../../elements/forms/HorizontalFormElement";
|
||||||
|
|
||||||
@customElement("ak-stage-user-delete-form")
|
@customElement("ak-stage-user-delete-form")
|
||||||
export class UserLogoutStageForm extends Form<UserDeleteStage> {
|
export class UserDeleteStageForm extends Form<UserDeleteStage> {
|
||||||
|
|
||||||
set stageUUID(value: string) {
|
set stageUUID(value: string) {
|
||||||
new StagesApi(DEFAULT_CONFIG).stagesUserDeleteRead({
|
new StagesApi(DEFAULT_CONFIG).stagesUserDeleteRead({
|
||||||
|
|
Reference in New Issue