webiny/webiny-js

Creating Headless CMS Entries in a Modal Dialog Saves Incorrect Folder

owenfarrell opened this issue · 0 comments

Version

5.37.0

Operating System

No response

Browser

No response

What are the steps to reproduce this bug?

I've come across a similar sounding situation. Happy to open a separate issue if this is off-topic...

  1. Create a group of CMS models, including a model that has a ref to other models defined in the same group (e.g. a Page contains multiple Section entries, and each Section contains multiple Card entries)
  2. Navigate to the top-level model in the Headless CMS admin page.
  3. Create a new Page entity
  4. From the Page creation screen, create a new Section via the modal dialog
  5. From the modal dialog, create a Card entry.

What is the expected behavior?

All headless CMS entries are stored in a Webiny admin folder for the corresponding type (i.e., Section entries are stored in a cms:section folder, Card entries are stored in a cms:card folder).

All new entries should be visible when browsing model entries via the folder browser in the admin application.

What do you see instead?

CMS entries are stored in a Webiny admin folder that does not correspond to the model type (i.e., Section entries are stored in a cms:page folder, Card entries are stored in a cms:section folder).

As a result, these entries are missing when browsing model entries via the folder browser in the admin application.

Additional information

Main API Query

{
  aco {
    listFolders (where: {type: "cms:card"}) {
      data { id }
    }
  }
}

Main API Response

{
  "data": {
    "aco": {
      "listFolders": {
        "data": [
          {  "id": "64deb79213adae0008558326#0001"},
          {  "id": "64deb78c13adae0008558325#0001"},
          {  "id": "64deb78413adae0008558324#0001"}
        ]
      }
    }
  }
}

Headless CMS Query

{
  listCards {
    data {
      wbyAco_location { folderId }
    }
  }
}

Headless CMS Response (note that folder ID 64deb63113adae0008558321 does not appear in the above response)

{
  "data": {
    "listCards": {
      "data": [
        ...
        { "wbyAco_location": { "folderId": "64deb63113adae0008558321#0001" } },
        { "wbyAco_location": { "folderId": "64deb63113adae0008558321#0001" } },
        ...
      ]
    }
  }
}

Main API Query

{
  aco {
    getFolder (id: "64deb63113adae0008558321#0001") {
      data { id type }
    }
  }
}

Main API Response (note that the folder type doesn't match the entity type above)

{
  "data": {
    "aco": {
      "getFolder": {
        "data": {
          "id": "64deb63113adae0008558321#0001",
          "type": "cms:page"
        }
      }
    }
  }
}

Possible solution

Per @Pavel910, the "create entry" dialog doesn't load the folders relevant to the referenced model, and instead stays in the context of the original mode.