Skip to content

Conversation

@Raubzeug
Copy link
Contributor

@Raubzeug Raubzeug commented Dec 3, 2025

closes #2283

Greptile Overview

Greptile Summary

This PR implements persistent user preference for storage view type (groups vs nodes), resolving issue #2283 where users wanted their storage type selection to be remembered across sessions.

  • Added STORAGE_TYPE setting key with default value of groups to user settings
  • Created useSaveStorageType hook that syncs URL query params with saved user preferences
  • Modified handleStorageTypeChange to save user preference when storage type is changed
  • Hook properly initializes storage type from saved settings on page load when no query param exists

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Clean implementation that follows existing patterns in the codebase. Uses established useSetting hook and query param management. No breaking changes, backward compatible with proper defaults. Previous typo feedback has been addressed.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/containers/Storage/useStorageQueryParams.ts 5/5 Added useSaveStorageType hook to persist storage type selection and modified handleStorageTypeChange to save user preference
src/containers/Storage/PaginatedStorage.tsx 5/5 Imported and invoked useSaveStorageType hook to initialize storage type from saved settings
src/store/reducers/settings/constants.ts 5/5 Added STORAGE_TYPE setting key with default value of groups to user settings configuration

Sequence Diagram

sequenceDiagram
    participant User
    participant PaginatedStorage
    participant useSaveStorageType
    participant useStorageQueryParams
    participant LocalStorage
    participant URL

    User->>PaginatedStorage: Load storage page
    PaginatedStorage->>useSaveStorageType: Initialize hook
    useSaveStorageType->>LocalStorage: Read saved storage type (default: "groups")
    useSaveStorageType->>URL: Check query param "type"
    alt Query param exists
        useSaveStorageType->>useSaveStorageType: Use query param value
    else No query param
        useSaveStorageType->>URL: Set query param to saved value
    end
    
    User->>User: Change storage type (groups/nodes)
    User->>useStorageQueryParams: handleStorageTypeChange(newType)
    useStorageQueryParams->>URL: Update query param
    useStorageQueryParams->>LocalStorage: Save new preference
    
    User->>PaginatedStorage: Return to storage page later
    PaginatedStorage->>useSaveStorageType: Initialize hook
    useSaveStorageType->>LocalStorage: Read saved storage type
    useSaveStorageType->>URL: Set query param to saved preference
Loading

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: 62.33 MB | Main: 62.33 MB
Diff: +3.37 KB (0.01%)

⚠️ Bundle size increased. Please review.

ℹ️ 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.

Copilot AI review requested due to automatic review settings December 3, 2025 06:34
Copilot finished reviewing on behalf of Raubzeug December 3, 2025 06:36
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.

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

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 adds persistence of the storage type selection (groups/nodes view) to user settings, allowing the application to remember the user's preferred storage view across sessions.

Key Changes:

  • Added STORAGE_TYPE setting key with default value of STORAGE_TYPES.groups
  • Modified handleStorageTypeChange to save the selected type to user settings
  • Added useSaveStorageType hook to initialize URL parameter from saved settings on component mount

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/store/reducers/settings/constants.ts Adds STORAGE_TYPE setting key and default value to user settings configuration
src/containers/Storage/useStorageQueryParams.ts Implements storage type persistence by saving to settings on change and initializing URL from saved settings; fixes missing dependency in useEffect
src/containers/Storage/PaginatedStorage.tsx Integrates the new useSaveStorageType hook to apply saved storage type on component mount

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.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Comment on lines +132 to +134
if (normalizedStorageType !== queryStorageType) {
setQueryStorageType(normalizedStorageType);
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to get to table with specific storage type in query? With your code in such case storage type from query will always be replaced with the saved one.

I think it should be two ways sync like here: https://github.com/ydb-platform/ydb-embedded-ui/blob/main/src/containers/Tenant/TenantNavigation/useTenantNavigation.tsx#L60

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, normalizedStorageType calculates with storageTypeSchema.parse(queryStorageType ?? savedStorageType). So, queryStorageType has priority and will be taken, if it is presented.

@Raubzeug Raubzeug added this pull request to the merge queue Dec 4, 2025
Merged via the queue into main with commit 23e4856 Dec 4, 2025
10 checks passed
@Raubzeug Raubzeug deleted the storage-type branch December 4, 2025 07:44
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.

keep previously selected storage type (groups/nodes) by default for storage view

3 participants