#Creating a block definition to replace previous block causes error

1 messages · Page 1 of 1 (latest)

frosty sentinel
#

"index.js:179 Uncaught TypeError: Cannot destructure property 'blockType' of 'row' as it is undefined."

frosty sentinel
#

@dim crow Sorry for ping, but I'm worried I broke something...is it possible my payload install is behind?

#

This is on the admin side, adding a Block to a collection

#

The page goes blank and prints that error

#

I'm on "payload": "^1.3.0"

#

import { Block, CollectionConfig } from "payload/types";

const BannerBlock: Block = {
  slug: "Banner",
  fields: [
    {
      name: "section",
      type: "text",
      required: true,
    },
    {
      name: "title",
      label: "Image Banner Title",
      type: "text",
      required: true,
    },
    {
      name: "subtitle",
      label: "Image Banner Sub-Title",
      type: "text",
      required: true,
    },
    {
      name: "image",
      type: "upload",
      relationTo: "media",
      required: true,
    },
  ],
};

const PanelBlock: Block = {
  slug: "Panels",
  fields: [
    {
      name: "section",
      type: "text",
      required: true,
    },
    {
      name: "panels", // required
      type: "array", // required
      label: "Content Panels",
      minRows: 1,
      maxRows: 4,
      labels: {
        singular: "Panel",
        plural: "Panels",
      },
      fields: [
        {
          name: "title",
          type: "text",
          required: true,
        },
        {
          name: "content",
          type: "textarea",
        },
        {
          name: "link",
          type: "text",
        },
        {
          name: "icon",
          type: "text",
        },
      ],
    },
  ],
};

const Pages: CollectionConfig = {
  slug: "pages",
  access: {
    read: () => true,
  },
  admin: {
    useAsTitle: "title",
  },
  fields: [
    {
      name: "title",
      label: "Page Title",
      type: "text",
      required: true,
      unique: true,
    },
    {
      name: "description",
      label: "Page Description",
      type: "textarea",
      required: true,
    },
    {
      name: "layout", // required
      type: "blocks", // required
      minRows: 1,
      maxRows: 20,
      blocks: [BannerBlock, PanelBlock],
    },
  ],
};

export default Pages;
dim crow
#

what is the Payload version that you actually have installed?

#

i would also try and use these exact field configs in a brand-new and empty Payload project created with npx create-payload-app, to see if the problem persists

#

this seems like a data problem, maybe you have docs that are out of date or similar. but if you can create this issue with a new / blank project, using these exact field / block definitions, then it would appear to be a bug and we can help look at this immediately

frosty sentinel
#

@dim crow Thanks my friend!

frosty sentinel
#

@dim crow Sadly updating did not fix the issue :/

#

I had a block before, "SliderBlock"

#

I renamed it, changed its schema a bit

#

To BannerBlock

#

updated the collection config

#

But now I can add blocks to the collection

#

cant*

dim crow
#

ahhh ok, if you renamed it, you should write a migration script to go through all your old docs, find any instances of the old block slug, and update them to the new block slug

frosty sentinel
#

I'm not sure how to do that

#

I figured it would take care of that kind of thing for me :X

dim crow
#

i believe there are some examples in our GitHub discussions about quick migration scripts

#

but yeah, migrations are manual as with most every ORM. We don't change your existing data ever for you, at least not yet

frosty sentinel
#

With prisma i can just do like prisma migrate dev --name

#

it would be nice to do prisma migrate

#

err payload migrate

#

and have it do that kind of thing

dim crow
#

that could very well be a thing that we build in the future

frosty sentinel
#

when i get financially stable enough ill quit my job and join payload

#

😛

dim crow
#

well, the good news there is that we will be prioritizing hiring future engineers straight from our community 😈

frosty sentinel
#

hehe amazing

#

My speciality is more like webgl / 3d stuff

#

But I do enjoy this kind of dev

#

TBH, I was looking at some other headless cms systems last night

#

And it's really rough out there

#

Payload is the only one who's marketing doesnt automatically make me feel like they just want all my $$$$$

#

And ive tried like, 7 of them

#

That and it works nicely

#

I mean not that you guys dont wnat $ but

#

you care about the community

#

etc

#

anyway, ill let you get back to it