Overview

When I attempt to create a component with a name as one that already exists, it tries to use the same machine name (ID), and I get an error.:

{
    "status": 409,
    "data": {
        "errors": [
            "'js_component' entity with ID 'image' already exists."
        ]
    }
}

Steps to reproduce

There are 2 different ways to trigger this error:

Standard components:

  1. Create a "Hero" component.
  2. Create another "Hero" component with the same name ("Hero").
  3. Try to create a third "Hero" component with the same name and you will get the error.

Dynamic components:

  1. Create a component with the same name as a dynamic component, e.g., 'breadcrumb'.
  2. Try to create another component with same name and you will get the error.

Proposed resolution

User interface changes

Comments

mayur-sose created an issue. See original summary.

wim leers’s picture

Title: Creating multiple components with same label causes error: entity with ID already exists » [Needs design] Creating multiple components with same label causes error: entity with ID already exists
Component: Page builder » Theme builder
Issue tags: +Needs design
Related issues: +#3503547: Display validation errors in dialogs that create sections, +#3504366: ApiConfigControllers::post() should detect a conflicting ID and throw a 409 exception

The API response already is a 409, which conveys "conflict". That happened in #3504366: ApiConfigControllers::post() should detect a conflicting ID and throw a 409 exception, to address @balintbrews' #3503547-2: Display validation errors in dialogs that create sections.

This is a subset of #3503547: Display validation errors in dialogs that create sections. I'm tempted to mark this a duplicate, but actually, this probably deserves its own UX, so keeping it separate makes sense?

wim leers’s picture

Issue tags: +Usability
hooroomoo’s picture

Title: [Needs design] Creating multiple components with same label causes error: entity with ID already exists » Creating multiple components with same label causes error: entity with ID already exists
Status: Active » Closed (works as designed)

Hm I'm not sure how you got the error for giving an existing name of a standard/dynamic component to a jS component, because the machine name/ID for a JS component gets appended with a "js" so if you named a JS component Breadcrumbs, then its id would be "js.breadcrumbs" therefore avoiding any conflicts.

It is by design for js components to not be allowed to have the same name. I am therefore marking this issue closed (works as designed).

https://www.drupal.org/project/experience_builder/issues/3520071#comment... will add the "js_component' entity with ID 'image' already exists." to render in the dialog, so the user will also see it right away now.