Skip to content

refactor: remove embedded mode methods from router classes#28063

Open
ShaileshParmar11 wants to merge 6 commits into
mainfrom
common-route-support
Open

refactor: remove embedded mode methods from router classes#28063
ShaileshParmar11 wants to merge 6 commits into
mainfrom
common-route-support

Conversation

@ShaileshParmar11
Copy link
Copy Markdown
Contributor

@ShaileshParmar11 ShaileshParmar11 commented May 12, 2026

Describe your changes:

Fixes #

I worked on ... because ...

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

High-level design:

N/A — small change.

Tests:

Use cases covered

Unit tests

Backend integration tests

Ingestion integration tests

Playwright (UI) tests

Manual testing performed

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

Summary by Gitar

  • Router Refactor:
    • Removed isEmbeddedMode methods from ConnectionsRouterClassBase and ObservabilityRouterClassBase to simplify routing logic.
    • Introduced inCurrentAppContext utility and registerAppContextProvider hook in RouterUtils to handle URL routing consistently in embedded environments.
  • Implementation Updates:
    • Updated EditorSlots, useOntologyExplorer, and KnowledgeGraph.utils to use inCurrentAppContext for all escape-hatch navigation.
    • Refactored GlobalSettingCategoryPage to rely on standard isEmbedded checks instead of deprecated router methods.
  • Test Suite:
    • Added comprehensive unit tests in RouterUtils.test.ts to verify provider registration and identity fallback behavior.
    • Updated BlockEditorUtils.test.ts and KnowledgeGraph.utils.test.ts to ensure canonical URL storage and correct context provider integration.

This will update automatically on new commits.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels May 12, 2026
Comment thread openmetadata-ui/src/main/resources/ui/src/utils/BlockEditorUtils.ts Outdated
Comment thread openmetadata-ui/src/main/resources/ui/src/utils/KnowledgeGraph.utils.test.ts Outdated
@ShaileshParmar11 ShaileshParmar11 marked this pull request as ready for review May 15, 2026 05:41
@ShaileshParmar11 ShaileshParmar11 requested a review from a team as a code owner May 15, 2026 05:41
Copilot AI review requested due to automatic review settings May 15, 2026 05:41
@gitar-bot
Copy link
Copy Markdown

gitar-bot Bot commented May 15, 2026

Code Review ✅ Approved 3 resolved / 3 findings

Removes embedded mode methods from router classes while introducing AppContextProvider and inCurrentAppContext utilities for consistent URL handling. No issues found.

✅ 3 resolved
Bug: Double-prefixing of URLs for mention/hashtag links in EditorSlots

📄 openmetadata-ui/src/main/resources/ui/src/components/BlockEditor/EditorSlots.tsx:94 📄 openmetadata-ui/src/main/resources/ui/src/utils/BlockEditorUtils.ts:70-73 📄 openmetadata-ui/src/main/resources/ui/src/utils/BlockEditorUtils.ts:83-84
In BlockEditorUtils.ts, inCurrentAppContext() is already applied when constructing the <a href="..."> tags for mention and hashtag links (lines 70-73, 83-84). When those links are later clicked in EditorSlots.tsx (line 94), the href attribute—already containing the app context prefix—is passed through inCurrentAppContext() again. This will produce a malformed URL like /subpath/subpath/entity/fqn whenever a non-identity provider is registered, breaking navigation for all entity mention/hashtag links in the block editor.

Quality: Import ordering: RouterUtils import placed before BlockEditorExtensionsClassBase

📄 openmetadata-ui/src/main/resources/ui/src/utils/BlockEditorUtils.ts:24-25
In BlockEditorUtils.ts, the new import import { inCurrentAppContext } from './RouterUtils' (line 24) is placed before import blockEditorExtensionsClassBase from './BlockEditorExtensionsClassBase' (line 25). Per alphabetical ordering conventions for relative imports, ./BlockEditorExtensionsClassBase should come before ./RouterUtils.

Quality: Missing afterEach cleanup in KnowledgeGraph test risks state leakage

📄 openmetadata-ui/src/main/resources/ui/src/utils/KnowledgeGraph.utils.test.ts:767-781
The new node:dblclick routes the URL through the registered AppContextProvider test (line 767-790) performs cleanup (registerAppContextProvider(null) and openSpy.mockRestore()) inline at the end of the test body rather than in an afterEach block. If any assertion fails before line 788, the registered provider leaks into subsequent tests.

The other two test files (RouterUtils.test.ts line 131-133 and BlockEditorUtils.test.ts line 168-169) correctly use afterEach for this cleanup — this test should follow the same pattern for consistency and resilience.

Options

Display: compact → Showing less information.

Comment with these commands to change:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Copy link
Copy Markdown
Contributor

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

Refactor removing unused setEmbeddedMode/isEmbeddedMode no-op methods from ConnectionsRouterClassBase and ObservabilityRouterClassBase, replacing the lone caller with the locally-derived isEmbedded flag, and introducing a small registerAppContextProvider/inCurrentAppContext extension hook in RouterUtils for rewriting escape-hatch URLs (window.open, target=_blank) used by hosts that mount OM under a sub-path. The new hook is wired into EditorSlots, useOntologyExplorer, and KnowledgeGraph.utils.

Changes:

  • Remove embedded-mode no-op methods (and their tests) from the two router base classes.
  • Add registerAppContextProvider / inCurrentAppContext in RouterUtils and apply it at escape-hatch window.open sites; verify mention/hashtag hrefs remain canonical in BlockEditorUtils.
  • Replace connectionsRouterClassBase.isEmbeddedMode() in GlobalSettingCategoryPage with the local isEmbedded flag and add unit tests for the new hook.

Reviewed changes

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

Show a summary per file
File Description
openmetadata-ui/.../utils/RouterUtils.ts Adds AppContextProvider, registerAppContextProvider, inCurrentAppContext.
openmetadata-ui/.../utils/RouterUtils.test.ts Unit tests for provider registration and identity fallback.
openmetadata-ui/.../utils/ObservabilityRouterClassBase.ts Removes embedded-mode no-op methods.
openmetadata-ui/.../utils/ObservabilityRouterClassBase.test.ts Removes corresponding tests.
openmetadata-ui/.../utils/ConnectionsRouterClassBase.ts Removes embedded-mode no-op methods.
openmetadata-ui/.../utils/ConnectionsRouterClassBase.test.ts Removes corresponding tests.
openmetadata-ui/.../utils/KnowledgeGraph.utils.ts Routes window.open URL through inCurrentAppContext.
openmetadata-ui/.../utils/KnowledgeGraph.utils.test.ts Verifies provider rewriting on node:dblclick.
openmetadata-ui/.../utils/BlockEditorUtils.ts Adds comment noting hrefs are stored unprefixed.
openmetadata-ui/.../utils/BlockEditorUtils.test.ts Asserts canonical hrefs regardless of provider.
openmetadata-ui/.../components/BlockEditor/EditorSlots.tsx Applies inCurrentAppContext on link clicks.
openmetadata-ui/.../components/OntologyExplorer/hooks/useOntologyExplorer.ts Applies inCurrentAppContext on node open.
openmetadata-ui/.../pages/GlobalSettingPage/.../GlobalSettingCategoryPage.tsx Replaces router isEmbeddedMode() call with local isEmbedded.

Comment on lines +110 to +113
if (isEmbedded && category === GlobalSettingsMenuCategory.SERVICES) {
navigate(
connectionsRouterClassBase.getSettingsServicesPath(option)
);
@github-actions
Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 62%
62.58% (64799/103534) 43.35% (35337/81511) 46.1% (10386/22525)

@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (15 flaky)

✅ 4065 passed · ❌ 0 failed · 🟡 15 flaky · ⏭️ 92 skipped

Shard Passed Failed Flaky Skipped
✅ Shard 1 299 0 0 4
🟡 Shard 2 756 0 6 14
🟡 Shard 3 779 0 2 7
🟡 Shard 4 787 0 3 18
🟡 Shard 5 708 0 1 41
🟡 Shard 6 736 0 3 8
🟡 15 flaky test(s) (passed on retry)
  • Features/BulkEditEntity.spec.ts › Glossary (shard 2, 1 retry)
  • Features/DataQuality/BundleSuiteBulkOperations.spec.ts › Add test case to existing Bundle Suite (shard 2, 1 retry)
  • Features/Glossary/GlossaryWorkflow.spec.ts › should start term as Draft when glossary has reviewers (shard 2, 1 retry)
  • Features/KnowledgeCenterList.spec.ts › Knowledge Center List - Test infinite scroll/pagination (shard 2, 2 retries)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Text Formatting (shard 2, 1 retry)
  • Features/KnowledgeCenterTextEditor.spec.ts › Rich Text Editor - Text Formatting (shard 2, 1 retry)
  • Features/RTL.spec.ts › Verify Following widget functionality (shard 3, 1 retry)
  • Features/Table.spec.ts › Tags term should be consistent for search (shard 3, 1 retry)
  • Pages/CustomProperties.spec.ts › Should display custom properties for apiCollection in right panel (shard 4, 1 retry)
  • Pages/DataContracts.spec.ts › Create Data Contract and validate for Topic (shard 4, 1 retry)
  • Pages/DescriptionVisibility.spec.ts › Domain description card collapse hides content and expand restores scrollability (shard 4, 1 retry)
  • Pages/ExplorePageRightPanel_KnowledgeCenter.spec.ts › Should remove user owner for knowledgeCenter (shard 5, 2 retries)
  • Pages/Lineage/DataAssetLineage.spec.ts › verify create lineage for entity - Pipeline (shard 6, 1 retry)
  • Pages/Lineage/LineageFilters.spec.ts › Verify lineage schema filter selection (shard 6, 1 retry)
  • Pages/Login.spec.ts › Refresh should work (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

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

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants