Consider renaming javascript component ID to 'id' rather than machineName

Created on 27 January 2025, 5 months ago

Overview

See https://git.drupalcode.org/project/experience_builder/-/merge_requests/5...

Proposed resolution

User interface changes

๐Ÿ“Œ Task
Status

Active

Version

0.0

Component

Config management

Created by

๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @larowlan
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    FYI: \Drupal\experience_builder\Entity\JavaScriptComponent::$machineName was specifically chosen to match SDC's core/assets/schemas/v1/metadata-full.schema.json#properties.machineName

    As documented in config schema:

        # See core/assets/schemas/v1/metadata-full.schema.json#properties.machineName
        machineName:
          type: machine_name
          label: 'Machine Name'
          constraints:
            Regex:
              pattern: '/^[a-z]([a-zA-Z0-9_-]*[a-zA-Z0-9])*$/'
              message: 'The %value machine name is not valid.'
    
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    I get that we are following SDC, but we also use snake case for all other config entity properties. Not sure what is best here.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    I don't feel strongly, I was just explaining the rationale!

    If you got confused by it, and it sounds like #2 does not convince you.

    So: you decide! ๐Ÿ˜„ What did you expect? What would've caused the least friction for you? Name it so! ๐Ÿ‘

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands balintbrews Amsterdam, NL

    FWIW, I thought not using snake case for the property name was an oversight when I reviewed the code for โœจ HTTP API for code component config entities Active , and saw all the other properties.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands balintbrews Amsterdam, NL

    I realized I was looking for ๐Ÿ“Œ JavaScriptComponent config entities should have mutable machineNames Active when I found this issue. Should we close this in favor of ๐Ÿ“Œ JavaScriptComponent config entities should have mutable machineNames Active and handle the renaming there?

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    #6: yes, please.

    Except โ€ฆ maybe we wanna repurpose this issue to tackle #5?

    This is basically all you need for that:

    diff --git a/src/Entity/JavaScriptComponent.php b/src/Entity/JavaScriptComponent.php
    index 86e66995..062e5f63 100644
    --- a/src/Entity/JavaScriptComponent.php
    +++ b/src/Entity/JavaScriptComponent.php
    @@ -99,10 +99,10 @@ final class JavaScriptComponent extends ConfigEntityBase implements XbHttpApiEli
             'props' => $this->props,
             'required' => $this->required,
             'slots' => $this->slots,
    -        'source_code_js' => $this->js['original'] ?? '',
    -        'source_code_css' => $this->css['original'] ?? '',
    -        'compiled_js' => $this->js['compiled'] ?? '',
    -        'compiled_css' => $this->css['compiled'] ?? '',
    +        'sourceCodeJs' => $this->js['original'] ?? '',
    +        'sourceCodeCss' => $this->css['original'] ?? '',
    +        'compiledJs' => $this->js['compiled'] ?? '',
    +        'compiledCss' => $this->css['compiled'] ?? '',
           ],
           preview: [
             '#markup' => '@todo Make something ๐Ÿ†’ in https://www.drupal.org/project/experience_builder/issues/3498889',
    @@ -128,12 +128,12 @@ final class JavaScriptComponent extends ConfigEntityBase implements XbHttpApiEli
           'props' => $data['props'] ?? [],
           'slots' => $data['slots'] ?? [],
           'js' => [
    -        'original' => $data['source_code_js'] ?? '',
    -        'compiled' => $data['compiled_js'] ?? '',
    +        'original' => $data['sourceCodeJs'] ?? '',
    +        'compiled' => $data['compiledJs'] ?? '',
           ],
           'css' => [
    -        'original' => $data['source_code_css'] ?? '',
    -        'compiled' => $data['compiled_css'] ?? '',
    +        'original' => $data['sourceCodeCss'] ?? '',
    +        'compiled' => $data['compiledCss'] ?? '',
           ],
         ];
       }
    

    (plus equivalent search+replace in \Drupal\Tests\experience_builder\Functional\XbConfigEntityHttpApiTest::testJavaScriptComponent().)

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands balintbrews Amsterdam, NL

    #7 ๐Ÿ“Œ Consider renaming javascript component ID to 'id' rather than machineName Active : Yes, please, let's ๐ŸชCase! (Just like in โœจ Send entity keys to the editor from the mount controller Active .)

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Re-scoping to #7 per @balintbrews in #8.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • First commit to issue fork.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia libbna New Delhi, India

    Hey, I have updated the code in the JavaScriptComponent.php file as per the discussion and created a merge request for the changes. Please review and let me know if anything further is required. Thanks.

  • Pipeline finished with Failed
    28 days ago
    Total: 828s
    #507446
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Thanks! I'm afraid there's lots of out-of-scope code reformatting, even causing the phpcs CI job to fail ๐Ÿ˜‡

    Besides that, the other next step: update the UI :)

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia libbna New Delhi, India

    Hi @wim leers, could you please clarify what you mean by โ€œupdate the UIโ€? Additionally, could you outline the next steps required for this issue so I can proceed accordingly? Thank you!

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom thoward216

    Hi @libbna, I think I can help here.

    I would first take a look at the pipeline for the MR and you'll see a number of PHPCS issues, which is due to the reformatting @wimleers mentioned.

    In terms of the UI, it is currently still expecting `source_code_js` to be valid, if you search the code base for `source_code_js` you'll see it is referenced in a number of the UI React files, these will also need updating.

    Hopefully that makes sense and you can proceed.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia libbna New Delhi, India

    Hi @thoward216 thank you so much for clarifications.

    Assigning the issue to myself to continue working on it as mentioned.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia libbna New Delhi, India

    Just to confirm, should I follow the same approach for the other entity IDs as well?

  • Pipeline finished with Failed
    25 days ago
    Total: 897s
    #510220
  • Pipeline finished with Failed
    25 days ago
    Total: 762s
    #510237
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia libbna New Delhi, India

    I have updated the code. Please review and let me know if anything is missed.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia libbna New Delhi, India
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia omkar-pd

    eslint failed

  • Pipeline finished with Failed
    25 days ago
    Total: 1188s
    #510302
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia libbna New Delhi, India
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom thoward216

    Moving back to needs work as theres a PHP unit test failing.

  • Pipeline finished with Failed
    22 days ago
    Total: 886s
    #512193
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States hooroomoo

    Gonna continue this, would like this changes in for CLI tool work

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States hooroomoo
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Gonna push this to the finish line since its close, would like this changes in for CLI tool work

    โค๏ธ โ€” thanks! ๐Ÿ™

    Conflicted (trivially) with #3526297. Resolved those conflicts.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Looks like โœจ CLI command to download code components Postponed already landed, 1 day after @hooroomoo pushed this forward.

    Worryingly, the CLI tests are not failing โ€ฆ because they're not running! This means its tests are not running when underlying infra changes; only when CLI code itself changes. Fixingโ€ฆ

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Updated logic + test expectations for the following that landed since June 12, thanks to test coverage:

    I think this is ready, but the CLI test coverage seems to lack integration/functional tests ๐Ÿ˜ฑ Which is why the CLI vitest CI job passed when it clearly cannot work ๐Ÿ˜…
    We clearly shouldn't fix that here, but ๐ŸŒฑ [Meta] CLI tool for code components Active needs a child issue for creating such test coverage.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Removing tag here because I posted this at #3525571-5: [Meta] CLI tool for code components โ†’ , which is the more appropriate place. It's really no fallout of this issue.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States hooroomoo

    there's 1 phpunit test failing that i'm stumped on

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Thanks for updating all others, Iโ€™ll take care of that last straggler! ๐Ÿ˜„

    Glad to see this MRโ€™s work coming to fruition rather than waste ๐Ÿ‘

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Odd โ€ฆ passes locally? ๐Ÿค”

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Too fiddly to merge today. Enjoying the sun ๐Ÿ˜Ž

  • Pipeline finished with Skipped
    about 17 hours ago
    #529193
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
Production build 0.71.5 2024