-
Notifications
You must be signed in to change notification settings - Fork 16
fix: refactor relative paths support #2877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 pull request refactors the codebase to better support relative paths by transitioning from using database names as parameters to a more structured approach that separates database identifiers from full database paths. The main goal is to improve path handling throughout the tenant and diagnostics components.
Key changes include:
- Replacing
tenantName
parameters withdatabase
parameters - Adding
databaseFullPath
parameters to maintain full path context - Updating path transformation utilities to handle relative paths correctly
Reviewed Changes
Copilot reviewed 123 out of 123 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/utils/constants.ts | Renamed tenantName constant to database for consistency |
Multiple test files | Updated test parameters from tenantName to database across tenant test suites |
src/utils/shardsQueryBuilders.ts | New utility file for building shards-related queries with improved path handling |
Type definition files | Updated type definitions to include databaseFullPath parameters and SchemaPathParam type |
Store reducers | Refactored API calls to use new path parameter structure with relative path support |
Service API files | Updated API methods to accept SchemaPathParam objects instead of string paths |
Container components | Updated component props and API calls to use new database/path parameter structure |
Comments suppressed due to low confidence (1)
src/containers/Tenant/ObjectSummary/transformPath.ts:21
- [nitpick] The function comment and variable names don't match the refactored implementation. The comment still mentions 'dbName' parameter but the function now uses 'databaseFullPath'. The variable 'normalizedDbName' should be renamed to 'normalizedDatabaseFullPath' for clarity.
export function transformPath(path: string, databaseFullPath: string): string {
// Normalize the path and dbName by removing leading/trailing slashes
const normalizedPath = path.replace(/^\/+|\/+$/g, '');
const normalizedDbName = databaseFullPath.replace(/^\/+|\/+$/g, '');
if (!normalizedPath.startsWith(normalizedDbName)) {
return normalizedPath || '/';
}
if (normalizedPath === normalizedDbName) {
return `/${normalizedPath}`;
}
let result = normalizedPath.slice(normalizedDbName.length);
// Remove leading slash if present, unless the result would be empty
result = result.replace(/^\/+/, '') || '/';
return result;
}
src/containers/Tenant/ObjectSummary/CreateDirectoryDialog/CreateDirectoryDialog.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing changes made in this pull request
timeout?: number; | ||
}) => { | ||
try { | ||
const relativePath = path.replace(databaseFullPath, ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Using simple string replace could be problematic. If path
contains databaseFullPath
as a substring multiple times or in unexpected positions, this could produce incorrect results. Consider using a more robust approach like checking if path starts with databaseFullPath and removing only the prefix.
src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TenantCpu.tsx
Outdated
Show resolved
Hide resolved
bugbot run |
Claude finished @astandrik's task —— View job Code Review for PR #2877: fix: refactor relative paths supportI've reviewed this PR focusing on code standards, TypeScript safety, React patterns, and critical requirements for the YDB Embedded UI codebase. Here are my findings: 🔴 Critical Bugs1. Missing
|
Closes #2847
Stand
CI Results
Test Status:⚠️ FLAKY
📊 Full Report
Test Changes Summary ⏭️2
⏭️ Skipped Tests (2)
Bundle Size: 🔺
Current: 85.44 MB | Main: 85.43 MB
Diff: +0.02 MB (0.02%)
ℹ️ CI Information
Updated On: 2025-09-11 15:49:06 UTC
This PR implements a comprehensive refactoring to support relative schema object paths throughout the YDB Embedded UI. The changes introduce a new
SchemaPathParam
type containing bothpath
anddatabaseFullPath
properties, enabling the application to work with relative paths while maintaining full path context for API calls.Key changes include:
SchemaPathParam
type insrc/types/api/common.ts
to standardize how schema paths are passed throughout the applicationBaseYdbAPI.getSchemaPath()
to convert absolute paths to relative ones by removing the database path prefix whenuseRelativePath
is enableddatabase
(relative identifier) anddatabaseFullPath
(absolute path) parameterssrc/utils/shardsQueryBuilders.ts
with reusable SQL query builders that include relative path display logictenantName
usage to consistentdatabase
terminologydatabase
constant instead of the deprecatedtenantName
The refactoring enables cleaner URLs and more intuitive navigation by displaying relative paths in components like TopShards and Storage Diagnostics while maintaining backward compatibility with existing absolute path functionality.
Important Files Changed
Changed Files
Confidence score: 2/5
Sequence Diagram