Sub issue of #1823450: [Meta] Convert core listings to Views
Problem/Motivation
Shortcut block can be converted to view.
Beta phase evaluation
This is appropriate for 8.0.x.
| Issue category | Task because the functionality of these listings is already in core (with custom code) |
|---|---|
| Issue priority | Major because this Meta is about replacing core listings in many places, across systems, and has community consensus for being important. Not critical because we can release 8.0.0 without completing the conversion to views and do it in a later release. Keeping the custom code (not converting a listing) will not cause severe performance or usability regressions. |
| Prioritized changes | A bit, it maybe would reduce fragility by re-using views code and getting rid of custom listing code. |
| Disruption | It will not be disruptive for core/contributed and custom modules/themes because it will not require a BC break/deprecation/widespread changes since changes are isolated to core listing custom code. |
Proposed resolution
Create a view for shortcut block.
The original scope was to replace the existing block with a view but that changed, see #70 - #73.
Remaining tasks
Fix core/tests/Drupal/FunctionalTests/Core/Recipe/StandardRecipeTest.php
Review
User interface changes
API changes
None
| Comment | File | Size | Author |
|---|
Issue fork drupal-2502151
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
jibranComment #3
jibranFixed the test fails.
Comment #5
jibranRe-uploading...
Comment #7
jibranThis should be green.
Comment #9
jibranNow with functional test.
Comment #10
jibranCreated #2502913: Link field default options values should be array for this.
This is ready for review.
Comment #11
tstoecklerThanks @jibran. Will try it out, but from looking at it looks great so far!
Comment #12
jibranMerged #2502913: Link field default options values should be array in it. Do not test patch is without the changes of #2502913. Have done minor cleanup interdiff included.
Thanks for having a look at it @tstoeckler
Comment #14
jibranFixed the test.
Comment #15
jibranReroll after #2502913: Link field default options values should be array
Comment #16
dawehnerThat comment seems a bit pointless, if you ask me, but the actual thing is that you should not need config schema in case there is no config ... it should inherit things automatically.
OOH, yes! <3
.
{@inheritdoc}Oh wow, this actually works?
Would it be possible to move the existing code to a trait instead?
Comment #17
jibranFixed #16. Thanks for the review @dawehner
Comment #18
kattekrab commentedAnd a manual test - works pretty nicely.
I was even able to edit the view, switch from HTML list to grid.
Comment #19
kattekrab commentednitpick: All the other view descriptions end with a full stop. This probably should too.
Comment #20
joshi.rohit100Comment #21
dawehnerLet's cache the view ...
Comment #22
joshi.rohit100Comment #23
moshe weitzman commented+ cacheable: falseThere are a couple instances of this. Not sure if it matters.
Comment #24
kattekrab commentedJust did another manual test. Still works!
Does the cacheable thing matter?
No? Let's RTBC this.
Yes? Back to needs work for a tidy-up.
:)
Nice work everyone.
Comment #25
jibran@moshe weitzman I checked the default taxonomy term view it also has the same situation so I think it doesn't matter. @kattekrab the answer is no so it can be RTBC.
Thank you @joshi.rohit100 for the quick fixes.
Meanwhile updated the shortcut description and added a category to the view.
Comment #26
kattekrab commentedYes. That's better. Just "Shortcuts." had been bugging me.
Do we need a change record for this?
Comment #27
jibranThere is one https://www.drupal.org/node/2084727 already we can update it after the commit.
Comment #28
nickdickinsonwildelooks good to me
Comment #29
kattekrab commentedGreat! RTBC++
Comment #30
lauriiiSorry for jumping in on the issue :) Just fixed some inconsistency on the array syntaxes and documentation
Comment #31
kattekrab commentedTested again. Still works!
And in the meantime, the unrelated bug I found while doing initial testing for this has been fixed and committed too! :-)
#2511024: Can't add multiple content types to shortcuts
Comment #32
wim leersWhy is it cacheable per URL? Which plugin/handler of this view causes that?
And which handler/plugin causes the view to be uncacheable?
We should add a @todo here: it doesn't need to be cached per user, but per-current-shortcut-set. I.e. a new
user.shortcut_setcache context.Can be follow-up of course. But right now, this unnecessarily reduces cacheability. This would point anybody interested user towards the issue where that will be improved.
Finally: this will conflict with #2464427: Replace CacheablePluginInterface with CacheableDependencyInterface.
Comment #33
jibranThank you very much for the review @Wim Leers. I have rerolled the patch on #2464427: Replace CacheablePluginInterface with CacheableDependencyInterface. Let's postpone this on #2464427: Replace CacheablePluginInterface with CacheableDependencyInterface for now.
#32
Comment #34
wim leers::calculcateCacheMetadata(). Also for point 1.Comment #35
jibranThanks for pointing me into right direction.
ArgumentPluginBase::getCacheContexts().Views::addCacheMetadata()doesn't take that into account it just the same value as yml file.Comment #36
olli commentedFiled #2514784: \Drupal\views\Plugin\views\argument\ArgumentPluginBase should allow subplugins to specify a more specific url cache context to fix #35.1.
Comment #37
wim leers@jibran: awesome
@olli: THANK YOU!
Comment #38
jibranWe also need an upgrade path for replacing the original block with the block provided by views.
Comment #39
jibranAdded upgrade path rolled on
replace-2464427-97-do-not-test.patchin #2464427-97: Replace CacheablePluginInterface with CacheableDependencyInterface so still postpone.Comment #40
jibran@alexpott reviewed the patch in IRC. Thanks for the suggestions. Updated the update hook it needs update path test now.
Comment #41
larowlanCan we split the BTB improvements into their own issue?
Comment #42
andypost+1 to split
Comment #43
larowlanRe-roll
Comment #44
tstoecklerUnblocked now. Let's see.
Comment #47
jibranReroll.
Comment #52
jibranFixed schema.
Comment #53
tstoecklerThis is 8.1.x material now.
Code looks pretty good, mostly only have minor comments. Will take this for a spin now. Also we need tests for the upgrade path.
This is not correct. There are actually no settings saved in the default argument handler, so the schema should not pretend there are. Let's do
type: mappingand thenmapping: { }Edit: I just looked at what other default argument plugins are doing and they are doing the same thing. So I guess we can leave it here and just update all of them together in a separate issue.
Also found #2623548: Remove obsolete views.argument_default.php config schema :-P
"views" -> "Views"
Remove this empty line.
"views and block" -> "Views and Block"
Minor but you can use
$module_handler->getModule('shortcut')->getPath();"Only update shortcut blocks."
Is there a reason we are deleting and recreating the block instead of just updating it directly?
shortcut block*s* and *V*iews shortcuts block*s*.
Let's leave this as BC, now that 8.0.0 is out and just add a @deprecated
Let's remove that @todo.
hook_default_shortcut_set()does not support cache metadata currently, so being able to *properly* cache shortcut (sets) is a whole can of worms, but making it per-user is a pretty good best effort IMO, so it should be fine for now."place *it* in a region"
The "through api" can be removed IMHO.
Maybe also assert that the shortcut title appears.
Comment #54
tstoecklerOpened #2623568: Config schema of argument_default plugins is incorrect
Comment #55
tstoecklerHere is a comparison of the markup and some screenshots to prove that the output is the same. The added markup is just in the nature of the game of using Views, I'm not sure we can do a lot about this.
Current:

Views:

Current markup:
Views markup:
Comment #56
jibranFixed the feedback from #53.
I'll try to write the upgrade path tests next.
Comment #58
jibranNice one.
Now with
git diff 8.1.x > convert_shortcut_block-2502151-58.patchinstead ofgit diff 8.0.x > convert_shortcut_block-2502151-56.patchComment #60
jibranWith upgrade path tests now.
Comment #62
jibranThis test passes locally for me.
Comment #63
jibranMaybe this will fix this.
Comment #65
kattekrab commentednice to see this moving again Jibran! :)
Comment #67
jibranWith green patch. Maybe the fails will be more verbose after #2608532: Simpletest UI munges PHPUnit-based test output.
Thanks @kattekrab.
Comment #68
tstoecklerLooks great to me. Thanks a lot @jibran, really great work!
Comment #69
tstoecklerI still think it is unnecessary to remove the block class, as there is no real benefit to breaking BC for that, but I'll let committers decide that. It's not a big issue to remove that part from the patch.
Comment #70
alexpottSo if a site is using shortcuts but not views then they'll just lose the block? Also what happens if they've placed the block - I think that now the block would be broken...
Comment #71
alexpottI think we'll either need to maintain the shortcut block as a fallback - but that is going to be very confusing since not sure how a fallback with blocks would actually work. I think we should just proceed with the shortcut views integration that this patch adds.
Comment #72
jibranHere is what I think we should do:
ShortcutsBlock.Comment #73
alexpottSo I think it makes sense to not "upgrade" the shortcut block but provide views integration. I'm not sure of the point of providing the disabled default view? Also all the block creatiion trait stuff should be in a separate patch.
Comment #87
sivakarthik229 commentedHello,
Adding patch for Drupal 9.4.
Please review and provide the feedback.
Thanks
Siva
Comment #88
sivakarthik229 commentedComment #89
sivakarthik229 commentedFixing PHPCS for the files.
Comment #90
sivakarthik229 commentedFixing PHPCS error.
Comment #92
quietone commentedIt was suggested in #72 to remove the upgrade path. That was agreed to by alexpott in the next comment so I am removing the upgrade tag,
Comment #93
sivakarthik229 commentedHello,
Created shortcuts view module.
https://www.drupal.org/project/shortcut_view
Thanks
Siva
Comment #97
quietone commentedComment #98
quietone commentedComment #100
quietone commentedThe Shortcut Module was approved for removal in #3476880: [Policy] Move Shortcut module to contrib.
This is Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.
The deprecation work is in #3569117: [meta] Tasks to deprecate the Shortcut module and the removal work in #3569121: [meta] Tasks to remove the Shortcut module.
Shortcut will be moved to a contributed project before Drupal 12.0.0 is released.