-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: Handle notebook conflicts #16352
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
frontend/src/scenes/notebooks/Notebook/NotebookConflictWarning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useActions } from 'kea' | ||
import { LemonButton } from 'lib/lemon-ui/LemonButton' | ||
import { notebookLogic } from './notebookLogic' | ||
|
||
export function NotebookConflictWarning(): JSX.Element { | ||
const { loadNotebook } = useActions(notebookLogic) | ||
|
||
return ( | ||
<div className="flex flex-col items-center text-muted-alt m-10"> | ||
<h2 className="text-muted-alt">This Notebook has been edited elsewhere</h2> | ||
|
||
<p> | ||
It looks like someone else has been editing this content too. You will need to reload the notebook to | ||
see the latest version. | ||
</p> | ||
|
||
<LemonButton type="primary" onClick={loadNotebook}> | ||
Reload to see the latest content | ||
</LemonButton> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not super familiar with Django but it seemed necessary to me that the instance needed to be loaded with
select_for_update
to lock the table row as part of the transaction. Is there a cleaner way to override theinstance
lookup within the serializer so maybe I don't need to load it a second time?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.
I don't know is my answer here :D
A quick google showed me that you can mark an entire view as atomic with a decorator . No idea if that would work here but worth a try? That way the entire call is in a transaction?
Not sure how that plays into what you say about needing to use
select_for_update
though...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.
Checked it out and the decorator didn't break anything but I also couldn't see an easy way of testing and handling the 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.
I like that
Notebook.objects.select_for_update()
is super explicit though. makes me happy we're not having to rely on some dark magic