Problem/Motivation

My content authors have requested that the preview link form display information on all the existing preview links.

Currently, the preview link form shows us the latest preview link url along when the time until it expires. My content authors would like to see the url, redirect url, and expiration for all existing preview links.

Proposed resolution

I want to add a details element to the preview link form.

proposed table

Remaining tasks

User interface changes

new details element with table

API changes

nope

Data model changes

nope

Issue fork wse-3538583

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

danflanagan8 created an issue. See original summary.

danflanagan8’s picture

Status: Active » Needs review
agarzola’s picture

Status: Needs review » Reviewed & tested by the community

I’ve applied this patch successfully and it does what it says on the tin!

amateescu’s picture

Assigned: Unassigned » s_leu
Status: Reviewed & tested by the community » Needs work

The current MR works well for its purpose, but we're planning on adding a full admin UI for preview links. Sebastian is working on that so assigning it to him.

s_leu made their first commit to this issue’s fork.

s_leu’s picture

Status: Needs work » Needs review

Ready for an initial review. The remaining pipeline fails are unrelated.

danflanagan8’s picture

I haven't tested yet because I'm having trouble with my local. I keep getting "The "workspace_preview_link" entity type does not exist." but I think it's a problem with Docker/lando file syncing rather than a bug in the code. Although, you know what, it is a bug in the code. The entity type definition uses the new format, which is not compatible with D10. So we'd either need to bump the core_version_requirement or add the D10-compatible entity type annotation in there.

I also haven't reviewed line by line. Still I'd like to share a few high level thoughts.

First, I love that the preview link is an entity now. As I was working on my original patch I was thinking to myself, "this would be a lot easier if the preview link was an entity!"

Second, I wonder if the canonical link for this entity shouldn't activate the preview. Wouldn't that be cool? I mean if I click a preview link entity that was rendered with "link to entity", isn't the preview the most obvious place to go?

Making the preview route and entity route (as opposed to a totally custom route with a custom controller) I think could make more granular access control easier. Currently there's a single broad permission to view previews. Now that the preview link is an entity, it's easy to imagine more sophisticated permissions. And my gut says that's all more natural if the preview route is the canonical entity route. This is mostly at the gut level, though. I haven't thought too hard. One immediate concern I would have with my idea is that we would still want to use the uuid rather than the id since we need to make it impossible to guess a valid preview url. I don't know how to deal with that.

amateescu’s picture

Status: Needs review » Needs work

@danflanagan8,

I wonder if the canonical link for this entity shouldn't activate the preview.

That's an interesting idea, but I think it'd be too risky/disruptive. Most listings (list builders, views) will provide that link by default, which would make accidental workspace preview activation way too easy. Let's provide it as a activate link template instead :)

s_leu’s picture

Status: Needs work » Needs review
danflanagan8’s picture

Status: Needs review » Needs work
StatusFileSize
new162.43 KB
new19.2 KB

Excited about this! Doing some manual testing after applying patch to 2.0.0-alpha13...

Update hooks look good:

 ------------- ----------- --------------- ----------------------------------- 
  Module        Update ID   Type            Description                        
 ------------- ----------- --------------- ----------------------------------- 
  wse_preview   11001       hook_update_n   11001 - Install the                
                                            workspace_preview_link entity      
                                            type.                              
  wse_preview   11002       hook_update_n   11002 - Migrate preview link data  
                                            from key_value_expire to entity    
                                            storage.                           
  wse_preview   11003       hook_update_n   11003 - Install the workspace      
                                            preview links view.                
 ------------- ----------- --------------- ----------------------------------- 

>  [notice] Update started: wse_preview_update_11001
>  [notice] Update completed: wse_preview_update_11001
>  [notice] Update started: wse_preview_update_11002
>  [notice] Migrated 6 preview links from key_value_expire to entity storage. 0 entries were skipped.
>  [notice] Update completed: wse_preview_update_11002
>  [notice] Update started: wse_preview_update_11003
>  [notice] Update completed: wse_preview_update_11003

And once I'm in a workspace, the new listing of preview links looks really slick!

new ui

Those are links that were successfully promoted to content entities by the update hook. Nicely done!

The filter works for me. Very cool.

I have run into a couple bugs though.

First, if I go to the Workspaces listing page (/admin/config/workflow/workspaces) I get a WSOD with the following error:

Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("workspace") to generate a URL for route "entity.workspace_preview_link.collection". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 189 of /app/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php).

Second, if I am generating a new preview link, the "Expire date and time" default value isn't working. The help text reads "Leave blank to use the time of form submission." But if I actually leave it blank, I get a validation error because it's a required field:

form error

That said, I don't think using the time of form submission really makes sense. Does this MR get rid of the preview_expiry_default setting? Could that value still be used to set the default expiry time here?

amateescu’s picture

Opened a 3.0.x-only MR from @s_leu's work on in MR 120, and I'll start fixing stuff found by @danflanagan8 above as well as some UX issues.

amateescu’s picture

Project: Workspaces Extra » Workspace Preview
Version: 2.0.x-dev » 1.0.x-dev
Component: Workspace Preview » Code
Assigned: s_leu » Unassigned
Category: Feature request » Task
Status: Needs work » Fixed

After a bunch of updates and new features added to this MR, I decided to promote WSE Preview to a standalone module: www.drupal.org/project/workspace_preview

Wrote a change record as well with more details: https://www.drupal.org/node/3592549

Thanks everyone for the work and testing from this issue!

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

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

Maintainers, credit people who helped resolve this issue.