Skip to content

[FIX] Show leave confirmation and prevent redundant requests when navigating away from in-progress function creation#3729

Open
amit-noy wants to merge 11 commits into
mlrun:feature/ig4from
amit-noy:ORIS-2556
Open

[FIX] Show leave confirmation and prevent redundant requests when navigating away from in-progress function creation#3729
amit-noy wants to merge 11 commits into
mlrun:feature/ig4from
amit-noy:ORIS-2556

Conversation

@amit-noy

@amit-noy amit-noy commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

📝 Description

when navigating away from an in-progress (unsaved) function creation page via the sidebar or breadcrumbs, the "Leave without deploying?" confirmation dialog was not shown. As a side effect, the function page was unmounting and remounting, causing the functions list request and the function name validation request to fire redundantly.

Root cause: igz4-nuclio, mlrun-ui, and igz4-ui each had their own RouterProvider and browser history instance. Three routers were competing over window.history, so Nuclio's useBlocker was firing on the wrong router - the leave dialog never appeared on browser back, and navigations from the host's sidebar/breadcrumbs bypassed the blocker entirely.

Fix: Share react-router-dom as a singleton across all apps. Since React Router throws when two providers share the same history, mlrun-ui uses useInRouterContext() to detect if it's embedded inside igz4-ui and renders <Routes> instead of a full RouterProvider in that case - plugging its route tree directly into the host's existing router context so all navigation is handled by a single history instance.


🛠️ Changes Made

  • vite.config.mjs - share react-router-dom as a singleton so all federated apps use one history instance
  • App.jsx - detect embedded mode via useInRouterContext(); render <Routes> instead of RouterProvider when hosted inside igz4-ui; stabilize router instance with useRef
  • RemoteNuclioRouteWrapper.jsx - register window.__igzLeaveGuard.onBlock to close the sidebar when Nuclio blocks a navigation; remove the synthetic popstate dispatch that was causing duplicate requests
  • HostLeaveGuard - deleted; Nuclio's own useBlocker now handles all navigation types including browser back/forward

✅ Checklist

  • I have given the PR a well-structured title describing the domain and the specific change that was made
  • I tested the changes in the browser (locally or via preview build)
  • I confirmed that existing tests pass
  • I added or updated unit / integration tests (if needed)
  • I checked that this change doesn’t introduce new console warnings or lint / formatting errors
  • I updated the relevant Jira ticket with the appropriate details and status

🔗 References


🚨 Potentially Breaking Changes

  • Yes
  • No

Includes DRC change

  • Yes
  • No

If yes -> requires bump NPM version


🔍 Additional Notes

This PR is part of a multi-repo leave-guard integration


📸 Screenshots / Demos


amit-noy added 6 commits July 14, 2026 17:06
<!-- Title structure should start with a flag - either of these:
[FEAT] [FIX] [CHORE] [CI] [DOCS] [STYLE] [REFACTOR] [TEST] [BUILD] [PERF]
Followed by a clear representation - e.g:
[STYLE] Reformat components for linting compliance
[CI] Run tests on push for all branches
[FEAT] Add dark mode toggle in header
-->

## 📝 Description
<!-- A clear, concise summary of what this PR does. -->
<!-- Include context, motivation, or related issues (e.g., "Replaces Sass with CSS Modules"). -->

When a user had an item's detail pane or version history open (on Jobs, Real-time pipelines, or Artifacts pages) and switched projects via the sidebar dropdown, the URL was naively replacing the project 
name in place. This kept the artifact/item-specific segments in the URL, causing the next network request to still reference the previous project's item instead of loading a clean state for the new 
project.
The fix strips artifact-specific path segments on project switch, so the user always lands on the section's main list of the new project with no leftover item context.

---

## 🛠️ Changes Made
<!-- List the main updates in this PR. -->
<!-- Example:
- Replaced Sass styles with CSS Modules
- Updated Button component props for accessibility
- Adjusted CI workflow to run on push for all branches
-->

- `ProjectDropdown.jsx`: compute `basePath` before building project links - when the current path is deeper than depth 5 (i.e. an item is selected), strip back to `/projects/:projectName/:section`
- `ProjectDropdown.test.jsx`: added `EllipsisTooltip` to the mock (was missing) and a new `project switch navigation` describe block with 7 test cases covering flat sections (depth 4), sub-tab main pages
(depth 5), and selected-item pages (depth 6+)

---

## ✅ Checklist

- [x] I have given the PR a well-structured title describing the domain and the specific change that was made
- [x] I tested the changes in the browser (locally or via preview build)
- [x] I confirmed that existing tests pass
- [x] I added or updated unit / integration tests (if needed)
- [x] I checked that this change doesn’t introduce new console warnings or lint / formatting errors
- [x] I updated the relevant Jira ticket with the appropriate details and status


---

## 🔗 References
- Related ticket / issue: https://ecliptos.atlassian.net/browse/ML-12831
- Figma / design spec:
- Documentation:

---

## 🚨 Potentially Breaking Changes
- [ ] Yes
- [x] No

<!-- If yes, describe what breaks and how to migrate: -->
<!-- Example: Renamed prop `variant` → `type` in Button component -->

---

Includes DRC change
- [ ] Yes
- [x] No

If yes -> requires bump NPM version

---

## 🔍 Additional Notes
<!-- Optional: other context, performance considerations, or follow-up work -->
<!-- Example:
- TODO: Migrate remaining components away from Sass
- Known issue: minor layout flicker on mobile
-->

---

## 📸 Screenshots / Demos
<!-- Include before/after screenshots, GIFs, or video demos if the change affects UI. -->
<!-- You can drag and drop images here directly in the PR. -->

---
@amit-noy amit-noy added the DO NOT MERGE Blocks accidental merges label Jul 16, 2026
amit-noy and others added 5 commits July 26, 2026 09:47
… mlrun-ui

- vite.config.mjs: add react-router-dom as MF singleton so all apps share one router instance
- App.jsx: detect when loaded inside a host router (useInRouterContext) and render
  <Routes> instead of <RouterProvider> to avoid nested-router crash

Co-authored-by: Cursor <cursoragent@cursor.com>
…bar close on block

- RemoteNuclioRouteWrapper: remove synthetic popstate dispatch and isNuclioPath
  (no longer needed with shared singleton router)
- RemoteNuclioRouteWrapper: close sidebar via igz:navigation-blocked onBlock callback
- Remove HostLeaveGuard (Nuclio's useBlocker handles all navigation directly)

Co-authored-by: Cursor <cursoragent@cursor.com>
@amit-noy amit-noy removed the DO NOT MERGE Blocks accidental merges label Jul 26, 2026
@amit-noy
amit-noy requested a review from pini-sh-panda July 27, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants