Ref: Improved Readability and Maintainability of PowerPlantsDetail implementations#110
Merged
mergify[bot] merged 17 commits intocanaryfrom Jan 23, 2025
Merged
Ref: Improved Readability and Maintainability of PowerPlantsDetail implementations#110mergify[bot] merged 17 commits intocanaryfrom
mergify[bot] merged 17 commits intocanaryfrom
Conversation
This component is used to wrap the contents of the power-plants/[id] details page within a Context provider. This way it can be used to access properties of the context within client-side components with ease.
Externalized the buttons used within the power-plants-details page into a separate client-side component.
This component is used to render the different water-gate related options, e.g. closing, opening the gate. Note that this component is rendered conditionally, depending on whether or not the management is enabled.
This endpoint is used to simulate a fetch request of an external API to gather a given PowerPlant.
Made some major improvements to the power-plants/[id] detail page by using newly created components to improve readability and maintainability.
Reverted the introduction of the query argument to the Link component within the PowerPlantPreview component, because it is no longer needed.
The reason for this change is that the use searchParams was removed, thereby resulting in a failing test-case.
Codecov ReportAll modified and coverable lines are covered by tests ✅
|
Contributor
|
Auto-Assigned MrsicMarko as a Reviewer to this Pull Request. |
The reason for this change is that the name is used to fetch a given power-plants information from the api and not the id.
This change was made within the PowerPlantPreview component for the name of a given powerplant.
The reason for this change is that the id property does not reflect the id of the power-plant but the id of the db-row that returned the information. This means that the id always increases by the amount of power-plants stored.
Fixed a typo in the base_endpoint property that is used to send commands to the given api. Changed the value of this property from the Database to the Control api endpoint.
Update the fetch request and response of the power-plant detail fetch retrieval to follow the api implementation.
This reverts commit 9476bb2.
MrsicMarko
approved these changes
Jan 23, 2025
Contributor
|
This Pull request satisfies all status-checks and will be automatically merged soon. |
Member
Author
|
🎉 This PR is included in version 1.14.0-canary.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Member
Author
|
🎉 This PR is included in version 1.14.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant updates to the power plant detail page and related components. The changes focus on refactoring the code to improve maintainability and readability.
Refactoring and Code Simplification:
app/power-plants/[id]/page.tsx: Refactored to use new componentsPowerPlantDetailProvider,DetailsActionButtons, andWatergateManagementView. Removed inline state management and fetch logic. (app/power-plants/[id]/page.tsxL1-R39)components/power-plants/PowerPlantPreview.tsx: Reverted thehrefproperty to redirect topower-plants/<name>, by default.New Components:
components/power-plants/[id]/DetailsActionButtons.tsx: Created a new component to render and handle the Action Button related tasks of the detail page. (components/power-plants/[id]/DetailsActionButtons.tsxR1-R57)components/power-plants/[id]/PowerPlantDetailProvider.tsx: Introduced a new context provider to manage the state and logic related to power plant details. (components/power-plants/[id]/PowerPlantDetailProvider.tsxR1-R43)components/power-plants/[id]/WatergateManagementView.tsx: Added a new component for managing water gate configurations. (components/power-plants/[id]/WatergateManagementView.tsxR1-R45)API Integration:
app/api/powerplants/[id]/route.ts: Added a new dummy API route to fetch power plant details usingNextRequestandNextResponse. (app/api/powerplants/[id]/route.tsR1-R10)Test Updates:
tests/jest/power-plants/PowerPlantPreview.test.tsx: Updated tests to reflect the changes inPowerPlantPreviewcomponent and the removal of encoded query parameters. [1] [2]