From 47ff0c92f031bb6f0e63bdb612c32c4a84b4ea5d Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Mon, 28 Nov 2022 14:22:41 +0000 Subject: [PATCH] Issue #2888872 by dagmar, brentg, yogeshmpawar, ravi.shankar, anacolautti, larowlan, alexpott: Hide type filter form in dblog view when there are no logs --- .../modules/dblog/src/Plugin/views/filter/DblogTypes.php | 9 +++++++++ core/modules/dblog/tests/src/Functional/DbLogTest.php | 2 ++ 2 files changed, 11 insertions(+) diff --git a/core/modules/dblog/src/Plugin/views/filter/DblogTypes.php b/core/modules/dblog/src/Plugin/views/filter/DblogTypes.php index 23ea736ea9ee..b6dd27f602ef 100644 --- a/core/modules/dblog/src/Plugin/views/filter/DblogTypes.php +++ b/core/modules/dblog/src/Plugin/views/filter/DblogTypes.php @@ -2,6 +2,7 @@ namespace Drupal\dblog\Plugin\views\filter; +use Drupal\Core\Form\FormStateInterface; use Drupal\views\Plugin\views\filter\InOperator; /** @@ -21,4 +22,12 @@ public function getValueOptions() { return $this->valueOptions; } + /** + * {@inheritDoc} + */ + protected function valueForm(&$form, FormStateInterface $form_state) { + parent::valueForm($form, $form_state); + $form['value']['#access'] = !empty($form['value']['#options']); + } + } diff --git a/core/modules/dblog/tests/src/Functional/DbLogTest.php b/core/modules/dblog/tests/src/Functional/DbLogTest.php index 9e6be6aed396..912ec2e71ced 100644 --- a/core/modules/dblog/tests/src/Functional/DbLogTest.php +++ b/core/modules/dblog/tests/src/Functional/DbLogTest.php @@ -724,12 +724,14 @@ public function testFilter() { $this->drupalGet('admin/reports/dblog', ['query' => ['order' => 'Type']]); $this->assertSession()->statusCodeEquals(200); $this->assertSession()->pageTextContains('Operations'); + $this->assertSession()->fieldExists('edit-type'); // Clear all logs and make sure the confirmation message is found. $this->clearLogsEntries(); // Confirm that the logs should be cleared. $this->submitForm([], 'Confirm'); $this->assertSession()->pageTextContains('Database log cleared.'); + $this->assertSession()->fieldNotExists('edit-type'); } /** -- GitLab