From a1fb0b6932acb51d973bc2e6903f39a2b350151e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Grabowski?= <michal.grabowski@ibexa.co>
Date: Fri, 21 Apr 2023 13:41:54 +0200
Subject: [PATCH 1/2] IBX-5565: Add reusable delete confirmation modal

---
 .../translations/content_type.en.xliff        | 15 +++-----
 .../ui/modal/delete_confirmation.html.twig    | 35 +++++++++++++++++++
 2 files changed, 40 insertions(+), 10 deletions(-)
 create mode 100644 src/bundle/Resources/views/themes/admin/ui/modal/delete_confirmation.html.twig

diff --git a/src/bundle/Resources/translations/content_type.en.xliff b/src/bundle/Resources/translations/content_type.en.xliff
index 08f73f388c..3d88774b02 100644
--- a/src/bundle/Resources/translations/content_type.en.xliff
+++ b/src/bundle/Resources/translations/content_type.en.xliff
@@ -816,16 +816,6 @@
         <target state="new">Password must contain at least one non-alphanumeric character</target>
         <note>key: field_definition.ezuser.require_at_least_one_non_alphanumeric_character</note>
       </trans-unit>
-      <trans-unit id="283d87c7f3e760a02fde52274ed0a4a8523d2a0d" resname="field_definition.ezuser.require_not_compromised_password">
-        <source>Password must not be contained in a public breach.</source>
-        <target state="new">Password must not be contained in a public breach.</target>
-        <note>key: field_definition.ezuser.require_not_compromised_password</note>
-      </trans-unit>
-      <trans-unit id="99aa2f672dfd9206b58ddf5d78e6a695ceb9ebf1" resname="field_definition.ezuser.require_not_compromised_password_help">
-        <source>This uses the API at %link% to securely check breach data. The password is not transmitted to the API.</source>
-        <target state="new">This uses the API at %link% to securely check breach data. The password is not transmitted to the API.</target>
-        <note>key: field_definition.ezuser.require_not_compromised_password_help</note>
-      </trans-unit>
       <trans-unit id="26cb6ab7ae7e190a9d8d8b0411512b531c8c42ff" resname="field_definition.ezuser.require_at_least_one_numeric_character">
         <source>Password must contain at least one number</source>
         <target state="new">Password must contain at least one number</target>
@@ -841,6 +831,11 @@
         <target state="new">Prevent reusing old password</target>
         <note>key: field_definition.ezuser.require_new_password</note>
       </trans-unit>
+      <trans-unit id="fdcfd21005fcd975636d979b1be61e28bb88d875" resname="field_definition.ezuser.require_not_compromised_password">
+        <source>Password must not be contained in a public breach.</source>
+        <target state="new">Password must not be contained in a public breach.</target>
+        <note>key: field_definition.ezuser.require_not_compromised_password</note>
+      </trans-unit>
       <trans-unit id="100096c9b93ce532e7bf2f184d8e3f43374ae921" resname="field_definition.ezuser.require_unique_email">
         <source>Email must be unique</source>
         <target state="new">Email must be unique</target>
diff --git a/src/bundle/Resources/views/themes/admin/ui/modal/delete_confirmation.html.twig b/src/bundle/Resources/views/themes/admin/ui/modal/delete_confirmation.html.twig
new file mode 100644
index 0000000000..1bf953f74f
--- /dev/null
+++ b/src/bundle/Resources/views/themes/admin/ui/modal/delete_confirmation.html.twig
@@ -0,0 +1,35 @@
+{% set confirm_button_rendered %}
+    {%- block confirm_button -%}
+        <button
+            class="btn ibexa-btn ibexa-btn--primary ibexa-btn--trigger"
+            data-click="{{ data_click }}"
+        >
+            {{ 'modal.delete'|trans|desc('Delete') }}
+        </button>
+    {% endblock %}
+{% endset %}
+
+{% set cancel_button_rendered %}
+    {%- block cancel_button -%}
+        <button
+            type="button"
+            class="btn ibexa-btn ibexa-btn--secondary"
+            data-bs-dismiss="modal"
+        >
+            {{ 'modal.cancel'|trans|desc('Cancel') }}
+        </button>
+    {% endblock %}
+{% endset %}
+
+{% embed '@ibexadesign/ui/component/modal/modal.html.twig' with {
+    no_header: true,
+    id,
+} %}
+    {% block body_content %}
+        {{ message }}
+    {% endblock %}
+    {% block footer_content %}
+        {{ confirm_button_rendered }}
+        {{ cancel_button_rendered }}
+    {% endblock %}
+{% endembed %}

From ddaa268323e1d9d11c144d17fe94aae31b6f177c Mon Sep 17 00:00:00 2001
From: mikolaj <mikolaj.adamczyk@ez.no>
Date: Fri, 21 Apr 2023 16:27:18 +0200
Subject: [PATCH 2/2] IBX-5565: Fixed issue with translation extraction

---
 .../Resources/translations/content_type.en.xliff |  5 +++++
 .../FieldType/Mapper/UserAccountFormMapper.php   | 16 ++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/bundle/Resources/translations/content_type.en.xliff b/src/bundle/Resources/translations/content_type.en.xliff
index 3d88774b02..b1a6261e8f 100644
--- a/src/bundle/Resources/translations/content_type.en.xliff
+++ b/src/bundle/Resources/translations/content_type.en.xliff
@@ -836,6 +836,11 @@
         <target state="new">Password must not be contained in a public breach.</target>
         <note>key: field_definition.ezuser.require_not_compromised_password</note>
       </trans-unit>
+      <trans-unit id="73a71072b428bec8a32c4ca1cf4813314b2a783d" resname="field_definition.ezuser.require_not_compromised_password_help">
+        <source>This uses the API at %link% to securely check breach data. The password is not transmitted to the API.</source>
+        <target state="new">This uses the API at %link% to securely check breach data. The password is not transmitted to the API.</target>
+        <note>key: field_definition.ezuser.require_not_compromised_password_help</note>
+      </trans-unit>
       <trans-unit id="100096c9b93ce532e7bf2f184d8e3f43374ae921" resname="field_definition.ezuser.require_unique_email">
         <source>Email must be unique</source>
         <target state="new">Email must be unique</target>
diff --git a/src/lib/FieldType/Mapper/UserAccountFormMapper.php b/src/lib/FieldType/Mapper/UserAccountFormMapper.php
index 88054c6d0a..3abbe31cd1 100644
--- a/src/lib/FieldType/Mapper/UserAccountFormMapper.php
+++ b/src/lib/FieldType/Mapper/UserAccountFormMapper.php
@@ -9,6 +9,8 @@
 use Ibexa\AdminUi\FieldType\FieldDefinitionFormMapperInterface;
 use Ibexa\AdminUi\Form\Data\FieldDefinitionData;
 use Ibexa\ContentForms\Form\Type\FieldDefinition\User\PasswordConstraintCheckboxType;
+use JMS\TranslationBundle\Model\Message;
+use JMS\TranslationBundle\Translation\TranslationContainerInterface;
 use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
 use Symfony\Component\Form\Extension\Core\Type\IntegerType;
 use Symfony\Component\Form\Extension\Core\Type\TextType;
@@ -19,7 +21,7 @@
 /**
  * Maps a user FieldType.
  */
-final class UserAccountFormMapper implements FieldDefinitionFormMapperInterface
+final class UserAccountFormMapper implements FieldDefinitionFormMapperInterface, TranslationContainerInterface
 {
     /**
      * {@inheritdoc}
@@ -52,9 +54,7 @@ public function mapFieldDefinitionForm(FormInterface $fieldDefinitionForm, Field
             'property_path' => $validatorPropertyPathPrefix . '[requireNotCompromisedPassword]',
             'label' => /** @Desc("Password must not be contained in a public breach.") */
                 'field_definition.ezuser.require_not_compromised_password',
-            'help' => /** @Desc("This uses the API at %link% to securely check breach data.
-                * The password is not transmitted to the API.") */
-                'field_definition.ezuser.require_not_compromised_password_help',
+            'help' => 'field_definition.ezuser.require_not_compromised_password_help',
             'help_translation_parameters' => [
                 '%link%' => '<a href="https://haveibeenpwned.com/" target="_blank">https://haveibeenpwned.com/</a>',
             ],
@@ -119,6 +119,14 @@ public function configureOptions(OptionsResolver $resolver)
                 'translation_domain' => 'content_type',
             ]);
     }
+
+    public static function getTranslationMessages(): array
+    {
+        return [
+            Message::create('field_definition.ezuser.require_not_compromised_password_help', 'content_type')
+                ->setDesc('This uses the API at %link% to securely check breach data. The password is not transmitted to the API.'),
+        ];
+    }
 }
 
 class_alias(UserAccountFormMapper::class, 'EzSystems\EzPlatformAdminUi\FieldType\Mapper\UserAccountFormMapper');