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

Command icon 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

amateescu created an issue. See original summary.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

amateescu’s picture

Title: Consider adding the concept of temporary workspaces » Add the concept of managed/temporary workspaces
Assigned: Unassigned » amateescu
Parent issue: » #3486378: [Plan] Allow for / implement simplified content workflow with workspaces

Started working on this.

geek-merlin’s picture

@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?

amateescu’s picture

Title: Add the concept of managed/temporary workspaces » Add the concept of workspace providers
Assigned: amateescu » Unassigned
Issue summary: View changes
Status: Active » Needs review

After trying out the initial proposal here with a temporary field, 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.

geek-merlin’s picture

Category: Feature request » Task
Priority: Normal » Major

Chapeau! 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.

geek-merlin’s picture

Current test failure looks like it needs a simple test expectation update.

geek-merlin’s picture

Status: Needs review » Needs work

Really nice work! Left some code comments.

amateescu’s picture

Status: Needs work » Needs review

@geek-merlin, thanks a lot for the in-depth review! Addressed all points and wrote the change records.

geek-merlin’s picture

Status: Needs review » Needs work

Really 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.

amateescu’s picture

Status: Needs work » Needs review

Answered the new comments, thanks for being so thorough! :)

geek-merlin’s picture

Great you appreciate it. The finishing line is in sight, i suppose it is RTBC if these ones are addressed.

geek-merlin’s picture

Status: Needs review » Needs work
amateescu’s picture

Status: Needs work » Needs review

Replied to the latest comments, and left the thread about checkAccess() open for core committers to give an opinion :)

geek-merlin’s picture

Status: Needs review » Reviewed & tested by the community
Related issues: +#3553283: [Plan] Leverage temporary workspaces for entity creation / update

Great! All review items are resolved. Nightwatch failure looks unrelated.
Banzai!

A small step code-wise, but...

catch’s picture

I 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.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, thanks!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

  • catch committed d2656465 on 11.x
    Issue #3095414 by amateescu, geek-merlin, catch: Add the concept of...
geek-merlin’s picture

I 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

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

gábor hojtsy’s picture