Skip to content

fix: import modal logic#6409

Merged
bijin-bruno merged 1 commit intousebruno:mainfrom
naman-bruno:bugfix/import-modal
Dec 15, 2025
Merged

fix: import modal logic#6409
bijin-bruno merged 1 commit intousebruno:mainfrom
naman-bruno:bugfix/import-modal

Conversation

@naman-bruno
Copy link
Collaborator

@naman-bruno naman-bruno commented Dec 15, 2025

Description

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • Refactor
    • Unified collection import workflow with a consolidated import location dialog, ensuring consistent behavior across all workspace configurations and simplifying the import process for users.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 15, 2025

Walkthrough

The PR consolidates collection import flows across multiple sidebar and workspace components by introducing a unified ImportCollectionLocation modal. It removes direct workspace-specific import paths, unifying how imports are handled regardless of context, and adds dynamic default collection location derivation from Redux state.

Changes

Cohort / File(s) Summary
Import Location Modal Enhancement
packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js
Added runtime derivation of default collection location from Redux state (workspaces, activeWorkspaceUid). Replaced static empty string with dynamic defaultLocation that respects default vs. active workspace contexts.
Unified Import Flow
packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js, packages/bruno-app/src/components/Sidebar/SidebarHeader/index.js, packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/index.js
Consolidated collection import handlers to use unified ImportCollectionLocation modal flow. Removed conditional logic for direct workspace-specific imports (importCollectionInWorkspace). All imports now follow a two-step pattern: store data → open modal → handle location selection.

Sequence Diagram

sequenceDiagram
    participant User
    participant Component as Import Handler<br/>(CollectionsSection/SidebarHeader/<br/>WorkspaceOverview)
    participant Modal as ImportCollectionLocation<br/>Modal
    participant Redux as Redux Store<br/>(Workspace/Collections)
    participant Action as Collection Actions

    User->>Component: Trigger import
    Component->>Modal: Store importData, open modal
    activate Modal
    Note over Modal: Derive defaultLocation from Redux<br/>(activeWorkspace, preferences)
    Modal->>User: Display location picker
    User->>Modal: Select location
    deactivate Modal
    Modal->>Action: Dispatch importCollection(data, location)
    Action->>Redux: Process import with location
    Redux-->>Component: Success/Error response
    Component->>User: Show toast (success/error)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focus areas:
    • Redux selector logic in ImportCollectionLocation for determining correct default location based on workspace context
    • Two-step import flow implementation consistency across three handler components
    • State management for importCollectionLocationModalOpen and importData in WorkspaceOverview
    • Verification that importCollectionInWorkspace removal doesn't break existing workspace-aware import behavior

Possibly related PRs

  • init: workspaces #6264: Initializes workspace infrastructure that this PR depends on for workspace-aware collection import flows and state derivation.

Suggested reviewers

  • lohit-bruno
  • bijin-bruno
  • helloanoop

Poem

📦 Import flows once fractured, now unified and whole,
Modal opens gently, guiding collections to their goal.
Redux reads the workspace, knows the path so true—
One flow to rule them all, from SideBar through to View.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: import modal logic' is vague and generic, using non-descriptive terms that don't clarify what aspect of import modal logic was fixed or what the core change accomplishes. Consider a more specific title that describes the actual change, such as 'refactor: unify collection import flow with location selection modal' or 'fix: consolidate workspace import logic into shared modal'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/bruno-app/src/components/Sidebar/SidebarHeader/index.js (1)

51-55: Unified import flow looks good; consider clearing importData on modal close

The new pattern of closing the first modal, storing { rawData, type }, and opening ImportCollectionLocation is consistent with the rest of the app and keeps the import pipeline centralized.

One small cleanup: onClose for ImportCollectionLocation only flips importCollectionLocationModalOpen and leaves importData set. It’s harmless (the modal condition checks both), but clearing importData on close would avoid stale state hanging around and more closely model “cancel” as abandoning the import.

For example:

-      {importCollectionLocationModalOpen && importData && (
+      {importCollectionLocationModalOpen && importData && (
         <ImportCollectionLocation
           rawData={importData.rawData}
           format={importData.type}
-          onClose={() => setImportCollectionLocationModalOpen(false)}
+          onClose={() => {
+            setImportCollectionLocationModalOpen(false);
+            setImportData(null);
+          }}
           handleSubmit={handleImportCollectionLocation}
         />
       )}

Also applies to: 156-162

packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/index.js (1)

4-9: Import flow is correctly centralized; consider reusing logic and harmonizing errors

The new 2‑step import flow here (store { rawData, type }, open ImportCollectionLocation, then dispatch importCollection with the converted data and chosen location) matches the sidebar components and looks functionally correct. State cleanup on success (setImportCollectionLocationModalOpen(false) + setImportData(null)) is also spot on.

Two small follow‑ups you might consider:

  1. Shared import helper
    The pattern (importData state + ImportCollection + ImportCollectionLocation + handleImportCollectionLocation) is now duplicated across SidebarHeader, CollectionsSection, and WorkspaceOverview. Extracting a small hook or helper could reduce repetition and keep future changes to the import pipeline in one place.

  2. Consistent error messaging
    Here you toast err.message, while the sidebar flows use a generic 'An error occurred while importing the collection'. Aligning on one approach (generic message + console log, or a safe parsed message) would give a more consistent UX.

Also applies to: 19-21, 53-70, 85-92

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c11266a and aab3392.

📒 Files selected for processing (4)
  • packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js (2 hunks)
  • packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js (1 hunks)
  • packages/bruno-app/src/components/Sidebar/SidebarHeader/index.js (1 hunks)
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/index.js (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (CODING_STANDARDS.md)

**/*.{js,jsx,ts,tsx}: Use 2 spaces for indentation. No tabs, just spaces
Stick to single quotes for strings. For JSX/TSX attributes, use double quotes (e.g., )
Always add semicolons at the end of statements
No trailing commas
Always use parentheses around parameters in arrow functions, even for single params
For multiline constructs, put opening braces on the same line, and ensure consistency. Minimum 2 elements for multiline
No newlines inside function parentheses
Space before and after the arrow in arrow functions. () => {} is good
No space between function name and parentheses. func() not func ()
Semicolons go at the end of the line, not on a new line
Names for functions need to be concise and descriptive
Add in JSDoc comments to add more details to the abstractions if needed
Add in meaningful comments instead of obvious ones where complex code flow is explained properly

Files:

  • packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js
  • packages/bruno-app/src/components/Sidebar/SidebarHeader/index.js
  • packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/index.js
  • packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: CLI Tests
  • GitHub Check: Playwright E2E Tests
  • GitHub Check: Unit Tests
  • GitHub Check: SSL Tests - Linux
  • GitHub Check: SSL Tests - macOS
  • GitHub Check: SSL Tests - Windows
🔇 Additional comments (2)
packages/bruno-app/src/components/Sidebar/Sections/CollectionsSection/index.js (1)

45-49: Import flow wiring is consistent and correct

Closing the initial import modal, storing { rawData, type } in importData, and then opening ImportCollectionLocation matches the SidebarHeader flow and keeps behavior consistent across entry points. The guard importCollectionLocationModalOpen && importData also prevents rendering with incomplete state.

Also applies to: 226-232

packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js (1)

2-6: Default collection location logic looks solid; please QA across workspace scenarios

The new logic to derive defaultLocation from Redux state is reasonable:

  • Default workspace → falls back to preferences.general.defaultCollectionLocation (via get, so it’s safe if preferences is missing).
  • Non‑default workspace → uses ${activeWorkspace.pathname}/collections when available, otherwise empty string.
  • Formik now seeds collectionLocation with this computed value, which should address inconsistencies between default vs workspace‑specific imports.

Given this is now the single source for all import entry points, it’s worth a quick QA pass to confirm:

  • Default workspace with and without a configured defaultCollectionLocation
  • Non‑default workspace with valid pathname
  • Edge case where the active workspace changes while the modal is open

Also applies to: 92-100, 103-107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants