Skip to content

feat: make dashboard view default#2858

Merged
moshloop merged 2 commits intomainfrom
dashboard-view-default
Feb 17, 2026
Merged

feat: make dashboard view default#2858
moshloop merged 2 commits intomainfrom
dashboard-view-default

Conversation

@yashmehrotra
Copy link
Member

@yashmehrotra yashmehrotra commented Feb 16, 2026

Fixes: #2848

Summary by CodeRabbit

  • New Features

    • Implemented dynamic homepage routing based on feature flag configuration for dashboard view selection, supporting UUID, namespace/name, and name-based resolution formats.
  • Changes

    • Updated default route behavior to resolve and redirect to configured dashboard views with automatic fallback to mission-control-dashboard and health page options when resolution fails.

@vercel
Copy link

vercel bot commented Feb 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aws-preview Ready Ready Preview Feb 16, 2026 9:34am
flanksource-ui Ready Ready Preview Feb 16, 2026 9:34am

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 16, 2026

Walkthrough

This pull request implements dynamic dashboard view routing based on feature flags, replacing the static topology dashboard default with a feature-driven approach. It introduces a new HomepageRedirect component that resolves the dashboard view through multiple resolution strategies (UUID lookup, namespace/name lookup, or name lookup), with fallback to a default view. The navigation system is refactored to conditionally include the resolved dashboard view as the primary navigation item.

Changes

Cohort / File(s) Summary
Core App Routing Changes
src/App.tsx
Replaces default "" route with HomepageRedirect component. Adds dynamic dashboard view resolution via feature flags with helper function findDashboardView(). Refactors useDynamicNavigation to conditionally include resolved dashboard view as primary navigation item. Removes static Topology Dashboard import and navigation element.
HomepageRedirect Component
src/components/HomepageRedirect.tsx
New React component that reads dashboard view property from feature flags and resolves to appropriate view via UUID, namespace/name, or name lookup. Uses React Query to compute redirect path, displays skeleton while loading, and navigates to resolved view or health fallback page.
Dashboard View Constants
src/components/dashboardViewConstants.ts
Introduces shared constants for dashboard view resolution: UUID_REGEX (UUID validation), FALLBACK_VIEW_NAME ("mission-control-dashboard"), and DASHBOARD_VIEW_PROPERTY ("defaults.dashboard_view").
Feature Flags Context Export
src/context/FeatureFlagsContext.tsx
Exports FeatureFlagsContext publicly to enable access in components like HomepageRedirect and App.
Tests
src/components/__tests__/HomepageRedirect.unit.test.tsx
Comprehensive test suite covering UUID-based redirection, namespace/name lookup, plain name lookup, fallback to mission-control-dashboard, health page fallback, and error scenarios. Mocks feature flags context and view resolution APIs.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant App as App.tsx
    participant HomepageRedirect as HomepageRedirect
    participant FeatureFlagsContext as FeatureFlagsContext
    participant API as View API<br/>(getViewIdByName,<br/>getViewIdByNamespaceAndName)
    participant Router as Router
    participant Dashboard as Dashboard View/<br/>Health Page

    User->>App: Load application
    App->>HomepageRedirect: Navigate to "" (default route)
    HomepageRedirect->>FeatureFlagsContext: Read DASHBOARD_VIEW_PROPERTY
    alt Feature flag value is UUID
        HomepageRedirect->>Router: Navigate directly to /views/{uuid}
    else Feature flag value contains slash
        HomepageRedirect->>API: getViewIdByNamespaceAndName(namespace, name)
        API-->>HomepageRedirect: Return view ID
        HomepageRedirect->>Router: Navigate to /views/{id}
    else Feature flag value is plain name
        HomepageRedirect->>API: getViewIdByName(name)
        API-->>HomepageRedirect: Return view ID
        HomepageRedirect->>Router: Navigate to /views/{id}
    else No property or resolution fails
        HomepageRedirect->>API: getViewIdByName("mission-control-dashboard")
        API-->>HomepageRedirect: Return fallback view ID or undefined
        alt Fallback view resolved
            HomepageRedirect->>Router: Navigate to /views/{id}
        else Fallback fails
            HomepageRedirect->>Router: Navigate to /health
        end
    end
    Router->>Dashboard: Render destination view
    Dashboard-->>User: Display dashboard or health page
Loading

Suggested Reviewers

  • moshloop
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: make dashboard view default' directly and concisely summarizes the main objective of the changeset, which is implementing the dashboard view as the default.
Linked Issues check ✅ Passed The pull request successfully implements the requirement from issue #2848 to make the Dashboard view the default, replacing the topology dashboard with proper view resolution and fallback logic.
Out of Scope Changes check ✅ Passed All changes are directly related to making the dashboard view default: route changes, feature flag integration, view resolution logic, and comprehensive tests. No unrelated modifications detected.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dashboard-view-default

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

@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: 1

🤖 Fix all issues with AI agents
In `@src/App.tsx`:
- Around line 1084-1102: findDashboardView currently looks only in the views
returned from getViewsForSidebar (which filters sidebar=eq.true) so a configured
dashboard with sidebar=false will not be found and thus not added to the sidebar
even though HomepageRedirect still redirects to it; update the logic in
findDashboardView (or the code that calls it) to, when the initial search in the
getViewsForSidebar results returns undefined, perform a secondary fetch for the
specific dashboard view (using the existing helpers getViewIdByName or
getViewIdByNamespaceAndName or a direct getViewById call) and return that result
so the dashboard nav item is added regardless of the sidebar flag, or
alternatively adjust the initial fetch to include sidebar values for the
configured dashboard lookup.
🧹 Nitpick comments (4)
src/components/HomepageRedirect.tsx (2)

19-25: Edge case: values with multiple slashes.

resolveViewId splits on "/" with a limit of 2, so for a value like "a/b/c", namespace becomes "a" and name becomes "b", silently dropping "c". If namespace/name values could legitimately contain slashes, consider splitting only on the first occurrence:

const idx = value.indexOf("/");
const namespace = value.slice(0, idx);
const name = value.slice(idx + 1);

If namespace/name values never contain slashes, the current behavior is fine.


27-50: Consider guarding against unloaded feature flags.

This component assumes featureFlags are already loaded when it renders (currently guaranteed by the featureFlagsLoaded guard in IncidentManagerRoutes). If that parent guard is ever removed or bypassed, the component would immediately resolve with an empty flags array and navigate to the fallback/health path before the actual configured view can be determined.

A defensive check would make this component self-contained:

🛡️ Suggested defensive guard
 export function HomepageRedirect() {
-  const { featureFlags } = useFeatureFlagsContext();
+  const { featureFlags, featureFlagsLoaded } = useFeatureFlagsContext();
+
+  if (!featureFlagsLoaded) {
+    return <FullPageSkeletonLoader />;
+  }
 
   const dashboardViewValue = featureFlags.find(
src/components/__tests__/HomepageRedirect.unit.test.tsx (1)

89-169: Good test coverage of the main resolution paths.

The tests cover UUID, namespace/name, plain name, fallback, and error scenarios well.

One minor gap: there's no test for when namespace/name resolution specifically fails (e.g., mockedGetViewIdByNamespaceAndName.mockResolvedValue(undefined) with a "ns/name" flag value). The current tests only cover plain-name lookup failure (line 160). This is low-risk since the fallback path is the same, but adding it would complete the coverage matrix.

src/App.tsx (1)

1104-1152: Minor duplication of feature-flag reading logic.

The pattern to extract the dashboard view value from feature flags:

featureFlags.find((f) => f.name === DASHBOARD_VIEW_PROPERTY)?.value

is repeated in both HomepageRedirect.tsx and here. Consider extracting a small utility (e.g., getDashboardViewProperty(featureFlags)) into dashboardViewConstants.ts to keep the resolution logic centralized.

Not blocking — the duplication is small and both usages are near-identical.

Comment on lines +1084 to +1102
function findDashboardView(
views: ViewSummary[],
dashboardViewValue?: string
): ViewSummary | undefined {
if (!dashboardViewValue) {
return views.find((v) => v.name === FALLBACK_VIEW_NAME);
}

if (UUID_REGEX.test(dashboardViewValue)) {
return views.find((v) => v.id === dashboardViewValue);
}

if (dashboardViewValue.includes("/")) {
const [namespace, name] = dashboardViewValue.split("/", 2);
return views.find((v) => v.namespace === namespace && v.name === name);
}

return views.find((v) => v.name === dashboardViewValue);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's find getViewsForSidebar definition
ast-grep --pattern 'export const getViewsForSidebar = $_'

Repository: flanksource/flanksource-ui

Length of output: 599


🏁 Script executed:

# Also search for getViewsForSidebar more broadly
rg 'getViewsForSidebar' -A 5 -B 2

Repository: flanksource/flanksource-ui

Length of output: 1472


🏁 Script executed:

# Find where findDashboardView is called
rg 'findDashboardView' -B 3 -A 3

Repository: flanksource/flanksource-ui

Length of output: 564


🏁 Script executed:

# Find HomepageRedirect and getViewIdByName
rg 'HomepageRedirect|getViewIdByName' -B 3 -A 5

Repository: flanksource/flanksource-ui

Length of output: 10534


🏁 Script executed:

rg 'export const getViewIdByNamespaceAndName' -A 8 src/api/services/views.ts

Repository: flanksource/flanksource-ui

Length of output: 381


Dashboard view may not appear in sidebar if sidebar flag is false.

findDashboardView searches the views array returned by getViewsForSidebar, which filters on sidebar=eq.true. If the configured dashboard view has sidebar=false, it won't be found here, so no dashboard nav item will be added to the sidebar — even though HomepageRedirect will still redirect to it (since it queries all views via getViewIdByName or getViewIdByNamespaceAndName, both without the sidebar filter).

If the intent is that the dashboard view always appears in the sidebar nav regardless of its sidebar flag, this needs a separate fetch or an adjusted query. If the expectation is that the dashboard view must have sidebar=true, this is fine but worth documenting.

🤖 Prompt for AI Agents
In `@src/App.tsx` around lines 1084 - 1102, findDashboardView currently looks only
in the views returned from getViewsForSidebar (which filters sidebar=eq.true) so
a configured dashboard with sidebar=false will not be found and thus not added
to the sidebar even though HomepageRedirect still redirects to it; update the
logic in findDashboardView (or the code that calls it) to, when the initial
search in the getViewsForSidebar results returns undefined, perform a secondary
fetch for the specific dashboard view (using the existing helpers
getViewIdByName or getViewIdByNamespaceAndName or a direct getViewById call) and
return that result so the dashboard nav item is added regardless of the sidebar
flag, or alternatively adjust the initial fetch to include sidebar values for
the configured dashboard lookup.

@moshloop moshloop merged commit c6baa97 into main Feb 17, 2026
14 of 16 checks passed
@moshloop moshloop deleted the dashboard-view-default branch February 17, 2026 07:33
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.

Remove topology dashboard and move to Dashboard view as default

2 participants