stages/prompt: add text_read_only field
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
ed6659a46d
commit
da74304221
|
@ -26,6 +26,10 @@ class FieldTypes(models.TextChoices):
|
|||
|
||||
# Simple text field
|
||||
TEXT = "text", _("Text: Simple Text input")
|
||||
# Simple text field
|
||||
TEXT_READ_ONLY = "text_read_only", _(
|
||||
"Text (read-only): Simple Text input, but cannot be edited."
|
||||
)
|
||||
# Same as text, but has autocomplete for password managers
|
||||
USERNAME = (
|
||||
"username",
|
||||
|
@ -80,8 +84,6 @@ class Prompt(SerializerModel):
|
|||
kwargs = {
|
||||
"required": self.required,
|
||||
}
|
||||
if default:
|
||||
kwargs["initial"] = default
|
||||
|
||||
if self.type == FieldTypes.EMAIL:
|
||||
field_class = EmailField
|
||||
|
@ -105,6 +107,8 @@ class Prompt(SerializerModel):
|
|||
if self.type == FieldTypes.SEPARATOR:
|
||||
kwargs["required"] = False
|
||||
kwargs["label"] = ""
|
||||
if default:
|
||||
kwargs["initial"] = default
|
||||
return field_class(**kwargs)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
|
|
@ -97,10 +97,10 @@ class PromptChallengeResponse(ChallengeResponse):
|
|||
# Check if we have any static or hidden fields, and ensure they
|
||||
# still have the same value
|
||||
static_hidden_fields: QuerySet[Prompt] = self.stage.fields.filter(
|
||||
type__in=[FieldTypes.HIDDEN, FieldTypes.STATIC]
|
||||
type__in=[FieldTypes.HIDDEN, FieldTypes.STATIC, FieldTypes.TEXT_READ_ONLY]
|
||||
)
|
||||
for static_hidden in static_hidden_fields:
|
||||
attrs[static_hidden.field_key] = static_hidden.placeholder
|
||||
attrs[static_hidden.field_key] = self.fields[static_hidden.field_key].initial
|
||||
|
||||
# Check if we have two password fields, and make sure they are the same
|
||||
password_fields: QuerySet[Prompt] = self.stage.fields.filter(type=FieldTypes.PASSWORD)
|
||||
|
|
|
@ -17634,6 +17634,7 @@ paths:
|
|||
- separator
|
||||
- static
|
||||
- text
|
||||
- text_read_only
|
||||
- username
|
||||
tags:
|
||||
- stages
|
||||
|
@ -28374,6 +28375,7 @@ components:
|
|||
PromptTypeEnum:
|
||||
enum:
|
||||
- text
|
||||
- text_read_only
|
||||
- username
|
||||
- email
|
||||
- password
|
||||
|
@ -30728,4 +30730,3 @@ components:
|
|||
servers:
|
||||
- url: /api/v3/
|
||||
- url: /api/v2beta/
|
||||
|
||||
|
|
|
@ -42,6 +42,13 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
|
|||
class="pf-c-form-control"
|
||||
?required=${prompt.required}
|
||||
value="">`;
|
||||
case PromptTypeEnum.TextReadOnly:
|
||||
return `<input
|
||||
type="text"
|
||||
name="${prompt.fieldKey}"
|
||||
class="pf-c-form-control"
|
||||
readonly
|
||||
value="${prompt.placeholder}">`;
|
||||
case PromptTypeEnum.Username:
|
||||
return `<input
|
||||
type="text"
|
||||
|
|
|
@ -4723,6 +4723,10 @@ msgstr "Test Policy"
|
|||
msgid "Test Property Mapping"
|
||||
msgstr "Test Property Mapping"
|
||||
|
||||
#: src/pages/stages/prompt/PromptForm.ts
|
||||
msgid "Text (read-only): Simple Text input, but cannot be edited."
|
||||
msgstr "Text (read-only): Simple Text input, but cannot be edited."
|
||||
|
||||
#: src/pages/stages/prompt/PromptForm.ts
|
||||
msgid "Text: Simple Text input"
|
||||
msgstr "Text: Simple Text input"
|
||||
|
|
|
@ -4675,6 +4675,10 @@ msgstr "Tester la politique"
|
|||
msgid "Test Property Mapping"
|
||||
msgstr "Tester le mapping de la propriété"
|
||||
|
||||
#: src/pages/stages/prompt/PromptForm.ts
|
||||
msgid "Text (read-only): Simple Text input, but cannot be edited."
|
||||
msgstr ""
|
||||
|
||||
#: src/pages/stages/prompt/PromptForm.ts
|
||||
msgid "Text: Simple Text input"
|
||||
msgstr "Texte : simple champ texte"
|
||||
|
|
|
@ -4715,6 +4715,10 @@ msgstr ""
|
|||
msgid "Test Property Mapping"
|
||||
msgstr ""
|
||||
|
||||
#: src/pages/stages/prompt/PromptForm.ts
|
||||
msgid "Text (read-only): Simple Text input, but cannot be edited."
|
||||
msgstr ""
|
||||
|
||||
#: src/pages/stages/prompt/PromptForm.ts
|
||||
msgid "Text: Simple Text input"
|
||||
msgstr ""
|
||||
|
|
|
@ -49,6 +49,12 @@ export class PromptForm extends ModelForm<Prompt, string> {
|
|||
>
|
||||
${t`Text: Simple Text input`}
|
||||
</option>
|
||||
<option
|
||||
value=${PromptTypeEnum.TextReadOnly}
|
||||
?selected=${this.instance?.type === PromptTypeEnum.TextReadOnly}
|
||||
>
|
||||
${t`Text (read-only): Simple Text input, but cannot be edited.`}
|
||||
</option>
|
||||
<option
|
||||
value=${PromptTypeEnum.Username}
|
||||
?selected=${this.instance?.type === PromptTypeEnum.Username}
|
||||
|
|
Reference in New Issue