Problem/Motivation
There are various use-cases for displaying the contents of a workspace to content editors without showing them the full workspace UI. Here are two examples:
- Content Moderation: as discussed in #3486378: [Plan] Allow for / implement simplified content workflow with workspaces, a temporary workspace could be used behind the scenes to group all the references of the "main" moderated entity and publish all of them together
- the node preview system: it could be re-implemented using the Workspaces API, by creating a temporary workspace when the user enters the "preview state" for a node
Proposed resolution
Add the concept of workspace providers as tagged services, with the following behavior for workspaces with a non-default provider:
- they are hidden from the regular admin listing
- they can not be "switched into" manually from the UI, they can only be (de)activated by the code that defined/created them
Remaining tasks
Review.
User interface changes
None, workspaces with a non-default provider are not shown anywhere in the UI.
API changes
Nope.
Data model changes
Nope.
Release notes snippet
TBD.
Issue fork drupal-3095414
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:
- 3095414-add-workspace-providers
changes, plain diff MR !13513
Comments
Comment #8
amateescu commentedStarted working on this.
Comment #9
geek-merlin@amateescu: Great news! This was on my hot-list for long, but never found time.
From my mental notes:
> Add a boolean temporary base field to the workspace entity type
As "managed" workspace, it shloudl rather be a "Owner"/"Provider" base field, so modules can recognize their workspaces (which obeoletes the boolean field).
WDYT?
Comment #11
amateescu commentedAfter trying out the initial proposal here with a
temporaryfield, I found that it's too limiting (as @geek-merlin also mentioned above), and that we need to go a few steps further and allow providers to easily control the behavior of entity operations in a workspace.Comment #12
geek-merlinChapeau! From a first glance this looks exactly like i envisioned.
(I did not compare but assume) it essentially moves Code from Hook/EntityOperations to DefaultWorkflowProvider.
Setting to major task, as this is an important step towards important use cases (ForwardRevisionNG, DomainNG, NodePreviewNG, ...)
Summary (maybe CR draft):
Every workspace now has a provider
Every workspace now has a provider. To create a provider, create an autoconfigured service extending from WorkSpaceProviderBase.
WorkSpaces module Provides its functionality now via the WorkspaceDefaultProvider service (w/ ID 'default').
Will start a code review now.
Comment #13
geek-merlinCurrent test failure looks like it needs a simple test expectation update.
Comment #14
geek-merlinReally nice work! Left some code comments.
Comment #15
amateescu commented@geek-merlin, thanks a lot for the in-depth review! Addressed all points and wrote the change records.
Comment #16
geek-merlinReally nice work Andrei! Esp. the change records play in the top liga.
Left some more comments. Some of them drilling deeper on having the new API correct and clean.
Comment #17
amateescu commentedAnswered the new comments, thanks for being so thorough! :)
Comment #18
geek-merlinGreat you appreciate it. The finishing line is in sight, i suppose it is RTBC if these ones are addressed.
Comment #19
geek-merlinComment #20
amateescu commentedReplied to the latest comments, and left the thread about
checkAccess()open for core committers to give an opinion :)Comment #21
geek-merlinGreat! All review items are resolved. Nightwatch failure looks unrelated.
Banzai!
A small step code-wise, but...
Comment #22
catchI had one question about the ::checkAccess() stuff - for me I think we will end up with two providers in core, and maybe a third in contrib, and the third one as a 99.9% chance of being written by @amateescu, so I think it's fine but maybe an extra hint in the interface docs would remind someone to be careful.
Otherwise I already reviewed this briefly at DrupalCon (and before @geek-merlin gave it a much more comprehensive review) and am happy with it - my feedback was already incorporated and I don't see any new problems in the latest changes.
Comment #23
catchCommitted/pushed to 11.x, thanks!
Comment #27
geek-merlinI have published the CRs.
@amataescu, @catch:
Please bear again with my thoroughness. Can you look at this: #3553638: Make provider the bundle key of workspaces
Comment #29
gábor hojtsy