- ๐บ๐ธUnited States smustgrave
Tagging for framework input. If this is a path we want to go down.
- Status changed to Needs work
about 2 years ago 5:50pm 28 February 2023 - ๐บ๐ธUnited States smustgrave
This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request โ as a guide.
Think it will help for steps to reproduce this bug.
With a UI change before/after screenshots should be added to the issue summary.
- ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
The current theme condition is not shown on blocks because of:
https://git.drupalcode.org/project/drupal/-/blob/10.1.x/core/modules/blo...// @todo Allow list of conditions to be configured in // https://www.drupal.org/node/2284687. $visibility = $this->entity->getVisibility(); $definitions = $this->manager->getFilteredDefinitions('block_ui', $form_state->getTemporaryValue('gathered_contexts'), ['block' => $this->entity]); foreach ($definitions as $condition_id => $definition) { // Don't display the current theme condition. if ($condition_id == 'current_theme') { continue; }
Should we recover this condition?
- ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
We are changing the plugin because of https://www.drupal.org/project/google_tag/issues/3263122 โจ Recovery the current theme condition plugin Active , to be able to load the google tag on any theme, and recover this plugin on the module. Now is excluded because is not possible to select any theme.
- ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
Updated to apply to the last drupal version
- Merge request !4331Issue #2783897 by albeorte, andregp, Chi, Eduardo Morales Alberti, bucefal91:... โ (Open) created by eduardo morales alberti
- last update
almost 2 years ago 29,800 pass, 4 fail - ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
Added patch also and diff between last commit and the current one, allowing blocks to use the current theme condition.
- Status changed to Needs review
almost 2 years ago 1:22pm 6 July 2023 - last update
almost 2 years ago 29,800 pass, 4 fail - ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
Added steps to test and captures as asked by @smustgrave
- Status changed to Needs work
almost 2 years ago 2:02pm 6 July 2023 - ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
I will review the failed tests https://www.drupal.org/pift-ci-job/2710393 โ
- last update
almost 2 years ago 29,801 pass, 2 fail - last update
almost 2 years ago 29,801 pass, 2 fail - last update
almost 2 years ago 29,802 pass - Status changed to Needs review
almost 2 years ago 3:23pm 7 July 2023 - last update
almost 2 years ago 29,802 pass - ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
Fixed tests, ready to review
- ๐บ๐ธUnited States smustgrave
I think the test coverage is okay.
But found the workflow a little odd.
I did a Standard install
Went to block layout
Added a block under the Olivero tab but have it only appear on the claro theme.
Tagging for usability for thatNow if we had a global block layout tab then this setting would make sense I think.
Will leave in review for framework manager thoughts.
- ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
@smustgrave Do you think the options should be "current theme" or "any" in the case of block layout? instead of the list of all themes.
For the block layout, it have sense because it has theme tabs, for other cases, the list should have all themes - Status changed to Postponed: needs info
almost 2 years ago 6:57am 10 July 2023 - ๐ซ๐ฎFinland lauriii Finland
Could someone expand the issue summary to explain why is this setting needed? Drupal Block UI is built so that blocks are intended to be specific to a theme. If we want to change that, it would be helpful to understand why that's desired.
- ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
@lauriii You are totally right, I miss the original scope of the issue.
We use current theme condition on google_tag module, but we need the "- any -" option https://www.drupal.org/project/google_tag/issues/3263122 โจ Recovery the current theme condition plugin Active to have the ability to use google_tag on all themes or only on a theme, for blocks the current_theme condition does not have any sense at all, I will remove the logic that I changed related with blocks and update the summary.
- Status changed to Needs work
almost 2 years ago 7:58am 10 July 2023 - last update
almost 2 years ago 29,804 pass - ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
Add MR changes as patch
- last update
almost 2 years ago 29,804 pass - Status changed to Needs review
almost 2 years ago 10:27am 10 July 2023 - ๐ช๐ธSpain eduardo morales alberti Spain, ๐ช๐บ
Seems like the block is the only drupal core entity that uses the "plugin.manager.condition", and the current theme is excluded in this case as explained in previous comments so in the example I will use the google_tag scenario.
- ๐ณ๐ฑNetherlands yoroy
Why a select list here when all the other variations of this use checkboxes?
- Status changed to Needs work
almost 2 years ago 2:18am 18 July 2023 - ๐ฆ๐บAustralia larowlan ๐ฆ๐บ๐.au GMT+10
-
+++ b/core/modules/system/src/Plugin/Condition/CurrentThemeCondition.php @@ -111,11 +112,18 @@ public function evaluate() { + $summary = $this->isNegated() ? + $this->t('The current theme is not @theme.', ['@theme' => $theme]) : $this->t('The current theme is @theme.', ['@theme' => $theme]); + } + else { + $summary = $this->isNegated() ? + $this->t('The current theme is not one of the enabled themes.') : $this->t('The current theme is one of the enabled themes.'); } - return $this->t('The current theme is @theme', ['@theme' => $this->configuration['theme']]); + return $summary;
we can return early here and avoid using else
-
+++ b/core/tests/Drupal/KernelTests/Core/Plugin/Condition/CurrentThemeConditionTest.php @@ -27,12 +27,20 @@ public function testCurrentTheme() { + $this->assertEquals(new FormattableMarkup('The current theme is not one of the enabled themes.', ['@theme' => '']), $condition_any_negated->summary());
This feels like a UX WTF?
How can a current theme not be one of the enabled themes?
So as such I think we probably want to prevent the negate option when 'Any' is selected
Nice work folks
-
- ๐ฉ๐ชGermany Anybody Porta Westfalica
Just ran into this when working on โจ Create an admin route condition plugin or add generic "Current theme" options for admin and default theme Active and I think we should rate this as major issue, because currently once you saved the conditions, this condition is always added and evaluated and user has no way to disable this rule?!
- ๐ฉ๐ชGermany Anybody Porta Westfalica
One important addition: The form element should be checkboxes, not radio!
It makes no sense to force selecting only one theme!Selecting no theme at all should always evaluate to TRUE!
- First commit to issue fork.
- ๐ฉ๐ชGermany Grevil
grevil โ changed the visibility of the branch 2783897-drupal-current-theme to hidden.
- ๐ฉ๐ชGermany Grevil
Ok, I adjusted the code, so that we now use checkboxes instead of the select. As @anybody and @yoroy already mentioned, this makes much more sense UX wise.
The only problem is, that this change requires an update hook, as we can now select multiple themes instead of only one. But I can't seem to find a good way on how to update a condition configuration, as it usually just gets merged into the form it was used. @larowlan do you know of a good way on how to update all form configs using the condition? If not, we could alternatively leave the "theme" config in as a fallback (simply wrapping an array around it) and deprecate it. Although I am not super keen to do so...
Anyway, apart from the update hook this can go back to "Needs Review", note that I did a total rewrite, so this needs to get reviewed throughout again.
- ๐ฉ๐ชGermany Anybody Porta Westfalica
Thanks @grevil totally makes sense and code LGTM so far. Sadly, I have no clue, how an update hook for a condition plugin can be written. I'm also unaware of any existing examples, while I think they possibly exist.
Is there maybe any core maintainer or someone else experienced with that? We'd really like to finish this, for UX and bugfixing reasons, as currently it's kind of broken by design ;)
- ๐ฉ๐ชGermany rkoller Nรผrnberg, Germany
i saw the needs usability review tag, and we can put the issue on the shortlist for the meetings on friday. but only one question, i've tried to quickly test the MR on 11.x now, but i have a hard time to see any actual change in the ui. the proposed resolution section in the issue summary is not very clear, i then tried to follow the instructions in #32 ๐ Drupal Current theme condition plugin should provide an option to select all themes Needs review , but again i see nothing in the ui of a block configuration page on a block layout page enabling me to choose a theme (nothing theme related in the vertical tabs nor in the select for the region - and i ran an
drush updatedb
as well as adrush cr
). - ๐ฉ๐ชGermany Anybody Porta Westfalica
@rkoller thanks, yes that's because this condition plugin doesn't seem to be applied on blocks, if I remember correctly.
We ran into this in contrib modules that allow all condition plugins, e.g. https://www.drupal.org/project/posthog โ or https://www.drupal.org/project/context โ - unsure if there's also a place in core where it's shown.@Grevil can you please update the IS accordingly by time, if I'm right?