Skip to content

Commit

Permalink
Merge pull request #105 from notum-cz/feat/strapi-v5-migration
Browse files Browse the repository at this point in the history
feat: migrate to V5, bump version to 2.0.0
  • Loading branch information
dominik-juriga authored Oct 8, 2024
2 parents 21781f0 + 555d6c5 commit b096efe
Show file tree
Hide file tree
Showing 59 changed files with 11,791 additions and 18,000 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,*.yml}]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
13 changes: 6 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: "weekly"
interval: 'weekly'
versioning-strategy: increase
assignees:
- "omikulcik"
- 'dominik-juriga'
commit-message:
include: scope
prefix: "chore:"
prefix: 'chore:'
labels:
- "pr: chore"

- 'pr: chore'
138 changes: 137 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,138 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

############################
# OS X
############################

.DS_Store
.AppleDouble
.LSOverride
Icon
.Spotlight-V100
.Trashes
._*


############################
# Linux
############################

*~


############################
# Windows
############################

Thumbs.db
ehthumbs.db
Desktop.ini
$RECYCLE.BIN/
*.cab
*.msi
*.msm
*.msp


############################
# Packages
############################

*.7z
*.csv
*.dat
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
*.com
*.class
*.dll
*.exe
*.o
*.seed
*.so
*.swo
*.swp
*.swn
*.swm
*.out
*.pid


############################
# Logs and databases
############################

.tmp
*.log
*.sql
*.sqlite
*.sqlite3


############################
# Misc.
############################

*#
ssl
.idea
nbproject
.tsbuildinfo
.eslintcache
.env


############################
# Strapi
############################

public/uploads/*
!public/uploads/.gitkeep


############################
# Build
############################

dist
build


############################
# Node.js
############################

lib-cov
lcov.info
pids
logs
results
node_modules
yarn.lock
.node_history


############################
# Package managers
############################

.yarn/*
!.yarn/cache
!.yarn/unplugged
!.yarn/patches
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.pnp.*
yarn-error.log


############################
# Tests
############################

coverage
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
coverage
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"endOfLine": "lf",
"tabWidth": 2,
"printWidth": 100,
"singleQuote": true,
"trailingComma": "es5"
}
55 changes: 39 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,79 @@
# Strapi plugin record-locking

This plugin provides the functionality to prevent data loss in cases where multiple users are simultaneously editing the same record within STRAPI v4.
This plugin provides the functionality to prevent data loss in cases where multiple users are simultaneously editing the same record within STRAPI v5.

**When a user attempts to edit a record that is already being edited, a warning will be displayed.**

![Record Locking Plugin Example](./record-locking.png)

## ⚠️ We've released version 2.0.0 for the Record Locking Plugin.

Plugin version 2.x is aimed at Strapi V5. If you need support for Strapi V4, please follow the 1.x releases. What's new:

- TypeScript rewrite.
- Overall code refactor to make it safer & more readable.
- Strapi V5 support.
- Records are now matched based on `document_id` attribute.

### Migration from 1.x to 2.x

Since the plugin does not retain any data, we're not providing migration scripts for the database. Strapi should update the columns automatically, however if this does not happen, you can update the columns manually when migrating to Strapi V5:

- column `entityType` has been renamed to `entityId`
- column `entityIdentifier` has been renamed to `entityDocumentId`

## 🙉 What does the plugin do for you?

✅ Safeguards against concurrent editing by restricting access to a record to a single user at a time.

✅ Provides clear visibility of the current editing user, enabling you to easily identify who is working on the record.
## 🧑‍💻 Installation

### 1. Install the plugin with your favourite package manager:
## 🧑‍💻 Installation

### 1. Install the plugin with your favourite package manager:

```
npm i @notum-cz/strapi-plugin-record-locking
```

```
yarn add @notum-cz/strapi-plugin-record-locking
```

### 2. Create or modify file `config/plugins.js` and include the following code snippet:

```js
module.exports = ({ env }) => ({
"record-locking": {
'record-locking': {
enabled: true,
},
});
```

We use websockets and you can determine the necessary transport yourself:

```js
module.exports = ({ env }) => ({
"record-locking": {
enabled: true,
config: {
transports: ["websocket"]
}
'record-locking': {
enabled: true,
config: {
transports: ['websocket'],
},
},
});
```

If you do not specify a transport, the default parameters will be applied:

```js
DEFAULT_TRANSPORTS: ["polling", "websocket", "webtransport"]
DEFAULT_TRANSPORTS: ['polling', 'websocket', 'webtransport'];
```


### 3. Enable websocket support by configuring the Strapi middleware.

In the `config/middlewares.js` file either replace `'strapi::security'` with a middleware object (see the example below) or update your existing configuration accordingly.
1. Ensure that `contentSecurityPolicy.directives.connect-src` array includes `"ws:"` and `"wss:"`.
In the `config/middlewares.js` file either replace `'strapi::security'` with a middleware object (see the example below) or update your existing configuration accordingly.

1. Ensure that `contentSecurityPolicy.directives.connect-src` array includes `"ws:"` and `"wss:"`.
2. Rebuild Strapi and test record locking features.
3. You should not encounter any `Content Security Policy` errors in the console.

Expand All @@ -78,18 +100,19 @@ module.exports = [
},
'strapi::cors', ...
```

> While optional, it is highly **recommended** to implement this step to prevent Socket.io from falling back to the HTTP protocol and generating the following error in the web console.
`Refused to connect to <protocol>://<url> because it does not appear in the connect-src directive of the Content Security Policy`
> `Refused to connect to <protocol>://<url> because it does not appear in the connect-src directive of the Content Security Policy`
---

## 🛣️ Road map

Are any of these features significant to you? Please show your support by giving a thumbs up on the linked issues. This will help us assess their priority on the roadmap.

-[An option to select specific collection types](https://github.com/notum-cz/strapi-plugin-record-locking/issues/46)
-["Takeover" button](https://github.com/notum-cz/strapi-plugin-record-locking/issues/47)


## 🐛 Bugs

We manage bugs through [GitHub Issues](https://github.com/notum-cz/strapi-plugin-record-locking/issues). <br>
Expand All @@ -104,7 +127,7 @@ Project owner: **Ondřej Janošík** <br>

## 💬 Community

Join our [Discord server](https://discord.gg/hZRCcfWq) to discuss new features, implementation challenges or anything related to this plugin.
Join our [Discord server](https://discord.gg/hZRCcfWq) to discuss new features, implementation challenges or anything related to this plugin.

### 🚀 Created with passion by [Notum Technologies](https://notum.cz/en)

Expand Down
2 changes: 2 additions & 0 deletions admin/custom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module '@strapi/design-system/*';
declare module '@strapi/design-system';
Loading

0 comments on commit b096efe

Please sign in to comment.