Skip to content

Conversation

@artemmufazalov
Copy link
Member

@artemmufazalov artemmufazalov commented Nov 17, 2025

Part of #2892

Stand: https://nda.ya.ru/t/BEIjuuLI7N8Qd7

Goal: connect tenant page to useSetting hook instead of direct LS access in store

CI Results

Test Status: ⚠️ FLAKY

📊 Full Report

Total Passed Failed Flaky Skipped
378 375 0 1 2
Test Changes Summary ⏭️2

⏭️ Skipped Tests (2)

  1. Scroll to row, get shareable link, navigate to URL and verify row is scrolled into view (tenant/diagnostics/tabs/queries.test.ts)
  2. Copy result button copies to clipboard (tenant/queryEditor/queryEditor.test.ts)

Bundle Size: ✅

Current: 66.13 MB | Main: 66.12 MB
Diff: +2.75 KB (0.00%)

✅ Bundle size unchanged.

ℹ️ CI Information
  • Test recordings for failed tests are available in the full report.
  • Bundle size is measured for the entire 'dist' directory.
  • 📊 indicates links to detailed reports.
  • 🔺 indicates increase, 🔽 decrease, and ✅ no change in bundle size.

Greptile Overview

Greptile Summary

Refactored tenant page state management from Redux to URL query parameters with persistent settings storage. The changes move tenantPage state out of Redux into URL query params using use-query-params library, while maintaining user preferences through the useSetting hook. The new useTenantPage hook manages synchronization between URL state and saved settings, providing a consistent source of truth across the application.

Key changes:

  • Introduced useTenantPage hook combining URL query params with settings persistence
  • Removed tenantPage from Redux state and setTenantPage action
  • Updated all consumers to use handleTenantPageChange callback instead of dispatching Redux actions
  • Removed tenant page from legacy state-url-mapping system
  • Applied validation using Zod schemas with fallbacks to prevent invalid states

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - the refactoring follows established patterns and is well-tested
  • Score reflects thorough state management refactoring following best practices (use-query-params over legacy Redux state), consistent application of patterns across all files, proper validation with Zod schemas and fallbacks. Tests are passing with only expected skips. The implementation aligns with the codebase's migration toward query param management.
  • No files require special attention - the implementation is consistent and well-integrated

Important Files Changed

File Analysis

Filename Score Overview
src/containers/Tenant/TenantNavigation/useTenantNavigation.tsx 4/5 Refactored tenant page state from Redux to URL query params with useSetting hook, added useTenantPage custom hook for managing tenant page state
src/store/reducers/tenant/tenant.ts 5/5 Removed tenantPage from Redux state and deleted setTenantPage action, simplified state management
src/containers/Tenant/ObjectGeneral/ObjectGeneral.tsx 5/5 Updated to use useTenantPage hook instead of Redux selector
src/containers/Tenant/utils/controls.tsx 5/5 Updated interface to accept setTenantPage callback instead of dispatching Redux action
src/containers/Tenant/utils/schemaActions.tsx 5/5 Updated to use setTenantPage callback instead of dispatching Redux action

Sequence Diagram

sequenceDiagram
    participant User
    participant Navigation as TenantNavigation
    participant Hook as useTenantPage
    participant Query as useQueryParams
    participant Settings as useSetting
    participant LS as LocalStorage
    
    User->>Navigation: Click navigation item
    Navigation->>Hook: handleTenantPageChange(pageId)
    
    Hook->>Query: setQueryParams({tenantPage: pageId})
    Query->>Query: Update URL query parameter
    
    Hook->>Settings: setInitialTenantPage(pageId)
    Settings->>LS: Store in YDB settings service
    
    Note over Hook,Query: On mount / URL change
    
    Hook->>Query: Read tenantPageFromQuery
    Hook->>Settings: Read initialTenantPage
    
    Hook->>Hook: Parse with tenantPageSchema.catch(fallback)
    
    alt Valid query param
        Hook->>Hook: Use query param as tenantPage
        Hook->>Settings: Sync to settings if differs
    else Invalid query param
        Hook->>Hook: Use saved setting as tenantPage
        Hook->>Query: Replace URL param with saved value
    end
    
    Hook-->>Navigation: Return {tenantPage, handleTenantPageChange}
    Navigation-->>User: Display active page
Loading

Copy link
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

This PR refactors the tenant page state management to use URL query parameters via the useTenantPage hook instead of storing the state directly in the Redux store. This change aligns with the goal of connecting the tenant page to the useSetting hook pattern while maintaining the state in the URL.

Key changes:

  • Introduced a new useTenantPage hook that manages tenant page state through URL query params and local settings
  • Removed tenantPage from Redux state, reducer actions, and URL state mapping
  • Updated all components to use handleTenantPageChange from useTenantPage instead of dispatching Redux actions

Reviewed Changes

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

Show a summary per file
File Description
src/store/state-url-mapping.ts Removed tenantPage entries from URL mapping configuration since it's now managed by use-query-params
src/store/reducers/tenant/types.ts Removed tenantPage from TenantState interface
src/store/reducers/tenant/tenant.ts Removed setTenantPage action and related initialization logic from Redux slice
src/containers/Tenant/utils/schemaActions.tsx Added setTenantPage to interface and updated calls to use parameter instead of Redux dispatch
src/containers/Tenant/utils/controls.tsx Added setTenantPage to interface and updated calls to use parameter instead of Redux dispatch
src/containers/Tenant/TenantPages.tsx Added tenantPage to AdditionalQueryParams type
src/containers/Tenant/TenantNavigation/useTenantNavigation.tsx Implemented new useTenantPage hook with URL query param and settings management
src/containers/Tenant/ObjectSummary/SchemaTree/SchemaTree.tsx Added handleTenantPageChange from useTenantPage hook and passed to action helpers
src/containers/Tenant/ObjectSummary/SchemaActions.tsx Updated to use useTenantPage hook instead of Redux selector
src/containers/Tenant/ObjectSummary/ObjectSummary.tsx Added handleTenantPageChange from useTenantPage and passed to controls
src/containers/Tenant/ObjectGeneral/ObjectGeneral.tsx Updated to get tenantPage from useTenantPage hook instead of Redux selector
src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx Added handleTenantPageChange from useTenantPage for navigation handler
Comments suppressed due to low confidence (1)

src/containers/Tenant/ObjectSummary/SchemaTree/SchemaTree.tsx:184

  • The handleTenantPageChange dependency is missing from the useMemo dependency array on line 170. Since handleTenantPageChange is used in the memoized function (line 155), it must be included in the dependencies to ensure the memoized value updates correctly when the callback changes.
    }, [
        actionsSchemaData,
        createDirectoryFeatureAvailable,
        dispatch,
        input,
        isActionsDataFetching,
        isDirty,
        isStreamingInfoFetching,
        onActivePathUpdate,
        streamingSysData,
        database,
        databaseFullPath,
        controlPlane,
        clusterMonitoring,
    ]);

@artemmufazalov artemmufazalov marked this pull request as ready for review November 17, 2025 18:21
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

12 files reviewed, no comments

Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format

Copy link
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

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

@Raubzeug
Copy link
Contributor

@greptile-review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

12 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@artemmufazalov artemmufazalov added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit 6f81825 Nov 20, 2025
15 checks passed
@artemmufazalov artemmufazalov deleted the tenant-navigation branch November 20, 2025 09:27
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.

3 participants