Problem/Motivation

Recipes that add on can only do so for stuff that exists at the time. So for example, the Advanced SEO recipe adds SEO fields to existing content types. If you add a new content type, there's no way to reapply the recipe via the UI to get the fields on the new content type.

Proposed resolution

Not sure yet, I am sure we could tackle this in PB but how would someone even know to look there when the recipe is already applied?

I have no answers, just capturing the question in case it isn't already captured.

Comments

pameeela created an issue. See original summary.

phenaproxima’s picture

Project: Drupal CMS development repository » Project Browser
Version: » 2.0.x-dev
Component: General » Code

This doesn't feel in the scope of Drupal CMS specifically; moving to Project Browser.

pameeela’s picture

I disagree but I guess it depends what we mean. I’m saying I don’t think this can live only with the current PB UI. Maybe there are two issues, one for “allow reapplying recipes in PB” and another for what I’m getting at here which is the larger journey.

pameeela’s picture

Project: Project Browser » Recipe
Version: 2.0.x-dev » master

After some discussion, moving to recipes because we will have to solve it there in some way first.

Other notes:

  • Users should be shown this option where it's relevant, so for the SEO recipe, that would be when creating a content type
  • Users should be able to select which content types to apply it for, in order to prevent it from being applied to existing content types where it's either not relevant or would no longer apply for some reason
pameeela’s picture

Project: Recipe » Drupal core
Version: master » 11.x-dev
Component: Code » recipe system
phenaproxima’s picture

Users should be able to select which content types to apply it for

To be clear...this capability is not currently a thing recipes can do, generally speaking, and it may be declined by the system maintainers because it contradicts a design decision of the recipe system, which is that recipes express strong opinions and do not make logical decisions. This concept (choose which things this recipe applies to) veers uncomfortably close to a recipe having logic, which isn't allowed because it breaks predictability and composability.

You can still do it via config actions, as long as you have a custom action which can accept a list of content types to target. (There are some examples of this pattern in core.) But it might not be accepted by the recipe system itself.

Having said that, I can see ways to accomplish this. Here's an example (although I think it would be unlikely to land in core) -- maybe you could take a recipe as a "template", and generate a temporary copy of that recipe, with some minor alterations that do cause it to be applied to only certain content types. Then the temporary recipe could be deleted after being applied.

pameeela’s picture

I probably should have said this was a discussion with Tim Plunkett and Alex Pott (in fact, I think that part was Alex's idea specifically!). We were just chatting though, in very general terms.

thejimbirch’s picture

Issue tags: +Recipes initiative

Recipes can be re-applied on the command line, and there are even tests for it in Drupal CMS. It is Project Browser that is not allowing a recipe to be re-applied in the UI.

Since #3478332: Add a way to prevent recipes' imported config from being compared too strictly to active config landed, if we add strict: false to the Advanced SEO recipe, it should be able run even if the config it imports are changed.

Once #3481751: Opt some core recipes out of strict config comparisons lands it will be even easier for other recipes to follow suite if they rely on core recipes.

Users should be shown this option where it's relevant, so for the SEO recipe, that would be when creating a content type

That is interesting. How are they creating a content type? On /admin/structure/types/add or in Project Browser?

Users should be able to select which content types to apply it for, in order to prevent it from being applied to existing content types where it's either not relevant or would no longer apply for some reason

Currently, the fields would be added to any content type that didn't have them. Since the existing content type has the fields, they are skipped.

Now that #3303126: Make it possible for recipes to prompt for input values has landed, we could change the recipe to ask which content types to add the fields to, all, or specific bundle machine names. But again, that is only on the command line. I searched, but couldn't find an issue where Project Browser is going to support getting input for recipes.

thejimbirch’s picture

pameeela’s picture

How are they creating a content type? On /admin/structure/types/add or in Project Browser?

When we discussed this we were thinking of /admin/structure/types/add but as you alluded to that's only one possible journey. This is a pretty complicated problem from the UX side, and my guess would be we don't solve this until a bit later since we still have to solve the input problem (and I'm sure a few others) first.

So maybe this should be postponed?

thejimbirch’s picture

So maybe this should be postponed?

Makes sense.

... we could change the recipe to ask which content types to add the fields to, all, or specific bundle machine names.

I was wrong. Reading the change order, it is not currently possible.

And you can't do things like:

config:
actions:
node.type.${content_type}:
# ...some nefarious business...

This is not allowed because it would make the recipe's effects less predictable, and therefore less composable, which would violate a fundamental design principle of the recipe system.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.