Reset List View Preferences
npm install @shefing/reset-list-viewA 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.
- 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
``bash`
npm install @shefing/reset-list-viewor
yarn add @shefing/reset-list-viewor
pnpm add @shefing/reset-list-view
Add the plugin to your Payload config:
`typescript
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
})
`
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 |
Add the reset button to all collections:
`typescript`
CollectionResetPreferencesPlugin()
Add the reset button to specific collections:
`typescript`
CollectionResetPreferencesPlugin({
includedCollections: ['posts', 'categories'],
})
Exclude specific collections from having the reset button:
`typescript`
CollectionResetPreferencesPlugin({
excludedCollections: ['users', 'media'],
})
Disable the plugin:
`typescript``
CollectionResetPreferencesPlugin({
disabled: true,
})
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.
MIT