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", "placeholder",
"order", "order",
"promptstage_set", "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) type = models.CharField(max_length=100, choices=FieldTypes.choices)
required = models.BooleanField(default=True) required = models.BooleanField(default=True)
placeholder = models.TextField(blank=True) placeholder = models.TextField(blank=True)
sub_text = models.TextField(blank=True, default="")
order = models.IntegerField(default=0) order = models.IntegerField(default=0)

View File

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

View File

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

View File

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

View File

@ -127,6 +127,7 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
${prompt.required ${prompt.required
? html`<p class="pf-c-form__helper-text">${t`Required.`}</p>` ? html`<p class="pf-c-form__helper-text">${t`Required.`}</p>`
: html``} : html``}
<p class="pf-c-form__helper-text">${unsafeHTML(prompt.subText)}</p>
</div>`; </div>`;
} }
// Special types that aren't rendered in a wrapper // 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]} .errors=${(this.challenge?.responseErrors || {})[prompt.fieldKey]}
> >
${unsafeHTML(this.renderPromptInner(prompt))} ${unsafeHTML(this.renderPromptInner(prompt))}
<p class="pf-c-form__helper-text">${unsafeHTML(prompt.subText)}</p>
</ak-form-element>`; </ak-form-element>`;
})} })}
${"non_field_errors" in (this.challenge?.responseErrors || {}) ${"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" msgid "Always require consent"
msgstr "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/events/EventInfo.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts #: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
msgid "App" msgid "App"
@ -2054,6 +2058,10 @@ msgstr "Healthy outposts"
msgid "Healthy sources" msgid "Healthy sources"
msgstr "Healthy sources" msgstr "Healthy sources"
#: src/pages/stages/prompt/PromptForm.ts
msgid "Help text"
msgstr "Help text"
#: src/pages/stages/prompt/PromptForm.ts #: src/pages/stages/prompt/PromptForm.ts
msgid "Hidden: Hidden field, can be used to insert data into form." msgid "Hidden: Hidden field, can be used to insert data into form."
msgstr "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." 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." 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 #: src/pages/tenants/TenantForm.ts
msgid "When using an external logging solution for archiving, this can be set to \"minutes=5\"." 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\"." 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" msgid "Always require consent"
msgstr "Toujours exiger l'approbation" 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/events/EventInfo.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts #: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
msgid "App" msgid "App"
@ -2037,6 +2041,10 @@ msgstr "Avant-postes sains"
msgid "Healthy sources" msgid "Healthy sources"
msgstr "Sources saines" msgstr "Sources saines"
#: src/pages/stages/prompt/PromptForm.ts
msgid "Help text"
msgstr ""
#: src/pages/stages/prompt/PromptForm.ts #: src/pages/stages/prompt/PromptForm.ts
msgid "Hidden: Hidden field, can be used to insert data into form." 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." 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." 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." 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 #: src/pages/tenants/TenantForm.ts
msgid "When using an external logging solution for archiving, this can be set to \"minutes=5\"." 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\"." 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" msgid "Always require consent"
msgstr "" msgstr ""
#: src/pages/stages/prompt/PromptForm.ts
msgid "Any HTML can be used."
msgstr ""
#: src/pages/events/EventInfo.ts #: src/pages/events/EventInfo.ts
#: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts #: src/pages/policies/event_matcher/EventMatcherPolicyForm.ts
msgid "App" msgid "App"
@ -2046,6 +2050,10 @@ msgstr ""
msgid "Healthy sources" msgid "Healthy sources"
msgstr "" msgstr ""
#: src/pages/stages/prompt/PromptForm.ts
msgid "Help text"
msgstr ""
#: src/pages/stages/prompt/PromptForm.ts #: src/pages/stages/prompt/PromptForm.ts
msgid "Hidden: Hidden field, can be used to insert data into form." msgid "Hidden: Hidden field, can be used to insert data into form."
msgstr "" 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." msgid "When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged."
msgstr "" 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 #: src/pages/tenants/TenantForm.ts
msgid "When using an external logging solution for archiving, this can be set to \"minutes=5\"." msgid "When using an external logging solution for archiving, this can be set to \"minutes=5\"."
msgstr "" msgstr ""

View File

@ -123,6 +123,9 @@ export class PromptForm extends ModelForm<Prompt, string> {
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${t`Name of the form field, also used to store the value.`} ${t`Name of the form field, also used to store the value.`}
</p> </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>
<ak-form-element-horizontal label=${t`Label`} ?required=${true} name="label"> <ak-form-element-horizontal label=${t`Label`} ?required=${true} name="label">
<input <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> <p class="pf-c-form__helper-text">${t`Optionally pre-fill the input value`}</p>
</ak-form-element-horizontal> </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"> <ak-form-element-horizontal label=${t`Order`} ?required=${true} name="order">
<input <input
type="number" type="number"