From 8a4928c160a334b4ac498bf2058008504b42727e Mon Sep 17 00:00:00 2001 From: Cristina Chumillas <ckrina@1206650.no-reply.drupal.org> Date: Fri, 12 Nov 2021 16:13:42 +0100 Subject: [PATCH] Issue #3223233 by joachim, danflanagan8, longwave: Form to edit or add a single image effect doesn't tell you which style you're in --- core/modules/image/src/Form/ImageEffectAddForm.php | 5 ++++- core/modules/image/src/Form/ImageEffectEditForm.php | 5 ++++- .../image/tests/src/Functional/ImageAdminStylesTest.php | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core/modules/image/src/Form/ImageEffectAddForm.php b/core/modules/image/src/Form/ImageEffectAddForm.php index 76f164caf6ca..42411ef4cbe5 100644 --- a/core/modules/image/src/Form/ImageEffectAddForm.php +++ b/core/modules/image/src/Form/ImageEffectAddForm.php @@ -46,7 +46,10 @@ public static function create(ContainerInterface $container) { public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { $form = parent::buildForm($form, $form_state, $image_style, $image_effect); - $form['#title'] = $this->t('Add %label effect', ['%label' => $this->imageEffect->label()]); + $form['#title'] = $this->t('Add %label effect to style %style', [ + '%label' => $this->imageEffect->label(), + '%style' => $image_style->label(), + ]); $form['actions']['submit']['#value'] = $this->t('Add effect'); return $form; diff --git a/core/modules/image/src/Form/ImageEffectEditForm.php b/core/modules/image/src/Form/ImageEffectEditForm.php index 0dd362c70cdd..158e9a109b33 100644 --- a/core/modules/image/src/Form/ImageEffectEditForm.php +++ b/core/modules/image/src/Form/ImageEffectEditForm.php @@ -18,7 +18,10 @@ class ImageEffectEditForm extends ImageEffectFormBase { public function buildForm(array $form, FormStateInterface $form_state, ImageStyleInterface $image_style = NULL, $image_effect = NULL) { $form = parent::buildForm($form, $form_state, $image_style, $image_effect); - $form['#title'] = $this->t('Edit %label effect', ['%label' => $this->imageEffect->label()]); + $form['#title'] = $this->t('Edit %label effect on style %style', [ + '%label' => $this->imageEffect->label(), + '%style' => $image_style->label(), + ]); $form['actions']['submit']['#value'] = $this->t('Update effect'); return $form; diff --git a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php index 0f3fa8a910d0..e38cf39e5cf4 100644 --- a/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php +++ b/core/modules/image/tests/src/Functional/ImageAdminStylesTest.php @@ -140,6 +140,8 @@ public function testStyle() { $this->drupalGet($style_path); $this->submitForm(['new' => $effect], 'Add'); if (!empty($edit)) { + $effect_label = \Drupal::service('plugin.manager.image.effect')->createInstance($effect)->label(); + $this->assertSession()->pageTextContains("Add {$effect_label} effect to style {$style_label}"); $this->submitForm($edit_data, 'Add effect'); } } @@ -391,6 +393,7 @@ public function testEditEffect() { // There should normally be only one edit link on this page initially. $this->clickLink('Edit'); + $this->assertSession()->pageTextContains("Edit Scale and crop effect on style Test style effect edit"); $this->submitForm(['data[width]' => '360', 'data[height]' => '240'], 'Update effect'); $this->assertSession()->pageTextContains('Scale and crop 360×240'); @@ -405,6 +408,7 @@ public function testEditEffect() { // Edit the scale effect that was just added. $this->clickLink('Edit'); + $this->assertSession()->pageTextContains("Edit Scale effect on style Test style scale edit scale"); $this->submitForm(['data[width]' => '24', 'data[height]' => '19'], 'Update effect'); // Add another scale effect and make sure both exist. Click through from -- GitLab