-
Notifications
You must be signed in to change notification settings - Fork 3k
feat: adds the ability to lock documents while they are being edited #7970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
…t/beta/locked-document
} | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error('Failed to unlock the document', error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we have a toast.error?
} | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error('Failed to update the document editor', error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here also, toast?
} | ||
|
||
return result | ||
if (returnLockStatus && req.user && (id || globalSlug)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there also be another condition in the if condition to prevent this block when locking isn't enabled for the collection/global?
} | ||
} | ||
|
||
if (lockedDocumentQuery) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should really be it's own function that returns the lockStatus. Can always refactor later.
🚀 This is included in version v3.0.0-beta.108 |
Just my 2 cents. I am wondering why you didnt opt for optimistic locking which is far more scalable and less problematic on the database. |
Description
Adds a new property to
collection
/global
configs calledlockDocuments
.Set to
true
by default - the lock is automatically triggered when a user begins editing a document within the Admin Panel and remains in place until the user exits the editing view or the lock expires due to inactivity.Set to
false
to disable document locking entirely - i.e.lockDocuments: false
You can pass an object to this property to configure the
duration
in seconds, which defines how long the document remains locked without user interaction. If no edits are made within the specified time (default: 300 seconds), the lock expires, allowing other users to edit / update or delete the document.Type of change
Checklist: