contentful / contentful-migration

🚚 Migration tooling for contentful
MIT License
324 stars 150 forks source link

Adding Custom sidebar widgets removes default widgets #661

Closed bits-by-brandon closed 3 years ago

bits-by-brandon commented 3 years ago

Expected Behavior

using .addSidebarWidget to add a new extension creates the sidebar at the end of the list of sidebar

Actual Behavior

using .addSidebarWidget to add a new extension removes all default builtin sidebar

Possible Solution

We are currently using the workaround of re-creating all the built-in sidebar widgets in the migration to not blow away the defaults.

Steps to Reproduce

  1. Create a new migration script creating a new Content Type
  2. use the .addSidebar migration method to add a new custom UI extension
  3. run this migration on Contentful using the CLI

Context

We came across this trying to create migrations for a new Content type and adding a translation extension to the content type. When running the migration using the CLI against Contentful, the end result has our new sidebar widget added to the content type, but all the default widgets were now removed.

Example migration:

module.exports = (migration) => {
    const fooContentType = migration
      .createContentType("fooContentType")
      .name("Foo Content Type")

    resourceType
      .createField("name")
      .name("Name")
      .type("Symbol")
      .localized(true)
      .required(false)
      .validations([])
      .disabled(false)
      .omitted(false);

    resourceType.displayField("name");
    // Here is our custom widget
    resourceType.addSidebarWidget("extension", "custom-extension-id")
};

We are currently working around this by re-adding all the default extensions:

    //...
    .addSidebarWidget("extension", "custom-extension-id")
    .addSidebarWidget('sidebar-builtin', 'publication-widget')
    .addSidebarWidget('sidebar-builtin', 'releases-widget')
    .addSidebarWidget('sidebar-builtin', 'content-workflows-tasks-widget')
    .addSidebarWidget('sidebar-builtin', 'content-preview-widget')
    .addSidebarWidget('sidebar-builtin', 'incoming-links-widget')
    .addSidebarWidget('sidebar-builtin', 'translation-widget')
    .addSidebarWidget('sidebar-builtin', 'versions-widget')
    .addSidebarWidget('sidebar-builtin', 'users-widget');

Environment

ghost commented 3 years ago

:tada: This issue has been resolved in version 4.2.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: