-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: percent calcuation and typescript deifinition in agent list (…
…#2690) ### TL;DR Refactored the AgentList component to improve type safety and code readability. ### What changed? - Improved type safety by explicitly defining types for `parsedOccupiedSlots` and `parsedAvailableSlots`. - Refactored the rendering logic for resource allocation to use a more consistent approach across different resource types. - Simplified calculations for percentage values and improved variable naming. - Consolidated duplicate code into reusable logic for CPU, memory, and other resource types. ### How to test? 1. Navigate to the Agent List view in the application. 2. Verify that the allocation information for CPU, memory, and other resources is displayed correctly. 3. Check that the progress bars accurately reflect the resource usage percentages. 4. Ensure that the color coding (red for high usage, green for normal usage) is working as expected. ### Why make this change? This refactoring improves code maintainability and reduces the likelihood of bugs by: 1. Enhancing type safety, which helps catch potential errors at compile-time. 2. Reducing code duplication, making it easier to update and maintain the component. 3. Improving readability, making it easier for developers to understand and work with the code. 4. Ensuring consistent handling of different resource types, which can simplify future additions or modifications to resource allocation display.
- Loading branch information
Showing
1 changed file
with
139 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters