-
Notifications
You must be signed in to change notification settings - Fork 508
[CB] Improve undo/redo behavior for Data Editor #4060
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
base: devel
Are you sure you want to change the base?
[CB] Improve undo/redo behavior for Data Editor #4060
Conversation
webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridEditAction.ts
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridEditAction.ts
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridEditAction.ts
Outdated
Show resolved
Hide resolved
| if (isSameKey) { | ||
| this.history.update(lastIndex, { | ||
| data: { | ||
| key, | ||
| value, | ||
| prevValue, | ||
| }, | ||
| }); | ||
|
|
||
| return; | ||
| } |
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.
not sure about this, because you might change same cell few times with a delay and when you will revert it you will expect that it will revert to previous edit
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.
Now I compress everything to 1 history item unless we are currently editing the cell. If we're editing the cell right now, it remembers each typed letter. Then, if we type something in another cell, it compresses all of the history for previous cells to 1 item by cell
webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridHistoryAction.ts
Outdated
Show resolved
Hide resolved
webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridHistoryAction.ts
Outdated
Show resolved
Hide resolved
| type IGridEditHistoryData<TKey extends IGridDataKey = IGridDataKey, TCell = unknown> = { | ||
| key: TKey; | ||
| value: TCell; | ||
| prevValue: TCell; | ||
| }; |
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.
please use interface for consistency in codebase
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.
Pull request overview
This pull request implements comprehensive undo/redo functionality for the Data Editor in CloudBeaver. The implementation introduces a history tracking system that records all editing operations (cell edits, row additions/deletions, duplications, reverts, and cancellations) and allows users to undo and redo these operations using keyboard shortcuts (Ctrl+Z for undo, Ctrl+Shift+Z or Ctrl+Y for redo).
Changes:
- Introduced a new history management system with GridHistoryAction, GridHistoryTypes, GridHistoryHandlers, and GridEditHistoryManager classes
- Integrated history tracking into GridEditAction and ResultSetEditAction to record all editing operations
- Added keyboard bindings and UI integration for undo/redo actions in the data viewer
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| webapp/packages/plugin-help/src/Shortcuts/SHORTCUTS_DATA.ts | Added undo/redo shortcuts to the help documentation |
| webapp/packages/plugin-data-viewer/src/module.ts | Registered GridHistoryAction in the dependency injection container |
| webapp/packages/plugin-data-viewer/src/TableViewer/TableFooter/TableFooterMenu/TableFooterMenuService.ts | Added undo/redo key bindings, action handlers, and menu integration |
| webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/ResultSet/ResultSetEditAction.ts | Integrated GridHistoryAction into ResultSetEditAction constructor |
| webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridHistoryTypes.ts | Defined type structures for different history entry types and type guard functions |
| webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridHistoryHandlers.ts | Implemented undo/redo handlers for each operation type |
| webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridHistoryAction.ts | Core history action class with undo/redo stack management and compression support |
| webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridEditHistoryManager.ts | Manager class that coordinates history recording with editor operations |
| webapp/packages/plugin-data-viewer/src/DatabaseDataModel/Actions/Grid/GridEditAction.ts | Integrated history tracking into all editing operations and added internal methods for undo/redo |
| webapp/packages/plugin-data-viewer/src/DATA_VIEWER_KEY_BINDINGS.ts | Defined key binding configurations for data viewer undo/redo |
| webapp/packages/core-utils/src/isNumber.ts | Improved type guard to enable proper type narrowing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
closes dbeaver/pro#7614