Skip to content

feat(data-modeling): show previous edits when opening the diagram COMPASS-9544 #7106

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mabaasit
Copy link
Contributor

Description

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@Copilot Copilot AI review requested due to automatic review settings July 11, 2025 13:11
@mabaasit mabaasit requested a review from a team as a code owner July 11, 2025 13:11
@github-actions github-actions bot added the feat label Jul 11, 2025
@mabaasit mabaasit added feature flagged PRs labeled with this label will not be included in the release notes of the next release no release notes Fix or feature not for release notes labels Jul 11, 2025
Copy link

@Copilot Copilot AI left a 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 PR implements functionality to preserve edit history when opening existing data modeling diagrams, allowing users to undo previous changes made before the current session. The change ensures that when a diagram is reopened, the undo/redo functionality works with the complete edit history rather than starting fresh.

Key changes:

  • Modifies the diagram reducer to preserve edit history when opening saved diagrams
  • Adds comprehensive E2E test coverage for the undo functionality after reopening diagrams

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/compass-data-modeling/src/store/diagram.ts Updates the OPEN_DIAGRAM action to reconstruct the edit history from saved edits
packages/compass-e2e-tests/tests/data-modeling-tab.test.ts Adds E2E test to verify undo functionality works after reopening a diagram
Comments suppressed due to low confidence (1)

packages/compass-data-modeling/src/store/diagram.ts:98

  • The variable name '_item' indicates an unused parameter. Consider using a more descriptive name like 'edit' or simply omit the parameter name since it's not used.
    const prev = current.map((_item, index, arr) => arr.slice(0, index + 1));

@@ -94,11 +94,14 @@ export const diagramReducer: Reducer<DiagramState> = (
action
) => {
if (isAction(action, DiagramActionTypes.OPEN_DIAGRAM)) {
const current = action.diagram.edits;
Copy link
Preview

Copilot AI Jul 11, 2025

Choose a reason for hiding this comment

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

This logic creates an array of progressively longer slices but could be clearer. Consider adding a comment explaining that this reconstructs the edit history states for undo functionality.

Suggested change
const current = action.diagram.edits;
const current = action.diagram.edits;
// Reconstruct the edit history states for undo functionality by creating an array of progressively longer slices of the `current` edits array.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat feature flagged PRs labeled with this label will not be included in the release notes of the next release no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant