Update default config to make a fresh install result in an XB UI with an empty canvas

Created on 5 September 2024, 10 months ago
Updated 16 September 2024, 10 months ago

Overview

Let's start cleaning up the experience and remove the default content. This served us well while developing this, but since we have capabilities now to actually build a lot of the stuff by yourself, it doesn't seem necessary anymore.

Proposed resolution

  1. Remove the default value for the XB field (config/optional/field.field.node.article.field_xb_demo.yml)
  2. Remove the Hero field (config/optional/field.storage.node.field_hero.yml + config/optional/field.field.node.article.field_hero.yml)

User interface changes

Empty canvas when you start using XB!

📌 Task
Status

Fixed

Component

Page builder

Created by

🇫🇮Finland lauriii Finland

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @lauriii
  • 🇫🇮Finland lauriii Finland
  • Status changed to Postponed 10 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    This must happen after 📌 Fix the visually broken "image" component instance: use FileUriItem's computed `url` property, not the stored `value` property Active at least, and possibly more issues, to minimize disruption for in-progress MRs.

  • Status changed to Active 10 months ago
  • Assigned to annmarysruthy
  • First commit to issue fork.
  • Issue was unassigned.
  • Assigned to deepakkm
  • Status changed to Needs work 10 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Talked to @lauriii, narrowing the scope, to the part that is actually important for 🌱 Milestone 0.1.0: Experience Builder Demo Active 👍

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Note: this blocks 📌 [PP-1] Harden UUID validation in ComponentTreeStructureConstraintValidator Postponed . (That's not urgent though.)

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    FYI: this also blocks 📌 Add Tugboat integration RTBC .

  • Assigned to tedbow
  • 🇺🇸United States tedbow Ithaca, NY, USA

    @deepakkm thanks the work on this. Since it past your end of day and this is important for 🌱 Milestone 0.1.0: Experience Builder Demo Active I am going to try move this forward

  • 🇺🇸United States tedbow Ithaca, NY, USA

    tedbow changed the visibility of the branch 3472299-remove-default-xb-field to hidden.

  • 🇺🇸United States tedbow Ithaca, NY, USA

    tedbow changed the visibility of the branch 3472299-remove-default-xb-field to active.

  • 🇺🇸United States tedbow Ithaca, NY, USA

    I have an idea I am working to leave the test coverage mostly the same so I am going to leave this assigned to me

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    If I do a fresh install of XB using this MR (and rebuilt the UI — I tested commit 4ce1b00bc8d2a41309ffcea12ae62b4a27a2845e of this MR), then I do start with an empty canvas. 🥳

    Unfortunately, I cannot place any component onto the canvas without fatal errors, except the sole propless component ()

    🚨 Surprisingly, @jessebaker and @shyam_bhatt did not run into the below that when they created 🐛 After deleting all the components from the canvas, "Add section" button should be visible on the canvas Active , where they manually emptied the canvas. So their starting point was different. I bet

    But there’s something odd going on with addNewComponentToLayout() in the UI: when dragging the component onto the empty canvas, the UI correctly initializes initialData (I just stepped through it), and hence

          dispatch(
            insertNode({
              to: payload.to,
              newNode: {
                children,
                nodeType: 'component',
                type: payload.newNode,
              },
              model: initialData,
            }),
          );
    

    has the correct model, yet somehow that information is lost by the time the request is sent to

    /api/preview/node/1
    

    :

    {
      "layout": {
        "uuid": "root",
        "nodeType": "root",
        "name": "root",
        "children": [
          {
            "children": [],
            "nodeType": "component",
            "type": "experience_builder:heading",
            "uuid": "611ba3f1-e3c8-4364-a512-44dd83501f82"
          }
        ]
      },
      "model": []
    }
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    To make TranslationTest pass, we need it to not rely on field_hero anymore. So, changes to the default

    • removed: {"uuid":"dynamic-image-udf7d","component":"experience_builder:image"},
    • replaced:
      {"uuid": "dynamic-image-static-imageStyle-something7d","component": "experience_builder:image"}
      with:
      {"uuid":"static-heading-some-uuid","component":"experience_builder:heading"}
      + as prop value:
      "static-heading-some-uuid":{"text":{"sourceType":"static:field_item:string","value":"hello, world!","expression":"ℹ︎string␟value"},"element":{"sourceType":"static:field_item:list_string","value":"h3","expression":"ℹ︎list_string␟value","sourceTypeSettings":{"storage":{"allowed_values":[{"value":"h1","label":"h1"},{"value":"h2","label":"h2"},{"value":"h3","label":"h3"},{"value":"h4","label":"h4"},{"value":"h5","label":"h5"},{"value":"h6","label":"h6"},{"value":"div","label":"div"}]}}}}
      
    • replaced the cta1href prop value for
      {"sourceType":"dynamic","expression":"ℹ︎␜entity:node:article␝field_hero␞␟entity␜␜entity:file␝uri␞␟value"}}
      with
      {"sourceType":"static:field_item:link","value":{"uri":"https:\/\/drupal.org","title":null,"options":[]},"expression":"ℹ︎link␟uri"}}
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    For the Cypress E2E tests, I recommend:

    • switching back to 0.x
    • apply
      diff --git a/tests/src/TestSite/XBTestSetup.php b/tests/src/TestSite/XBTestSetup.php
      index 87680653..9c4409a0 100644
      --- a/tests/src/TestSite/XBTestSetup.php
      +++ b/tests/src/TestSite/XBTestSetup.php
      @@ -75,6 +75,7 @@ class XBTestSetup implements TestSetupInterface {
             'title' => 'XB Needs This For The Time Being',
           ]);
           $node->save();
      +    var_dump($node->get('field_xb_test')[0]->toArray());
       
           $xb_role = Role::create([
             'id' => 'xb',
      
    • execute any Cypress test, observe the dumped output
    • copy/paste that dumped output into the Node::create() call in XBTestSetup
    • … that should keep all Cypress tests running exactly as-is, with zero changes
  • 🇬🇧United Kingdom jessebaker

    RE #17

    It seems that the initial request for the page data when loading the page made to /api/layout/node/1 is returning

    {
        "layout": {
            "uuid": "root",
            "nodeType": "root",
            "name": "root",
            "children": []
        },
        "model": []
    }
    

    The important part of that is that "model": [] here is coming back as a JS Array. When the model has content, the request returns model as a JS Object ("model": {}).

    If required, we can probably re-shape the data to make it work on the front end in this case, but I think the better solution would be to solve it on the back end.

  • 🇺🇸United States tedbow Ithaca, NY, USA
  • Assigned to wim leers
  • Status changed to RTBC 10 months ago
  • 🇺🇸United States tedbow Ithaca, NY, USA
  • Status changed to Needs review 10 months ago
  • 🇺🇸United States tedbow Ithaca, NY, USA

    whoops

  • 🇳🇿New Zealand danielveza Brisbane, AU

    Left a couple of tiny comments on the MR.

    The IS mentions updating CONTRIBUTING.md, I've checked it in the merge branch and I don't think anything needs to be updated :)

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Merged in upstream changes that 📌 Make Media Library a dependency Fixed landed … curious to see if this still passes 🤓

  • Issue was unassigned.
  • Status changed to RTBC 10 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    #24++ :)

  • Status changed to Needs work 10 months ago
  • 🇺🇸United States tedbow Ithaca, NY, USA
    1. re #24
      From contributing.md

      5. Browse to `/node/add/article` — you'll see a `🪄 XB Demo ✨` field. Don't touch that — just enter a title for the article and hit save: a component is rendered using the article title 🤓
      I think we do need to update this.
      The component is not render with title by default now, and you don't actually see the field in /node/add/article(maybe that was pre-existing).

    2. Manually testing, I did a fresh install and now I get error trying add a component.

      TypeError: array_diff_key(): Argument #1 ($array) must be of type array, null given in array_diff_key() (line 42 of /Users/ted.bowman/sites/exp-d-core/modules/contrib/experience_builder/src/Controller/SdcController.php).

      #0 /Users/ted.bowman/sites/exp-d-core/modules/contrib/experience_builder/src/Controller/SdcController.php(42): array_diff_key(NULL, Array)
      #1 /Users/ted.bowman/sites/exp-d-core/modules/contrib/experience_builder/src/Plugin/DataType/ComponentTreeHydrated.php(60): Drupal\experience_builder\Controller\HardcodedPropsComponentTreeItem->resolveComponentProps('353413ac-18b1-4...')
      #2 /Users/ted.bowman/sites/exp-d-core/modules/contrib/experience_builder/src/Plugin/DataType/ComponentTreeHydrated.php(121): Drupal\experience_builder\Plugin\DataType\ComponentTreeHydrated->getValue()
      #3 /Users/ted.bowman/sites/exp-d-core/modules/contrib/experience_builder/src/Plugin/Field/FieldType/ComponentTreeItem.php(309): Drupal\experience_builder\Plugin\DataType\ComponentTreeHydrated->toRenderable()
      #4 /Users/ted.bowman/sites/exp-d-core/modules/contrib/experience_builder/src/Controller/SdcController.php(389): Drupal\experience_builder\Plugin\Field\FieldType\ComponentTreeItem->toRenderable()

      I switched by to https://git.drupalcode.org/project/experience_builder/-/merge_requests/2... and it worked again.

      Maybe something changed in 0.x and the merged change caused this?

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    #27.2: thanks, that's what I was gonna do next before merging, and why I didn't merge rapidly before the personal stuff I left for at #26 😅

    That's exactly the problem I was running into I ran into in #17.

  • Assigned to wim leers
  • Status changed to Needs review 10 months ago
  • 🇺🇸United States tedbow Ithaca, NY, USA
  • Issue was unassigned.
  • Status changed to RTBC 10 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Manually tested, works well!

  • Pipeline finished with Skipped
    10 months ago
    #284595
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • Status changed to Fixed 10 months ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024