How to use the netlify-cms-lib-util.Cursor.create function in netlify-cms-lib-util

To help you get started, we’ve selected a few netlify-cms-lib-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github netlify / netlify-cms / packages / netlify-cms-core / src / actions / entries.ts View on Github external
.then((response: { cursor: typeof Cursor }) => ({
        ...response,

        // The only existing backend using the pagination system is the
        // Algolia integration, which is also the only integration used
        // to list entries. Thus, this checking for an integration can
        // determine whether or not this is using the old integer-based
        // pagination API. Other backends will simply store an empty
        // cursor, which behaves identically to no cursor at all.
        cursor: integration
          ? Cursor.create({
              actions: ['next'],
              meta: { usingOldPaginationAPI: true },
              data: { nextPage: page + 1 },
            })
          : Cursor.create(response.cursor),
      }))
      .then((response: { cursor: typeof Cursor; pagination: number; entries: EntryValue[] }) =>
github netlify / netlify-cms / packages / netlify-cms-core / src / actions / entries.ts View on Github external
export function entriesLoaded(
  collection: Collection,
  entries: EntryValue[],
  pagination: number | null,
  cursor: typeof Cursor,
  append = true,
) {
  return {
    type: ENTRIES_SUCCESS,
    payload: {
      collection: collection.get('name'),
      entries,
      page: pagination,
      cursor: Cursor.create(cursor),
      append,
    },
  };
}
github netlify / netlify-cms / packages / netlify-cms-core / src / components / Collection / Entries / EntriesSearch.js View on Github external
getCursor = () => {
    const { page } = this.props;
    return Cursor.create({
      actions: isNaN(page) ? [] : ['append_next'],
    });
  };
github netlify / netlify-cms / packages / netlify-cms-core / src / components / Collection / Entries / EntryListing.js View on Github external
hasMore = () => {
    return Cursor.create(this.props.cursor).actions.has('append_next');
  };
github netlify / netlify-cms / packages / netlify-cms-backend-bitbucket / src / API.js View on Github external
getEntriesAndCursor = jsonResponse => {
    const {
      size: count,
      page: index,
      pagelen: pageSize,
      next,
      previous: prev,
      values: entries,
    } = jsonResponse;
    const pageCount = pageSize && count ? Math.ceil(count / pageSize) : undefined;
    return {
      entries,
      cursor: Cursor.create({
        actions: [...(next ? ['next'] : []), ...(prev ? ['prev'] : [])],
        meta: { index, count, pageSize, pageCount },
        data: { links: { next, prev } },
      }),
    };
  };
github netlify / netlify-cms / packages / netlify-cms-core / src / reducers / cursors.js View on Github external
const cursors = (state = fromJS({ cursorsByType: { collectionEntries: {} } }), action) => {
  switch (action.type) {
    case ENTRIES_SUCCESS: {
      return state.setIn(
        ['cursorsByType', 'collectionEntries', action.payload.collection],
        Cursor.create(action.payload.cursor).store,
      );
    }

    default:
      return state;
  }
};
github netlify / netlify-cms / packages / netlify-cms-core / src / actions / entries.ts View on Github external
const addAppendActionsToCursor = (cursor: typeof Cursor) => {
  return Cursor.create(cursor).updateStore('actions', (actions: Set) => {
    return actions.union(
      appendActions
        .filter((v: Map) => actions.has(v.get('action') as string))
        .keySeq(),
    );
  });
};
github netlify / netlify-cms / packages / netlify-cms-core / src / backend.ts View on Github external
.then(async ({ entries, cursor: newCursor }) => ({
        entries: this.processEntries(entries, collection),
        cursor: Cursor.create(newCursor).wrapData({
          cursorType: 'collectionEntries',
          collection,
        }),
      }));
  }