2025-07-30 23:48:36 -04:00
# Garage Web UI API Upgrade Report
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
## Upgrade Overview
2025-07-15 15:59:47 +08:00
2025-07-31 18:14:39 -04:00
The Garage Web UI project has been successfully upgraded from Garage Admin API v1 to v2, with all linting issues resolved and API endpoints aligned with the official specification.
2025-07-15 15:59:47 +08:00
2025-07-31 18:14:39 -04:00
**⚠️ Implementation Note**: This project now fully aligns with the official Garage Admin API v2 specification. For the authoritative API specification, please refer to [https://garagehq.deuxfleurs.fr/api/garage-admin-v2.html ](https://garagehq.deuxfleurs.fr/api/garage-admin-v2.html ).
2025-07-31 17:19:15 -04:00
2025-07-30 23:48:36 -04:00
## Upgrade Timeline
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
- **Completion Date**: July 2025
- **Current Version**: v1.0.9
2025-07-30 23:48:36 -04:00
- **Scope of Upgrade**: All API calls within the frontend React hooks
2025-07-31 18:14:39 -04:00
- **Code Quality**: All ESLint errors and warnings resolved
- **API Alignment**: Fully aligned with official Garage Admin API v2 specification
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
## Upgrade Details
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
### 1. Home Page (`src/pages/home/hooks.ts`)
2025-07-15 15:59:47 +08:00
- ✅ `useNodesHealth` : `/v1/health` → `/v2/GetClusterHealth`
2025-07-30 23:48:36 -04:00
### 2. Cluster Page (`src/pages/cluster/hooks.ts`)
2025-07-15 15:59:47 +08:00
- ✅ `useClusterStatus` : `/v1/status` → `/v2/GetClusterStatus`
- ✅ `useClusterLayout` : `/v1/layout` → `/v2/GetClusterLayout`
- ✅ `useConnectNode` : `/v1/connect` → `/v2/ConnectClusterNodes`
2025-07-31 17:19:15 -04:00
- ✅ `useAssignNode` : `/v1/layout` → `/v2/UpdateClusterLayout`
- ✅ `useUnassignNode` : `/v1/layout` → `/v2/UpdateClusterLayout`
2025-07-15 15:59:47 +08:00
- ✅ `useRevertChanges` : `/v1/layout/revert` → `/v2/RevertClusterLayout`
- ✅ `useApplyChanges` : `/v1/layout/apply` → `/v2/ApplyClusterLayout`
2025-07-30 23:48:36 -04:00
### 3. Keys Page (`src/pages/keys/hooks.ts`)
2025-07-15 15:59:47 +08:00
- ✅ `useKeys` : `/v1/key?list` → `/v2/ListKeys`
- ✅ `useCreateKey` : `/v1/key` → `/v2/CreateKey`
2025-07-30 23:48:36 -04:00
- ✅ `useCreateKey` (Import): `/v1/key/import` → `/v2/ImportKey`
2025-07-31 18:10:39 -04:00
- ✅ `useRemoveKey` : `/v1/key` → `/v2/DeleteKey?id={id}` (POST method, aligned with official spec)
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
### 4. Buckets Page (`src/pages/buckets/hooks.ts`)
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
- ✅ `useBuckets` : Custom `/buckets` endpoint → `/v2/ListBuckets` (enhanced with bucket details)
2025-07-15 15:59:47 +08:00
- ✅ `useCreateBucket` : `/v1/bucket` → `/v2/CreateBucket`
2025-07-30 23:48:36 -04:00
### 5. Bucket Management Page (`src/pages/buckets/manage/hooks.ts`)
2025-07-15 15:59:47 +08:00
- ✅ `useBucket` : `/v1/bucket` → `/v2/GetBucketInfo`
2025-07-31 17:19:15 -04:00
- ✅ `useUpdateBucket` : `/v1/bucket` → `/v2/UpdateBucket` (POST method)
2025-07-31 18:10:39 -04:00
- ✅ `useAddAlias` : `/v1/bucket/alias/global` → `/v2/AddBucketAlias` (POST method)
- ✅ `useRemoveAlias` : `/v1/bucket/alias/global` → `/v2/RemoveBucketAlias` (POST method)
2025-07-15 15:59:47 +08:00
- ✅ `useAllowKey` : `/v1/bucket/allow` → `/v2/AllowBucketKey`
- ✅ `useDenyKey` : `/v1/bucket/deny` → `/v2/DenyBucketKey`
2025-07-31 18:10:39 -04:00
- ✅ `useRemoveBucket` : `/v1/bucket` → `/v2/DeleteBucket?id={id}` (POST method, aligned with official spec)
2025-07-31 17:19:15 -04:00
### 6. Object Browser (`src/pages/buckets/manage/browse/hooks.ts`)
- ✅ `useBrowseObjects` : New custom `/browse/{bucket}` endpoint for S3-compatible object browsing
- ✅ `usePutObject` : New custom `/browse/{bucket}/{key}` endpoint for file uploads
- ✅ `useDeleteObject` : New custom `/browse/{bucket}/{key}` endpoint for file/folder deletion
### 7. Authentication (`src/pages/auth/hooks.ts` and `src/hooks/useAuth.ts`)
- ✅ `useLogin` : New custom `/auth/login` endpoint
- ✅ `useAuth` : New custom `/auth/status` endpoint for session management
### 8. Configuration (`src/hooks/useConfig.ts`)
- ✅ `useConfig` : New custom `/config` endpoint for garage configuration access
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
## Upgrade Statistics
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
### API Endpoint Mapping
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
| Original v1 Endpoint | Official v2 Endpoint | Implementation | Status |
| -------------------------------------------- | ---------------------------------- | ----------- | ------ |
| `/v1/health` | `GET /v2/GetClusterHealth` | `GET /v2/GetClusterHealth` | ✅ |
| `/v1/status` | `GET /v2/GetClusterStatus` | `GET /v2/GetClusterStatus` | ✅ |
| `/v1/layout` | `GET /v2/GetClusterLayout` | `GET /v2/GetClusterLayout` | ✅ |
| `/v1/connect` | `POST /v2/ConnectClusterNodes` | `POST /v2/ConnectClusterNodes` | ✅ |
| `/v1/layout` (POST) | `POST /v2/UpdateClusterLayout` | `POST /v2/UpdateClusterLayout` | ✅ |
| `/v1/layout/revert` | `POST /v2/RevertClusterLayout` | `POST /v2/RevertClusterLayout` | ✅ |
| `/v1/layout/apply` | `POST /v2/ApplyClusterLayout` | `POST /v2/ApplyClusterLayout` | ✅ |
| `/v1/key?list` | `GET /v2/ListKeys` | `GET /v2/ListKeys` | ✅ |
| `/v1/key` (POST) | `POST /v2/CreateKey` | `POST /v2/CreateKey` | ✅ |
| `/v1/key/import` | `POST /v2/ImportKey` | `POST /v2/ImportKey` | ✅ |
2025-07-31 18:10:39 -04:00
| `/v1/key` (DELETE) | `POST /v2/DeleteKey?id={id}` | `POST /v2/DeleteKey?id={id}` | ✅ |
2025-07-31 17:19:15 -04:00
| `/buckets` | `GET /v2/ListBuckets` | `GET /v2/ListBuckets` | ✅ |
| `/v1/bucket` (POST) | `POST /v2/CreateBucket` | `POST /v2/CreateBucket` | ✅ |
| `/v1/bucket` (GET) | `GET /v2/GetBucketInfo` | `GET /v2/GetBucketInfo` | ✅ |
| `/v1/bucket` (PUT) | `POST /v2/UpdateBucket` | `POST /v2/UpdateBucket` | ✅ |
2025-07-31 18:10:39 -04:00
| `/v1/bucket` (DELETE) | `POST /v2/DeleteBucket?id={id}` | `POST /v2/DeleteBucket?id={id}` | ✅ |
| `/v1/bucket/alias/global` (PUT) | `POST /v2/AddBucketAlias` | `POST /v2/AddBucketAlias` | ✅ |
| `/v1/bucket/alias/global` (DELETE) | `POST /v2/RemoveBucketAlias` | `POST /v2/RemoveBucketAlias` | ✅ |
2025-07-31 17:19:15 -04:00
| `/v1/bucket/allow` | `POST /v2/AllowBucketKey` | `POST /v2/AllowBucketKey` | ✅ |
| `/v1/bucket/deny` | `POST /v2/DenyBucketKey` | `POST /v2/DenyBucketKey` | ✅ |
**Note**: "Official" refers to the Garage Admin API v2 specification, "Impl" refers to the Garage Web UI implementation which may use more REST-compliant HTTP methods.
### Custom Backend Endpoints
In addition to the standard Garage Admin API v2 endpoints, the Garage Web UI implements several custom backend endpoints for enhanced functionality:
| Endpoint | HTTP Method | Purpose | Status |
| -------- | ----------- | ------- | ------ |
| `/config` | GET | Get garage configuration | ✅ |
| `/auth/login` | POST | User authentication | ✅ |
| `/auth/logout` | POST | User logout | ✅ |
| `/auth/status` | GET | Authentication status | ✅ |
| `/buckets` | GET | Enhanced bucket listing with details | ✅ |
| `/browse/{bucket}` | GET | Browse bucket objects | ✅ |
| `/browse/{bucket}/{key...}` | GET | View/download object | ✅ |
| `/browse/{bucket}/{key...}` | PUT | Upload object | ✅ |
| `/browse/{bucket}/{key...}` | DELETE | Delete object/folder | ✅ |
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
### Upgrade Count
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
- **Total Standard v2 Endpoints Implemented**: 18
- **Custom Backend Endpoints**: 9
- **Total API Endpoints**: 27
- **Successfully Upgraded**: 18 (100% of planned v1→v2 migrations)
- **Custom Features Added**: 9 (Object browsing, authentication, enhanced bucket listing)
- **Number of Files Upgraded**: 5 TypeScript hook files + 1 backend router
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
## Backend Compatibility
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
✅ **No Backend Modifications Required** :
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
- The backend uses a reverse proxy (`ProxyHandler` ) to directly forward API requests to the Garage Admin API.
- All v2 API requests are automatically forwarded to the correct Garage Admin endpoints.
- No changes to the Go backend code were necessary.
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
## Build Verification
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
✅ **Build Successful** :
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
- TypeScript compilation passed.
- Vite bundling was successful.
- No compilation errors.
2025-07-31 17:19:15 -04:00
- Docker build working properly.
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
✅ **Code Quality** :
2025-07-15 15:59:47 +08:00
2025-07-31 18:14:39 -04:00
- All ESLint errors and warnings have been resolved.
- Type definitions have been optimized (removed all `any` types).
- All React hooks follow proper dependency rules.
- Form controls are properly managed (controlled vs uncontrolled).
- All components have proper TypeScript interfaces.
- React component keys are properly assigned for list items.
- Input fields have appropriate `readOnly` props where needed.
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
## New Feature Availability
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
After upgrading to the v2 API, the project now utilizes the following enhanced features:
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
### Enhanced Cluster Management
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
- More detailed cluster health status information via `/v2/GetClusterHealth`
- Improved layout management operations with `/v2/UpdateClusterLayout`
- Better node connection handling through `/v2/ConnectClusterNodes`
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
### Enhanced Key Management
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
- Support for more key types through `/v2/CreateKey`
- Improved permission management with `/v2/AllowBucketKey` and `/v2/DenyBucketKey`
- Better key import functionality via `/v2/ImportKey`
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
### Enhanced Bucket Management
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
- Richer bucket metadata from `/v2/GetBucketInfo`
2025-07-31 18:10:39 -04:00
- Improved alias management with `/v2/AddBucketAlias` and `/v2/RemoveBucketAlias`
2025-07-31 17:19:15 -04:00
- Finer-grained permission control through updated permission APIs
2025-07-31 18:14:39 -04:00
## Recent Improvements & Fixes
### ✅ **API Endpoint Corrections (July 2025)**
1. **Bucket Alias Operations** :
- Fixed `AddBucketAlias` : Now uses correct endpoint `/v2/AddBucketAlias` with POST method
- Fixed `RemoveBucketAlias` : Now uses correct endpoint `/v2/RemoveBucketAlias` with POST method
- Updated request format to use `{ bucketId, globalAlias }` in request body
2. **Delete Operations** :
- Fixed `DeleteKey` : Now uses `POST /v2/DeleteKey?id={id}` (aligned with official spec)
- Fixed `DeleteBucket` : Now uses `POST /v2/DeleteBucket?id={id}` (aligned with official spec)
### ✅ **Code Quality Improvements (July 2025)**
1. **TypeScript & ESLint Fixes** :
- Removed all `any` types in favor of proper TypeScript interfaces
- Fixed all React Hook dependency warnings
- Resolved controlled vs uncontrolled input warnings
- Added proper `key` props to list items
- Added `readOnly` props to display-only input fields
2. **Component Fixes** :
- **Chips Component**: Fixed TypeScript prop spreading
- **Select Component**: Improved ref handling
- **Disclosure Hooks**: Enhanced type safety
- **Page Context**: Fixed infinite loop issues with proper memoization
- **Main Layout**: Fixed sidebar toggle on mobile devices
- **ShareDialog**: Added `readOnly` prop to URL input field
- **Permissions Tab**: Added proper keys and readOnly checkboxes
- **Create Key Dialog**: Fixed uncontrolled to controlled input warnings
3. **Mobile & UX Improvements** :
- Fixed sidebar functionality on mobile devices
- Resolved burger menu toggle issues
- Improved form validation and error handling
2025-07-31 17:19:15 -04:00
## Production Status
✅ **Production Ready** :
1. ✅ **Type Definition Optimization** : All `any` types have been replaced with specific interface definitions.
2. ✅ **Functional Testing** : All upgraded features tested and working in production.
3. ✅ **Documentation Update** : Project documentation updated to reflect the use of the v2 API.
4. ✅ **Error Handling** : Error handling logic adjusted for the v2 API's response format.
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
## Future Enhancement Opportunities
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
1. **Additional v2 Features** : Implement newly available v2 API features such as:
- Admin token management (`/v2/CreateAdminToken` , `/v2/ListAdminTokens` )
- Enhanced node monitoring (`/v2/GetNodeInfo` , `/v2/GetNodeStatistics` )
- Block management and repair tools (`/v2/GetBlockInfo` , `/v2/LaunchRepairOperation` )
2. **User Experience** : Continue improving the UI for mobile devices and add real-time updates.
3. **Monitoring Integration** : Enhanced Prometheus metrics visualization.
4. **Bulk Operations** : Support for bulk management of buckets and access keys.
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
## Risk Assessment
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
### ✅ Production Stable
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
- API path upgrade completed successfully.
2025-07-30 23:48:36 -04:00
- No compilation errors.
2025-07-31 17:19:15 -04:00
- Excellent backend compatibility.
- All features tested and working.
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
### ✅ Features Fully Operational
2025-07-15 15:59:47 +08:00
2025-07-31 17:19:15 -04:00
- All upgraded API endpoints working correctly.
- Error response handling optimized.
- API parameter formats fully compatible.
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
## Rollback Plan
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
To roll back to the v1 API if necessary:
2025-07-15 15:59:47 +08:00
2025-07-30 23:48:36 -04:00
1. Restore the API paths in all hook files.
2. Ensure the Garage server supports the v1 API.
3. Recompile and redeploy.
2025-07-15 15:59:47 +08:00
---
2025-07-31 17:19:15 -04:00
**Upgrade Complete**: The Garage Web UI has been successfully upgraded to Garage Admin API v2 and is currently running in production with enhanced functionality and better performance.