Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

strapi-plugin-do-not-delete

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strapi-plugin-do-not-delete

A plugin for Strapi CMS that protects certain entries from being deleted.

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source
Logo for Strapi do not delete plugin

Strapi "Do Not Delete"

A plugin for Strapi CMS that protects certain entries from being deleted.

Screenshot for Strapi do not delete plugin

Get Started

  • Features
  • Installation
  • Configuration
  • User Guide
  • Troubleshooting
  • Support or Donate
  • Roadmap

✨ Features

  • Protect certain entries from being deleted.
  • Use various comparators to match against protection rules.

💎 Installation

yarn add strapi-plugin-do-not-delete@latest

Don't forget to restart or rebuild your Strapi app when installing a new plugin.

🔧 Configuration

propertytype (default)description
contentTypesobject (null)A config object that describes protection rules for content types.

contentTypes

A config object that describes protection rules for content types using the model UID and an array of comparators.

The object keys for contentTypes should be a valid model UID and the value should be an array or arrays which describe the comparison rules.

Example

Below, the comparison rule is querying if the slug value for Page is equal to home, and if this condition is true, the delete operation is cancelled.

// ./config/plugins.js`
'use strict';

module.exports = {
  'do-not-delete': {
    config: {
      contentTypes: {
        'api::page.page': [
          ['slug', 'is', 'home'],
        ],
      },
    },
  },
};
Comparators

The items in each comparison array must follow the format:

['attribute', 'comparator', 'value or pattern']
ComparatorDescription
isStrict equality with ===
isNotStrict inequality with !==
inDoes the value array include attribute?
notInDoes the value array not include attribute?
hasDoes the attribute contain value?
hasNotDoes the attribute not contain value?
ltIs attribute less than value?
lteIs attribute less than or equal to value?
gtIs attribute greater than value?
gteIs attribute greater than or equal to value?
betweenDoes attribute fall between the pair of values?
afterDoes attribute occur after the value date?
beforeDoes attribute occur before the value date?
dayDoes attribute occur on the same day of the value date?
monthDoes attribute occur in the same month of the value date?
yearDoes attribute occur in the same year of the value date?
matchesRegExp test against pattern (do not include outer slashes)
// ./config/plugins.js`
'use strict';

module.exports = {
  'do-not-delete': {
    config: {
      contentTypes: {
        'api::page.page': [
          // Equality.
          ['slug', 'is', 'home'],
          ['slug', 'isNot', 'test'],

          // Contains.
          ['slug', 'in', ['home', 'blog', '404']],
          ['slug', 'notIn', ['test', 'temp']],
          ['slug', 'has', 'admin'],
          ['slug', 'hasNot', '-test'],

          // Regular expression.
          ['slug', 'matches', '^foobar'], // same as "starts with"
          ['slug', 'matches', 'foobar$'], // same as "ends with"

          // Greater than or equal to.
          ['rating', 'lt', 10],
          ['rating', 'lte', 9],
          ['rating', 'gt', 4],
          ['rating', 'gte', 5],
          ['rating', 'between', [3, 6]],

          // Dates (any valid date string format can be used).
          ['publishedAt', 'after', '2022-12-31'],
          ['publishedAt', 'before', '2020-01-01T00:00:00.000Z'],
          ['publishedAt', 'day', 'Wed, 01 Jan 2020 00:00:00 GMT'],
          ['publishedAt', 'month', 'January 2020'],
          ['publishedAt', 'year', '2023'],
        ],
      },
    },
  },
};

📘 User Guide

Attempting to delete a protected entry

When attempting to delete a protected entry, a validation error will display at the top of the screen that reads:

This protected entry cannot be deleted.

Deleting an entry that is currently protected

If you find yourself in a scenario where a protected entry actually does need to be deleted, you must first update the plugin config to remove the protection rule that applies to that entry.

💩 Troubleshooting

In general

Remember to rebuild your app after making changes to some config or other code.

yarn build
# OR
yarn develop

❤️ Support or Donate

If you are enjoying this plugin and feel extra appreciative, you can buy me a beer or 3 🍺🍺🍺.

🚧 Roadmap

  • Settings page to visually manage protected entries and their applicable rules.
  • Edit view sidebar button to "lock" an entity based on it's id.
  • RBAC features.
  • Custom validation error messages.

Keywords

FAQs

Package last updated on 09 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc