Skip to content

Latest commit

 

History

History
105 lines (72 loc) · 3.09 KB

File metadata and controls

105 lines (72 loc) · 3.09 KB

Reset List View Plugin for Payload CMS

A plugin for Payload CMS that adds a "Reset Preferences" button to collection list views, allowing users to reset their list view preferences to the default state.

Features

  • Adds a "Reset Preferences" button to the list view menu of collections
  • Allows users to quickly reset their list view preferences (columns, filters, pagination, etc.)
  • Configurable to include or exclude specific collections

Installation

npm install @shefing/reset-list-view
# or
yarn add @shefing/reset-list-view
# or
pnpm add @shefing/reset-list-view

Usage

Add the plugin to your Payload config:

import { buildConfig } from 'payload/config'
import { CollectionResetPreferencesPlugin } from '@shefing/reset-list-view'

export default buildConfig({
  plugins: [
    CollectionResetPreferencesPlugin({
      // Plugin options here
    }),
  ],
  // Rest of your Payload config
})

Configuration Options

The plugin accepts the following configuration options:

Option Type Description Default
disabled boolean Disable the plugin false
includedCollections string[] List of collection slugs to add the reset button to. If provided, only these collections will have the reset button. undefined
excludedCollections string[] List of collection slugs to exclude from having the reset button. Only used if includedCollections is not provided. undefined

Examples

Add the reset button to all collections:

CollectionResetPreferencesPlugin()

Add the reset button to specific collections:

CollectionResetPreferencesPlugin({
  includedCollections: ['posts', 'categories'],
})

Exclude specific collections from having the reset button:

CollectionResetPreferencesPlugin({
  excludedCollections: ['users', 'media'],
})

Disable the plugin:

CollectionResetPreferencesPlugin({
  disabled: true,
})

How It Works

The plugin adds a "Reset Preferences" button to the list view menu of collections. When clicked, the button makes a DELETE request to the Payload API to delete the user's preferences for that collection's list view, and then reloads the page. This resets the list view to its default state, clearing any custom column configurations, filters, pagination settings, etc.

Roadmap

See the consolidated ROADMAP.md at the repo root and the live RoadMap issues for Reset List View.

P0

  • Granular reset menu — split into Reset columns, Reset filters, Reset sort, Reset page size, Reset all.
  • Per-user default preset — admin can save a view and force it as the default for everyone.

P1

  • Named saved views per user with a quick switcher — pairs with QuickFilter saved presets.
  • Auto-reset on logout option for shared workstations.

P2

  • Admin button to bulk-reset preferences for all users (e.g., after a schema change).

License

MIT