keystonejs / keystone-classic

Node.js CMS and web app framework
http://v4.keystonejs.com
MIT License
14.64k stars 2.21k forks source link

CloudinaryImage.blocks.image block won't work in more than one Content type field in the same model #5002

Closed dearlordylord closed 3 years ago

dearlordylord commented 3 years ago

Expected behavior

For two field of type Content in the same model, adding a CloudinaryImage.blocks.image block, I expect them to work

Actual/Current behavior

They don't work

Steps to reproduce the actual/current behavior

// models/post.ts
import { Text } from '@keystonejs/fields';
import { CloudinaryImage } from '@keystonejs/fields-cloudinary-image';
import { Wysiwyg } from '@keystonejs/fields-wysiwyg-tinymce';
import { Content } from '@keystonejs/fields-content';
import { ListSchema } from '@keystonejs/keystone';
import { cloudinaryAdapter } from '../adapters/cloudinaryAdapter';

const { access } = require('../auth/utils');
export const NAME = 'Post';

const contentBlocks = [
  Content.blocks.blockquote,
  Content.blocks.link,
  Content.blocks.orderedList,
  Content.blocks.unorderedList,
  Content.blocks.heading,
  [CloudinaryImage.blocks.image, { adapter: cloudinaryAdapter }]
];

export const model: ListSchema = {
  fields: {
    contentBrief: {
      type: Content,
      blocks: contentBlocks,
    },
    contentExtended: {
      type: Content,
      blocks: contentBlocks,
    },
  },
  access: {
    read: () => true,
    update: access.userIsAdminOrOwner,
    create: access.userIsAdmin,
    delete: access.userIsAdmin,
    auth: false,
  },
};

export default {
  name: NAME,
  model
};

-> get the error in node console during build

(node:69829) UnhandledPromiseRejectionWarning: Error: _ContentType_Post_contentExtended.cloudinaryImages refers to a non-existant field, _Block_Post_cloudinaryImage.from
    at Keystone._consolidateRelationships (/Users/firfi/work/clients/ar/ths-cms/node_modules/@keystonejs/keystone/lib/Keystone/index.js:350:13)
    at Keystone.connect (/Users/firfi/work/clients/ar/ths-cms/node_modules/@keystonejs/keystone/lib/Keystone/index.js:449:23)
    at /Users/firfi/work/clients/ar/ths-cms/server.ts:12:20
    at step (/Users/firfi/work/clients/ar/ths-cms/server.ts:33:23)
    at Object.next (/Users/firfi/work/clients/ar/ths-cms/server.ts:14:53)
    at /Users/firfi/work/clients/ar/ths-cms/server.ts:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/firfi/work/clients/ar/ths-cms/server.ts:4:12)
    at /Users/firfi/work/clients/ar/ths-cms/server.ts:48:12
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

however, if I have

 fields: {
    contentBrief: {
      type: Content,
      blocks: [],
    },
    contentExtended: {
      type: Content,
      blocks: contentBlocks,
    },
  },

or

 fields: {
    contentBrief: {
      type: Content,
      blocks: contentBlocks,
    },
    contentExtended: {
      type: Content,
      blocks: [],
    },
  },

if that matters, it all works well.

Environment

Software Version
Keystone 18
Node.js v14.12.0
Browser not applicable
OS OSX
dearlordylord commented 3 years ago

Wrong repo.