Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

miro_dietiker’s picture

I guess you mean that the "add to library" action is not displayed?
A validation is a bit late.

I proposed that we should have a checkbox if a paragraph type is allowed to be put into the library.
Are we now only looking at selection plugin settings?

Berdir’s picture

no, I'm not talking about add to library.

I'm talking about adding a library paragraph and then selecting one through auto-complete (or entity browser, or ..).

Not sure if there's an easy way to already limit it in the autocomplete/selection plugin, that's why I said validation.

maybe we have access to the field then it might be possible. needs to be investigated.

Primsi’s picture

Assigned: Unassigned » Primsi
Primsi’s picture

As per discussion, we will define a third party setting per paragraph type, that states, that this paragraph type can be converted into a library item. We will then check for that while displaying the button and possible creating the library entity.

Primsi’s picture

Status: Active » Postponed
FileSize
7.19 KB

This relies on #2884095: Add paragraphs entity to hook_paragraph_widget_dropbutton_alter. Also a bit of scope creep with the use statements.

miro_dietiker’s picture

Status: Postponed » Needs review

Committed the other. Now let's see.

Status: Needs review » Needs work

The last submitted patch, 6: validate_library-2882390-6.patch, failed testing. View results

miro_dietiker’s picture

:-) Schema errors for paragraphs.paragraphs_type.text with the following errors: paragraphs.paragraphs_type.text:third_party_settings.paragraphs_library.disallow_library_conversion missing schema

Primsi’s picture

Let's try again.

Berdir’s picture

  1. +++ b/modules/paragraphs_library/config/schema/paragraphs_library.schema.yml
    @@ -0,0 +1,7 @@
    +    disallow_library_conversion:
    +      type: integer
    +      label: 'Disallow conversion to paragraph library item'
    

    this means it is an opt-out and not an opt-in, not sure what makes more sense.

  2. +++ b/modules/paragraphs_library/paragraphs_library.module
    @@ -21,22 +22,30 @@ function paragraphs_library_paragraph_widget_dropbutton_alter(&$links, &$context
    +    /** @var ParagraphsTypeInterface $paragraphs_type */
    +    $paragraphs_type = \Drupal::entityTypeManager()->getStorage('paragraphs_type')->load($bundle);
    

    I think we have getParagraphType() on $paragraph for this, problem is just that ParagraphsInterface is missing most of the methods it should have.

Other than that, this looks pretty good. Only problem is that this is not what I created this issue for, it was the other side of this problem, the part where you can select whatever kind of library item you want and store it, even though the target paragraph type wouldn't be allowed in this context. We either need a new issue for what the issue was about or a new issue for what the patch is about :)

Primsi’s picture

this means it is an opt-out and not an opt-in, not sure what makes more sense.

I first did it the other way around, but then it felt to me that this way to be more natural. I thought that if one installs paragraphs_library, having the ability to convert paragraphs to library without additional steps is what I would expect. Both approaches are valid though.

We either need a new issue for what the issue was about or a new issue for what the patch is about :)

:) Then given that we already derailed this issue my vote goes for a to rename this issue and add another one.

Status: Needs review » Needs work

The last submitted patch, 12: validate_library-2882390-12.patch, failed testing. View results

Primsi’s picture

Did not rebase.

Primsi’s picture

Primsi’s picture

As per discussion, require per type allow conversion.

Primsi’s picture

mbovan’s picture

miro_dietiker’s picture

Status: Needs review » Needs work
+++ b/modules/paragraphs_library/paragraphs_library.module
@@ -134,3 +140,32 @@ function _paragraphs_library_count_usage(array $usage_data) {
+  $form['allow_library_conversion'] = [

Don't show this checkbox on from_library type.

Primsi’s picture

This applies now only for type "from_library". Not sure if there is a better way to do it.

miro_dietiker’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/modules/paragraphs_library/config/schema/paragraphs_library.schema.yml
@@ -0,0 +1,7 @@
+  label: 'Per-paragraph type third party settings'

I think the label should more mention the library to be valuable. But at least in a test module i have seen this label skipped on this level.

Other than that i think we should get this in.

  • Primsi committed 94e51fd on 8.x-1.x
    Issue #2882390 by Primsi, mbovan, miro_dietiker, Berdir: Validate...
Primsi’s picture

Status: Reviewed & tested by the community » Fixed

Corrected the label and committed.

Status: Fixed » Closed (fixed)

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