slice-machine icon indicating copy to clipboard operation
slice-machine copied to clipboard

Custom Type that defines slices that arent saved to library are not synced to local correctly

Open shainegordon opened this issue 3 years ago • 2 comments

Version

  • Prismic CLI version (know it by running prismic --version): 3.8.13
  • slice-machine-ui version (know it by running prismic --version): 0.1.0-alpha.6

Reproduction

In .prisimic.io create a new "Single Type" called "Menu", and configure it with the following JSON, and then "Save"

{
  "Main": {
    "doc_name": {
      "type": "StructuredText",
      "config": {
        "single": "heading1",
        "label": "Document name"
      }
    },
    "nav": {
      "type": "Slices",
      "fieldset": "Slice zone",
      "config": {
        "choices": {
          "nav_item": {
            "type": "Slice",
            "fieldset": "Nav Item",
            "description": "Nav Item with Sub Navigation",
            "icon": "insert_link",
            "non-repeat": {
              "label": {
                "type": "StructuredText",
                "config": {
                  "single": "paragraph",
                  "label": "Label",
                  "placeholder": "Enter Link Label..."
                }
              },
              "link": {
                "type": "Link",
                "config": {
                  "label": "Link",
                  "placeholder": "Select Link..."
                }
              }
            },
            "repeat": {
              "sub_nav_link_label": {
                "type": "StructuredText",
                "config": {
                  "single": "paragraph",
                  "label": "Sub Nav Link Label",
                  "placeholder": "Enter Sub Nav Link Label..."
                }
              },
              "sub_nav_link": {
                "type": "Link",
                "config": {
                  "label": "Sub Nav Link",
                  "placeholder": "Select Sub Nav Link..."
                }
              }
            }
          }
        }
      }
    }
  }
}

Open "Slice Machine" - prismic sm --develop - and visit http://localhost:9999/

Go to "Custom Types" -> "Menu" and click "Save To Filesystem"

What is expected?

The file customtypes/menu/index.json is created with the following content:

{
  "id": "menu",
  "label": "Menu",
  "status": true,
  "repeatable": false,
  "json": {
    "Main" : {
      "doc_name" : {
        "type" : "StructuredText",
        "config" : {
          "single" : "heading1",
          "label" : "Document name"
        }
      },
      "nav" : {
        "type" : "Slices",
        "fieldset" : "Slice zone",
        "config" : {
          "choices" : {
            "nav_item" : {
              "type" : "Slice",
              "fieldset" : "Nav Item",
              "description" : "Nav Item with Sub Navigation",
              "icon" : "insert_link",
              "non-repeat" : {
                "label" : {
                  "type" : "StructuredText",
                  "config" : {
                    "single" : "paragraph",
                    "label" : "Label",
                    "placeholder" : "Enter Link Label..."
                  }
                },
                "link" : {
                  "type" : "Link",
                  "config" : {
                    "label" : "Link",
                    "placeholder" : "Select Link..."
                  }
                }
              },
              "repeat" : {
                "sub_nav_link_label" : {
                  "type" : "StructuredText",
                  "config" : {
                    "single" : "paragraph",
                    "label" : "Sub Nav Link Label",
                    "placeholder" : "Enter Sub Nav Link Label..."
                  }
                },
                "sub_nav_link" : {
                  "type" : "Link",
                  "config" : {
                    "label" : "Sub Nav Link",
                    "placeholder" : "Select Sub Nav Link..."
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

What is actually happening?

The file customtypes/menu/index.json is created with the following content:

{
  "id": "menu",
  "label": "Menu",
  "status": true,
  "repeatable": false,
  "json": {
    "Main": {
      "doc_name": {
        "type": "StructuredText",
        "config": {
          "single": "heading1",
          "label": "Document name"
        }
      }
    }
  }
}

As you can see, the "Slice zone" has not been synced correctly.

shainegordon avatar Jun 21 '21 09:06 shainegordon

Hey @shainegordon, the local builder currently does not handle non shared slices. I'm adding this to our backlog, we'll start working on this as soon as 0.1 is released

hypervillain avatar Jun 24 '21 15:06 hypervillain

Great, we will definitely work around this by using a shared slice

shainegordon avatar Jun 29 '21 13:06 shainegordon