Problem/Motivation

It would be great if you could enable this for just one content type for example and nothing else.

Proposed resolution

Add a simple config object for storing a list of entity types and bundles which should receive the preview link treatment. Allowing developers to customise the allowed entity types/bundles.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

Sam152 created an issue. See original summary.

sam152’s picture

Status: Active » Needs review
StatusFileSize
new7.63 KB
fenstrat’s picture

Status: Needs review » Needs work

Looking really good, just one super minor nit.

+++ b/src/Access/PreviewEnabledAccessCheck.php
@@ -0,0 +1,83 @@
+   * Check if the entity type and bundle are allowed.

Nit: allowed > enabled

sam152’s picture

Status: Needs work » Needs review
StatusFileSize
new1.86 KB
new7.63 KB

Good catch, fixing terminology.

fenstrat’s picture

Status: Needs review » Reviewed & tested by the community

.

benjy’s picture

LGTM

larowlan’s picture

+++ b/preview_link.post_update.php
@@ -0,0 +1,15 @@
+  $config = \Drupal::configFactory()->getEditable('preview_link.settings');

do we need to check the installed version here so this only runs on existing sites?

jibran’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/preview_link.post_update.php
@@ -0,0 +1,15 @@
+function preview_link_post_update_install_config() {

This needs to update hook because we are adding the new schema.

sam152’s picture

Re: #7, these updates only run on sites with the module already installed right?

Re: #8, if updb installs the new schema, wouldn't I want a post update here to ensure the schema is present before adding the new config?

jibran’s picture

if updb installs the new schema

updb doesn't install new schema.

wouldn't I want a post update here to ensure the schema is present before adding the new config

schema should be valid before running post-update hooks. As we are adding the new schema that means after updating the codebase site will have invalid schema so it should be fixed by hook_update_N.

sam152’s picture

Status: Needs work » Needs review
StatusFileSize
new780 bytes
new7.59 KB

I don't think an object not existing counts as invalid schema, but reading the docs this seems like the right approach for new schema on existing objects, so may as well follow suit with that.

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

  • Sam152 committed 54ba7b1 on 8.x-1.x
    Issue #3033759 by Sam152: Allow preview links to be restricted to...
sam152’s picture

Status: Reviewed & tested by the community » Fixed

Thanks folks.

Status: Fixed » Closed (fixed)

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