Like what we’re doing? Star us on GitHub!

Versions not showing/being listed

DavidOliver
3 months ago
2 2

I'm running Payload 1.2.3. 1.2.4 in Ubuntu 18.04.6 LTS, Node 16.18.1, with a local install of MongoDB 6.0.3.

I've enabled versions on a collection, and see '5 versions found' in the sidebar in the admin. When I click through to the versions listing, the pagination says '1-4 of 4', but no versions are listed.

I'm logged in with the initial admin user created as part of setup.

Members.ts:

import { CollectionConfig } from 'payload/types';

const Members: CollectionConfig = {
  slug: 'members',
  auth: true,
  admin: {
    useAsTitle: 'email',
    defaultColumns: ['nameFirst', 'nameLast', 'jobTitle', 'department'],
    disableDuplicate: true,
    listSearchableFields: ['nameFirst', 'nameLast'],
  },
  access: {
    create: () => true,
    read: () => true,
    update: () => true,
    delete: () => true,
    readVersions: () => true,
  },
  versions: true,
  fields: [
    {
      type: 'row',
      fields: [
        {
          name: 'nameFirst',
          type: 'text',
          label: 'First name',
          index: true,
          required: true,
        },
        {
          name: 'nameLast',
          type: 'text',
          label: 'Last name',
          index: true,
          required: true,
        },
      ],
    },
    {
      type: 'row',
      fields: [
        {
          name: 'jobTitle',
          type: 'text',
        },
        {
          name: 'department',
          type: 'text',
        },
      ]
    },
  ],
};

export default Members;

payload.config.ts:

import { buildConfig } from 'payload/config';
import path from 'path';
import Members from './collections/Members';
import Users from './collections/Users';

export default buildConfig({
  serverURL: 'http://localhost:3000',
  csrf: [
    'http://localhost:4000',
  ],
  admin: {
    user: Users.slug,
  },
  collections: [
    Members,
    Users,
  ],
  typescript: {
    outputFile: path.resolve(__dirname, 'payload-types.ts'),
  },
  graphQL: {
    schemaOutputFile: path.resolve(__dirname, 'generated-schema.graphql'),
  },
});

Am I doing something wrong?

Thanks!

Update

I have the same issue with a simpler collection:

import { CollectionConfig } from 'payload/types';

const Organisations: CollectionConfig = {
  slug: 'organisations',
  admin: {
    useAsTitle: 'name',
    defaultColumns: ['name'],
    disableDuplicate: true,
    listSearchableFields: ['name'],
  },
  versions: true,
  fields: [
    {
      type: 'row',
      fields: [
        {
          name: 'name',
          type: 'text',
          label: 'Name',
          index: true,
          required: true,
        },
      ],
    },
  ],
};

export default Organisations;
  • kalon-robson
    3 months ago

    Hi @DavidOliver, I've been able to recreate the problem. It appears limit is set to 0 by default on the request to the Api made by Payload.

    Request: GET /api/draft-posts/versions?locale=en&depth=1&where%5Bparent%5D%5Bequals%5D=638e620497a5b55f0214a1b2 HTTP/1.1

    Response: {"docs":[],"totalDocs":11,"limit":0,"totalPages":1,"page":1,"pagingCounter":1,"hasPrevPage":false,"hasNextPage":false,"prevPage":null,"nextPage":null}

    If you change the pagination limit "Per page: 10" or append ?limit=10 you should see it working.

    I'm going to open an issue off the back of your discussion for the Payload team to look at.

    2 replies
  • DavidOliver
    3 months ago

    Aha! Thanks for the info.

  • JarrodMFlesch
    Payload Team
    3 months ago

    Hey guys, no need to open an issue. I merged the fix for that this morning when I noticed it. It will land in the next release (soon) 👍

    #1589

  • kalon-robson
    3 months ago

    @DavidOliver There has been a commit earlier today that resolves the issue commit #dd04d78

Open the post
Continue the discussion in GitHub
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More