From fb409a73a190e457d9fb08101c72c810c0eb3ebc Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 6 Apr 2021 17:27:53 +0200 Subject: [PATCH] web/elements: Fix display in deleteform when object has no name Signed-off-by: Jens Langhammer --- authentik/policies/api/bindings.py | 8 +++++--- web/src/elements/forms/DeleteForm.ts | 8 +++++++- web/src/locales/en.po | 12 ++++++------ web/src/locales/pseudo-LOCALE.po | 10 +++++----- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/authentik/policies/api/bindings.py b/authentik/policies/api/bindings.py index 8a69ca9f5..00e29ba77 100644 --- a/authentik/policies/api/bindings.py +++ b/authentik/policies/api/bindings.py @@ -101,9 +101,11 @@ class PolicyBindingSerializer(ModelSerializer): class PolicyBindingViewSet(ModelViewSet): """PolicyBinding Viewset""" - queryset = PolicyBinding.objects.all().select_related( - "target", "group", "user" - ).prefetch_related("policy") # prefetching policy so we resolve the subclass + queryset = ( + PolicyBinding.objects.all() + .select_related("target", "group", "user") + .prefetch_related("policy") + ) # prefetching policy so we resolve the subclass serializer_class = PolicyBindingSerializer filterset_fields = ["policy", "target", "enabled", "order", "timeout"] search_fields = ["policy__name"] diff --git a/web/src/elements/forms/DeleteForm.ts b/web/src/elements/forms/DeleteForm.ts index e0d8741d9..27c436c14 100644 --- a/web/src/elements/forms/DeleteForm.ts +++ b/web/src/elements/forms/DeleteForm.ts @@ -49,6 +49,12 @@ export class DeleteForm extends ModalButton { } renderModalInner(): TemplateResult { + let objName = this.obj?.name; + if (objName) { + objName = ` "${objName}"`; + } else { + objName = ""; + } return html`

@@ -59,7 +65,7 @@ export class DeleteForm extends ModalButton {

- ${t`Are you sure you want to delete ${this.objectLabel} "${this.obj?.name}"?`} + ${t`Are you sure you want to delete ${this.objectLabel} ${objName} ?`}

diff --git a/web/src/locales/en.po b/web/src/locales/en.po index facc8cb86..881f8e7dd 100644 --- a/web/src/locales/en.po +++ b/web/src/locales/en.po @@ -188,9 +188,9 @@ msgstr "" "Are you sure you want to clear the policy cache?\n" "This will cause all policies to be re-evaluated on their next usage." -#: src/elements/forms/DeleteForm.ts:62 -msgid "Are you sure you want to delete {0} \"{1}\"?" -msgstr "Are you sure you want to delete {0} \"{1}\"?" +#: src/elements/forms/DeleteForm.ts:69 +msgid "Are you sure you want to delete {0} {objName} ?" +msgstr "Are you sure you want to delete {0} {objName} ?" #: src/pages/users/UserActiveForm.ts:52 msgid "Are you sure you want to update {0} \"{1}\"?" @@ -385,7 +385,7 @@ msgid "Can be in the format of 'unix://' when connecting to a local docker daemo msgstr "Can be in the format of 'unix://' when connecting to a local docker daemon, or 'https://:2376' when connecting to a remote system." #: src/elements/forms/ConfirmationForm.ts:75 -#: src/elements/forms/DeleteForm.ts:79 +#: src/elements/forms/DeleteForm.ts:86 #: src/elements/forms/ModalForm.ts:71 #: src/pages/users/UserActiveForm.ts:73 msgid "Cancel" @@ -813,7 +813,7 @@ msgstr "Decides what this Flow is used for. For example, the Authentication flow msgid "Define how notifications are sent to users, like Email or Webhook." msgstr "Define how notifications are sent to users, like Email or Webhook." -#: src/elements/forms/DeleteForm.ts:72 +#: src/elements/forms/DeleteForm.ts:79 #: src/pages/applications/ApplicationListPage.ts:102 #: src/pages/crypto/CertificateKeyPairListPage.ts:86 #: src/pages/events/RuleListPage.ts:82 @@ -861,7 +861,7 @@ msgstr "Delete account" msgid "Delete temporary users after" msgstr "Delete temporary users after" -#: src/elements/forms/DeleteForm.ts:55 +#: src/elements/forms/DeleteForm.ts:62 msgid "Delete {0}" msgstr "Delete {0}" diff --git a/web/src/locales/pseudo-LOCALE.po b/web/src/locales/pseudo-LOCALE.po index 5d71d3db8..79cde2689 100644 --- a/web/src/locales/pseudo-LOCALE.po +++ b/web/src/locales/pseudo-LOCALE.po @@ -184,8 +184,8 @@ msgid "" "This will cause all policies to be re-evaluated on their next usage." msgstr "" -#: src/elements/forms/DeleteForm.ts:62 -msgid "Are you sure you want to delete {0} \"{1}\"?" +#: src/elements/forms/DeleteForm.ts:69 +msgid "Are you sure you want to delete {0} {objName} ?" msgstr "" #: src/pages/users/UserActiveForm.ts:52 @@ -381,7 +381,7 @@ msgid "Can be in the format of 'unix://' when connecting to a local docker daemo msgstr "" #: src/elements/forms/ConfirmationForm.ts:75 -#: src/elements/forms/DeleteForm.ts:79 +#: src/elements/forms/DeleteForm.ts:86 #: src/elements/forms/ModalForm.ts:71 #: src/pages/users/UserActiveForm.ts:73 msgid "Cancel" @@ -809,7 +809,7 @@ msgstr "" msgid "Define how notifications are sent to users, like Email or Webhook." msgstr "" -#: src/elements/forms/DeleteForm.ts:72 +#: src/elements/forms/DeleteForm.ts:79 #: src/pages/applications/ApplicationListPage.ts:102 #: src/pages/crypto/CertificateKeyPairListPage.ts:86 #: src/pages/events/RuleListPage.ts:82 @@ -857,7 +857,7 @@ msgstr "" msgid "Delete temporary users after" msgstr "" -#: src/elements/forms/DeleteForm.ts:55 +#: src/elements/forms/DeleteForm.ts:62 msgid "Delete {0}" msgstr ""