Skip to content
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

Undo/redo through different views #1417

Merged
merged 65 commits into from
Jan 3, 2023
Merged

Conversation

apedroferreira
Copy link
Member

@apedroferreira apedroferreira commented Dec 5, 2022

Switches to the correct view on undo/redo.
Also closes #1460.

Video (undo starts at 1:36):

Screen.Recording.2022-12-20.at.13.56.17.mov

Preview URL: https://toolpad-pr-1417.onrender.com/

Summary of changes:

  • DOM state now stores current view + properties panel tab
  • Adds methods to domApi to set current view and tab. View can also be changed with domApi.update if we want 1 action to represent a DOM change + view change, for example, which was needed in some situations.
  • Uses DOM state as source of truth for current active view/tab
  • Add test for undo between pages

There's many different approaches we could use for this logic and to extend/improve it. I think this a good starting point for further changes, even if it's not the final solution.
(Also we might still be able to use DOM diffs to get the current view automatically, just starting out with something simpler)

Continuing to follow the checklist in #226
Relevant discussion reference: #1225 (comment)

@apedroferreira apedroferreira added core Infrastructure work going on behind the scenes enhancement This is not a bug, nor a new feature labels Dec 5, 2022
@apedroferreira apedroferreira self-assigned this Dec 5, 2022
.circleci/config.yml Outdated Show resolved Hide resolved
Base automatically changed from atomic-undo-redo to master December 20, 2022 09:56
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 20, 2022
@oliviertassinari oliviertassinari requested a deployment to undo-redo-with-views - toolpad-db PR #1417 December 20, 2022 12:02 — with Render Abandoned
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 20, 2022
@@ -965,83 +955,138 @@ export default function RenderOverlay({ canvasHostRef }: RenderOverlayProps) {
const isDraggingOverLayoutSlot = dragOverSlot?.type === 'layout';
const isDraggingOverElement = appDom.isElement(dragOverNode);

domApi.update((draft) => {
let parent = appDom.getParent(draft, dragOverNode);
domApi.update(
Copy link
Member Author

@apedroferreira apedroferreira Dec 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all just formatting changes except the second argument passed to domApi.update (which caused the reformatting). Maybe I should extract this nested function...

@oliviertassinari oliviertassinari temporarily deployed to undo-redo-with-views - toolpad PR #1417 December 20, 2022 19:01 — with Render Destroyed
Copy link
Member

@bharatkashyap bharatkashyap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great effort!

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Dec 21, 2022
@oliviertassinari oliviertassinari requested a deployment to undo-redo-with-views - toolpad-db PR #1417 January 2, 2023 14:13 — with Render Abandoned
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jan 2, 2023
@oliviertassinari oliviertassinari temporarily deployed to undo-redo-with-views - toolpad PR #1417 January 2, 2023 14:15 — with Render Destroyed
@apedroferreira
Copy link
Member Author

This should be good to merge, will merge soon if there's no more feedback.
I was fixing some bugs before the break, it seems good from what I've tested now, if there's any more bugs we should find them later.

@apedroferreira apedroferreira merged commit 4f4f4f1 into master Jan 3, 2023
@apedroferreira apedroferreira deleted the undo-redo-with-views branch January 3, 2023 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A small doubt
4 participants