stages/prompt: add sub_text field to add HTML below prompt fields

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-10-07 18:34:37 +02:00
parent 050ec99c89
commit 57e5acaf2f
11 changed files with 77 additions and 0 deletions

View file

@ -48,6 +48,7 @@ class PromptSerializer(ModelSerializer):
"placeholder",
"order",
"promptstage_set",
"sub_text",
]

View file

@ -0,0 +1,18 @@
# Generated by Django 3.2.8 on 2021-10-07 16:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("authentik_stages_prompt", "0003_auto_20210222_1821"),
]
operations = [
migrations.AddField(
model_name="prompt",
name="sub_text",
field=models.TextField(blank=True, default=""),
),
]

View file

@ -64,6 +64,7 @@ class Prompt(SerializerModel):
type = models.CharField(max_length=100, choices=FieldTypes.choices)
required = models.BooleanField(default=True)
placeholder = models.TextField(blank=True)
sub_text = models.TextField(blank=True, default="")
order = models.IntegerField(default=0)

View file

@ -35,6 +35,7 @@ class StagePromptSerializer(PassiveSerializer):
required = BooleanField()
placeholder = CharField(allow_blank=True)
order = IntegerField()
sub_text = CharField()
class PromptChallenge(Challenge):

View file

@ -26254,6 +26254,8 @@ components:
type: array
items:
$ref: '#/components/schemas/StageRequest'
sub_text:
type: string
PatchedPromptStageRequest:
type: object
description: PromptStage Serializer
@ -27133,6 +27135,8 @@ components:
type: array
items:
$ref: '#/components/schemas/Stage'
sub_text:
type: string
required:
- field_key
- label
@ -27197,6 +27201,8 @@ components:
type: array
items:
$ref: '#/components/schemas/StageRequest'
sub_text:
type: string
required:
- field_key
- label
@ -28509,12 +28515,15 @@ components:
type: string
order:
type: integer
sub_text:
type: string
required:
- field_key
- label
- order
- placeholder
- required
- sub_text
- type
StageRequest:
type: object

View file

@ -4,6 +4,7 @@ import "codemirror/addon/display/autorefresh";
import "codemirror/addon/hint/show-hint";
import "codemirror/addon/search/search";
import "codemirror/addon/search/searchcursor";
import "codemirror/mode/htmlmixed/htmlmixed.js";
import "codemirror/mode/javascript/javascript.js";
import "codemirror/mode/python/python.js";
import "codemirror/mode/xml/xml.js";

View file

@ -127,6 +127,7 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
${prompt.required
? html`<p class="pf-c-form__helper-text">${t`Required.`}</p>`
: html``}
<p class="pf-c-form__helper-text">${unsafeHTML(prompt.subText)}</p>
</div>`;
}
// Special types that aren't rendered in a wrapper
@ -144,6 +145,7 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
.errors=${(this.challenge?.responseErrors || {})[prompt.fieldKey]}
>
${unsafeHTML(this.renderPromptInner(prompt))}
<p class="pf-c-form__helper-text">${unsafeHTML(prompt.subText)}</p>
</ak-form-element>`;
})}
${"non_field_errors" in (this.challenge?.responseErrors || {})

View file

@ -278,6 +278,10 @@ msgstr "Alternatively, if your current device has Duo installed, click on this l
msgid "Always require consent"
msgstr "Always require consent"
#: src/pages/stages/prompt/PromptForm.ts
msgid "Any HTML can be used."
msgstr "Any HTML can be used."
#: src/pages/events/EventInfo.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
msgid "App"
@ -2054,6 +2058,10 @@ msgstr "Healthy outposts"
msgid "Healthy sources"
msgstr "Healthy sources"
#: src/pages/stages/prompt/PromptForm.ts
msgid "Help text"
msgstr "Help text"
#: src/pages/stages/prompt/PromptForm.ts
msgid "Hidden: Hidden field, can be used to insert data into form."
msgstr "Hidden: Hidden field, can be used to insert data into form."
@ -5346,6 +5354,10 @@ msgstr "When selected, incoming assertion's Signatures will be validated against
msgid "When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged."
msgstr "When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged."
#: src/pages/stages/prompt/PromptForm.ts
msgid "When used in conjunction with a User Write stage, use attributes.foo to write attributes."
msgstr "When used in conjunction with a User Write stage, use attributes.foo to write attributes."
#: src/pages/tenants/TenantForm.ts
msgid "When using an external logging solution for archiving, this can be set to \"minutes=5\"."
msgstr "When using an external logging solution for archiving, this can be set to \"minutes=5\"."

View file

@ -282,6 +282,10 @@ msgstr "Sinon, si Duo est installé sur cet appareil, cliquez sur ce lien :"
msgid "Always require consent"
msgstr "Toujours exiger l'approbation"
#: src/pages/stages/prompt/PromptForm.ts
msgid "Any HTML can be used."
msgstr ""
#: src/pages/events/EventInfo.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
msgid "App"
@ -2037,6 +2041,10 @@ msgstr "Avant-postes sains"
msgid "Healthy sources"
msgstr "Sources saines"
#: src/pages/stages/prompt/PromptForm.ts
msgid "Help text"
msgstr ""
#: src/pages/stages/prompt/PromptForm.ts
msgid "Hidden: Hidden field, can be used to insert data into form."
msgstr "Caché : champ caché, peut être utilisé pour insérer des données dans le formulaire."
@ -5285,6 +5293,10 @@ msgstr "Si activée, les signatures des assertions entrantes seront validées pa
msgid "When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged."
msgstr "Si activée, toutes les exécutions de cette politique seront enregistrées. Par défaut, seules les erreurs d'exécution sont consignées."
#: src/pages/stages/prompt/PromptForm.ts
msgid "When used in conjunction with a User Write stage, use attributes.foo to write attributes."
msgstr ""
#: src/pages/tenants/TenantForm.ts
msgid "When using an external logging solution for archiving, this can be set to \"minutes=5\"."
msgstr "En cas d'utilisation d'une solution de journalisation externe pour l'archivage, cette valeur peut être fixée à \"minutes=5\"."

View file

@ -278,6 +278,10 @@ msgstr ""
msgid "Always require consent"
msgstr ""
#: src/pages/stages/prompt/PromptForm.ts
msgid "Any HTML can be used."
msgstr ""
#: src/pages/events/EventInfo.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
msgid "App"
@ -2046,6 +2050,10 @@ msgstr ""
msgid "Healthy sources"
msgstr ""
#: src/pages/stages/prompt/PromptForm.ts
msgid "Help text"
msgstr ""
#: src/pages/stages/prompt/PromptForm.ts
msgid "Hidden: Hidden field, can be used to insert data into form."
msgstr ""
@ -5331,6 +5339,10 @@ msgstr ""
msgid "When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged."
msgstr ""
#: src/pages/stages/prompt/PromptForm.ts
msgid "When used in conjunction with a User Write stage, use attributes.foo to write attributes."
msgstr ""
#: src/pages/tenants/TenantForm.ts
msgid "When using an external logging solution for archiving, this can be set to \"minutes=5\"."
msgstr ""

View file

@ -123,6 +123,9 @@ export class PromptForm extends ModelForm<Prompt, string> {
<p class="pf-c-form__helper-text">
${t`Name of the form field, also used to store the value.`}
</p>
<p class="pf-c-form__helper-text">
${t`When used in conjunction with a User Write stage, use attributes.foo to write attributes.`}
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Label`} ?required=${true} name="label">
<input
@ -157,6 +160,11 @@ export class PromptForm extends ModelForm<Prompt, string> {
/>
<p class="pf-c-form__helper-text">${t`Optionally pre-fill the input value`}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Help text`} name="subText">
<ak-codemirror mode="htmlmixed" value="${ifDefined(this.instance?.subText)}">
</ak-codemirror>
<p class="pf-c-form__helper-text">${t`Any HTML can be used.`}</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Order`} ?required=${true} name="order">
<input
type="number"