Problem/Motivation
If we want to do #3079738: Add Claro administration theme to core, then we need to figure out how to actually add a theme to core as experimental. (This will be the first time we've tried!)
Both profiles and modules have a status indicator that they are experimental (profiles in the name; modules in the grouping):
Experimental profiles don't seem to get any special treatment when selecting them; however, when you select an experimental module it warns you for good measure:
And are included in the status report overview page, so we'll need a similar entry there for themes (and/or consolidate it all into "experimental stuff"):
Proposed resolution
- Allow themes to be marked "experimental".
- Ensure experimental themes get a
(experimental theme)
suffix in the UI at/admin/appearance
, just like/admin/appearance
already does for(default theme)
and(experimental theme)
. - Ensure that whenever an experimental theme is installed, a confirmation dialog is presented.
- Also ensure that whenever a non-experimental theme is installed that depends on an experimental theme, a confirmation dialog is presented.
- List installed experimental themes in the status report.
Alternately, something suggested by @effulgentsia is we could potentially fix #474684: Allow themes to declare dependencies on modules and leverage a required module to do the experimental warning.
Remaining tasks
None.
User interface changes
Yes; we'll need to clearly outlay a theme as being experimental.
API changes
None. Only an API addition: themes can now specify
experimental: true
in their *.info.yml
file.
Data model changes
None.
Release notes snippet
None.
Comment | File | Size | Author |
---|---|---|---|
#43 | interdiff_41-43.txt | 1.23 KB | zrpnr |
#43 | 3084069-43.patch | 24.61 KB | zrpnr |
#41 | interdiff_34-41.txt | 3.55 KB | zrpnr |
#41 | 3084069-41.patch | 24.07 KB | zrpnr |
#38 | Screen Shot 2019-10-10 at 00.09.13.png | 34.63 KB | lauriii |
Comments
Comment #2
webchickHere's a possible "mockup" of how this could work, as a starting point for discussion.
1) New grouping on the themes page for Experimental themes (placed below "Uninstalled" themes for de-emphasis):
2) Upon selecting "Install" or "Install and set default" you get a warning similar to modules:
3) Entry in the admin status report for themes:
Comment #3
kamalzairigHi @webchick,
Here is a quick patch I've made to implement the proposed solution. Instead of grouping experimental themes in a new group, I propose to simply add the note "experimental theme" in front of the theme name.
An experimental theme must have the property experimental set to true in the .info.yml file :
Here are some screenshots of the result :
Theme display
Confirmation form
Theme display in admin themes combobox
Warning display for experimental themes in status report page
Comment #4
kamalzairigHere is a new patch that tries to fix failed tests.
Comment #5
Wim LeersGreat work here, @kamalzairig! I have a lot of remarks, but most of it is small stuff, so it'll be easy to address 😊
🤔 This code is different from that for modules because
SystemController::themesPage()
was never truly modernized like the modules page was, whose code now lives at\Drupal\system\Form\ModulesListForm()
.🤓 Übernit: There can only be one default theme, and only one administration theme. There can be many experimental themes. The language of the comment kinda doesn't work.
🤓🐫 Nit: s/$allThemes/$all_themes/
🤓 Missing space:
if(
→if (
🤓 Let's use
FQCN::class
instead of hardcoding a string?👎 Missing
s?
at the end — then the English will be unbroken and it will match\Drupal\system\Form\ModulesListExperimentalConfirmForm::getQuestion
exactly.👎 AFAIK we're not yet using PHP 7-only syntax in Drupal 8.8, to simplify backports to Drupal 8.7.
🐫
🤓 80 cols violation.
🤓 Indentation issues.
👍 The changes here make perfect sense. Take what exists for modules, repeat the exact same code pattern for themes.
Comment #6
tinko CreditAttribution: tinko as a volunteer commentedHello, I've fixed some of the points.
3. Fixed
4. Fixed
6. Fixed - I have added the 's?' at the end, but It's not exactly the same with the documentation). Is it okay to stay like this?
9. Fixed
10. Fixed
Comment #7
ckrinaI think adding a text/label is a very good solution that gives us room to come up with a design for Claro integrating it into the cards component and doesn't take too much space. The rest of the behaviors follow the current patterns, so +1 for this.
Comment #8
lauriiiComment #9
lauriiiComment #10
lauriiiComment #11
kamalzairigHello,
Thanks @wim-leers for the remarks and @tinko for the fixes.
Here is a complete patch fixing all the remarks listed by Wim Leers.
For point 6, I added the question mark without the plural "s". Because unlike modules, themes can be installed only one at a time. What do you think?
Comment #12
Wim LeersThanks!
Nit: 80 cols violation.
+1 to going with singular like you wrote in #11, but then we need to say "a":
[…] install an experimental theme?
Nit: the indentation of this is still wrong.
Comment #13
kamalzairigThanks for the quick reply!
Here is a new patch addressing those issues :)
Comment #14
Wim LeersActually,
$theme_installer
was correct. We need to rename$themeHandler
to$theme_handler
too. I missed that in my earlier reviews! 😅Should be
$set_default
.That is no longer true as of #2587119: Form sets system.theme:admin to '0' breaking Quick Edit and making no sense :)
Can we use a strict comparison here?
The last reroll broke the indentation on this.
Comment #15
kamalzairigHi Wim. Here is a new patch fixing those issues.
Comment #16
Wim LeersNo more remarks about the code :) Only structural remarks.
This requires a line like
to be added to a theme. That's different from how it works for experimental modules, where you have to do
Why that difference?
Comment #17
Wim LeersComment #18
Wim LeersTest coverage and test theme added, based on
\Drupal\Tests\system\Functional\Module\ExperimentalModuleTest
, which was added by #2663796: Use a confirmation form when enabling experimental modules. To prove and demonstrate I tried to stay as close as possible to the pattern established in that issue, I includedsimilarity-comparison.txt
(which was created usinggit diff -C -C -M20%
).This should still fail because this is only adding test coverage, and the logic in #15's patch doesn't yet handle the case of a non-experimental subtheme that uses an experimental base theme.
Comment #19
Wim Leers#18 should fail like this:
Which points to a bug in the patch in #15. Fixing that first.
Comment #20
Wim LeersAnd finally, this fixes the problem that #18 already alluded to:
Comment #21
Wim LeersSo, to address my own review in #16:
package: Core (Experimental)
was not really conscious: it was pragmatic. We never got around to improving it.Comment #25
Wim LeersFixing coding standards violations.
The test failure is sadly rather unhelpful — will dig in!
Comment #26
Wim Leers😳🤦♂️
Comment #28
kamalzairigHi Wim,
Thank you for implementing the tests.
+1 for using experimental key (#21, 1st point). I think that that it will be useful to mark contrib themes as experimental.
Comment #29
effulgentsia CreditAttribution: effulgentsia at Acquia commentedAre all these rebuilds necessary? The ones in the confirmation form seem unnecessary but relatively harmless if they only run when you're trying to install an experimental theme. However, the one in install(), and worse, the one in setDefaultTheme(), looks like they would run even when you're installing / setting-to-default a non-experimental theme.
Comment #30
effulgentsia CreditAttribution: effulgentsia at Acquia commentedThis is nice test coverage. But it looks to be missing coverage for setting an already installed theme to the default. In particular, when doing that, what is the expected behavior for a theme that isn't experimental itself but depends on an experimental theme?
Also, looks like there's no test coverage for setting an experimental theme as the admin theme (e.g., verifying that its label has the "(experimental)" suffix) or verifying that "experimental theme" appears as a note in the Appearance page.
Comment #31
effulgentsia CreditAttribution: effulgentsia at Acquia commentedThis also needs test coverage.
Comment #32
effulgentsia CreditAttribution: effulgentsia at Acquia commentedLet's also open a followup to create documentation that we can link "Experimental themes" to, to match how "Experimental modules" is a link to documentation.
Comment #33
Wim Leers#29: great question. I should've dug deeper into that in my own review prior to starting the work on this. I don't think this matters a great deal though because installing extensions is a rare operation. Nevertheless: fixed.
(I think @kamalzairig simply chose to use the service that was available to him already 🙂)
Comment #34
Wim Leers#30:
It better be, because it's identical to the test coverage in
\Drupal\Tests\system\Functional\Module\ExperimentalModuleTest
, like I described in #18!Good catch! 👍 Added this test coverage.
The patch already contains test coverage for when installing a non-experimental theme that depends on an experimental theme. It does not yet contain test coverage for installing and setting as the default at the same time in that scenario. And in fact, there's a bug in there, which causes that missing test to fail — I'm sure that's why you asked specifically about that 🧐👍😊
I didn't add that because
\Drupal\Tests\system\Functional\Module\ExperimentalModuleTest
doesn't test that either. Of course, the module listing page is different than the theme listing page. Plus, experimental modules are all in that one package, and hence are implicitly labeled already, unlike themes. So: 👍, added that test coverage too.Comment #35
Wim LeersComment #37
Wim LeersUpdated issue summary.
Comment #38
lauriiiI made Claro an experimental theme and here's what I could find:
👍Claro is now listed as an experimental theme in the theme list.
👎I started installing the theme and I could see that the text doesn't read well if the experimental theme depends on multiple base themes.
👍 When I have an admin theme set to something else than the default option and I try to install and set the theme as the default theme, I got this helpful message.
👍 After enabling the theme, I can see a warning in the status report that I have an experimental theme enabled on my site.
I'm setting this back to needs work to address point 2.
Comment #39
tedbowExciting feature! Glad we are going to support experimental themes
This seems overly complicated and hard to read for me. It doesn't seem we actually need to make
$is_experimental
a function.Why not just first make an array of
$themes_to_enable
which would be$all_themes[$theme]->requires
and$theme
.Then loop through
$themes_to_enable
and check the condition we set up in$is_experimental
now. First one that matches returns true. If no matches after the loop return false.I guess this personal preference but with creating the function variable, the array_map, array_sum and the
||
which means are calling$is_experimental
in 2 different spots it just seem overly complicated.Also if
$theme
is put as the first item in the array this way would technically be more efficient because now if$theme
is not experimental then$is_experimental
is called on all elements in$depencies
whereas the way I am suggesting it only needs to test items till it finds the first experimental. I know$all_themes[$theme]->requires
is likely to have 1 or 2 elements at most but still.Use
===
for checking status\Drupal\Core\Extension\ThemeExtensionList::doList()
explicitly sets as an int.We need to update the @return for this function. It now can return as well as the existing
RedirectResponse
I noticed these are places we are duplicating messages from existing code and neither this or the existing code as test coverage for these message. Should a do a minor follow to test all possible messages when enabling themes?
The comment here seems off. We not installing the experimental theme. We are installing the theme that depends on the experimental theme.
Comment #40
effulgentsia CreditAttribution: effulgentsia at Acquia commentedI updated the draft CR: https://www.drupal.org/node/3086531/revisions/view/11594225/11596547.
Comment #41
zrpnr#38.2 I agree this message looks awkward, but it is a direct copy of the wording when installing an experimental module, we should open a follow-up to improve the wording in both places.
#39.1 I updated this per your suggestion, I can see why a function would be a good choice since it's checking the same condition on the theme and the dependencies, but I agree that a simpler loop is more clear.
#39.2 Used strict equality here, and updated the comment in
setDefaultTheme
since I was confused at first why this would be necessary.#39.3 Added "array" as a possible return value and updated the comment.
#39.4 Another followup here would be good too.
#39.5 Changed the wording in the comment
Comment #42
tedbow@zrpnr thanks for the updates. Just a couple more things and the 2 follows need to be created.
This looks good. Sorry didn't notice
\Drupal\system\Controller\ThemeController::setDefaultTheme()
has the same issue and needs its @return updated. Probably can just copy all of this there.I think we still need to check
isset($all_themes[$name])
as the first conditioned to be evaluated . incase it is somehow is not set the other conditions don't get evaluated.But actually...
Could we shorten this whole thing by doing
if (!empty($all_themes[$name]->info['experimental']) && $all_themes[$name]->status === 0) {
Because this way the second condition will be checked if
isset($all_themes[$name]) !== TRUE
(as a side effect of the first check).That way we can cut the conditions for the original 4 to 2.
Comment #43
zrpnr#42.2 Fixed, good catch!
#42.3 That is much more succinct and readable
Comment #44
tedbowLooks good to me! 🎉
Comment #45
Wim LeersThanks for pushing this across the finish line @zrpnr & @tedbow! 🙏
Comment #46
effulgentsia CreditAttribution: effulgentsia at Acquia commentedAdding reviewer credit.
Comment #47
effulgentsia CreditAttribution: effulgentsia at Acquia commentedPushed #43 to 8.8.x and published the CR.
However, tagging it for needing followups identified in #41 and #42. Also, it occurs to me that part of what makes #38.2 worse (in the case of Claro) is that...
This lists all dependencies, including ones already "installed". E.g., in the case of enabling Claro, if you already have Bartik installed, then you already have Stable and Classy "installed" as well, so we don't really need to include them in the confirmation message.
ModulesListConfirmForm
doesn't, because it iterates on a$dependencies
variable that only includes dependencies not yet installed. So let's also open a follow-up to clean that up for themes too. Because this message only appears when you're installing an experimental theme, and I don't think having it include extra base themes in that list is too terrible, I decided to not hold up commit on it.Comment #48
effulgentsia CreditAttribution: effulgentsia at Acquia commentedNot sure why d.o. hasn't added the commit comment to this issue yet. So here's the commit: https://git.drupalcode.org/project/drupal/commit/20faabf.
Comment #49
Wim LeersCreated the #38.2 follow-up that both #41 and #42 asked for: #3086941: Improve experimental theme/module installation warning.
Also created the follow-up that #47 asked for. Well-spotted. That would not have occurred if theme extensions had undergone the same improvements that module extensions have gone through. I agree we should not hold up improving this string on that though. See #3086942: Improve experimental theme confirmation warning to not list required base themes that are already installed.
Comment #51
lauriiiYay! 🔥🔥🔥 Thank you everyone! 🙏