Skip to content

feat(alert): improves deployment alerts UI#1512

Merged
ygrishajev merged 2 commits intomainfrom
feature/deployment-alerts-ui
Jun 20, 2025
Merged

feat(alert): improves deployment alerts UI#1512
ygrishajev merged 2 commits intomainfrom
feature/deployment-alerts-ui

Conversation

@ygrishajev
Copy link
Contributor

@ygrishajev ygrishajev commented Jun 18, 2025

Screen.Recording.2025-06-19.at.17.29.08.mov

Summary by CodeRabbit

  • New Features

    • Added a badge indicator to the "Alerts" tab in deployment details when there are unsaved changes to alert settings.
  • Refactor

    • Unified alert configuration into a single form with validation and streamlined submission in the deployment alerts section.
    • Simplified alert subcomponents to rely on a shared form context for state and validation, improving consistency and maintainability.
    • Updated notification channel selection to support disabled and error states, with improved accessibility and styling.
    • Refactored deployment alerts container to handle denomination and price-aware conversions for alert thresholds, enhancing data consistency.
    • Modified notification channels guard to use a function-as-children pattern for better data passing.
  • Bug Fixes

    • Improved error handling and user feedback for alert configuration actions.
  • Tests

    • Expanded and improved test coverage for deployment alerts and notification channel selection, including realistic data and new scenarios.
    • Refined tests to simulate user interactions and validate form behavior more accurately.
  • Chores

    • Removed unused components including the deployment balance container.
    • Added new test data builders for alerts.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 18, 2025

Walkthrough

This set of changes refactors the deployment alert management UI to use unified form handling with react-hook-form and zod validation, introduces denomination-aware threshold conversions, and streamlines alert components to be controlled by external form context. It also adds comprehensive test coverage, a new deployment alert seeder, and a visual badge indicator for unsaved changes on the Alerts tab.

Changes

File(s) Change Summary
.../DeploymentAlertsContainer/DeploymentAlertsContainer.tsx, .spec.tsx Refactored to accept full deployment object and dependencies; added denomination conversion, error handling, and expanded tests.
.../DeploymentAlerts/DeploymentAlerts.tsx, .spec.tsx Refactored to unified form with zod validation, dynamic max threshold, and consolidated alert updates; tests updated for user-driven form interaction.
.../DeploymentBalanceAlert/DeploymentBalanceAlert.tsx Refactored to use external form context; removed internal form state, validation, and submission logic.
.../DeploymentCloseAlert/DeploymentCloseAlert.tsx Refactored to use external form context; removed internal form state and submission logic.
.../NotificationChannelSelectForm/NotificationChannelSelect.tsx, .spec.tsx Refactored to accept dynamic field name and disabled state; improved error display and link handling; tests expanded for UI states.
.../NotificationChannelsGuard/NotificationChannelsGuard.tsx Changed to function-as-children pattern, passing notification channel list to children.
.../DeploymentDetail.tsx Added badge indicator for Alerts tab; tracks unsaved changes and updates tab badge state accordingly.
.../DeploymentBalanceContainer/DeploymentBalanceContainer.tsx Deleted component; balance calculation now handled in parent container/component.
.../tests/seeders/deploymentAlert.ts Added buildDeploymentAlert seeder for generating mock deployment alert data.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant DeploymentDetail
    participant DeploymentAlerts
    participant DeploymentAlertsContainer
    participant API

    User->>DeploymentDetail: Navigates to Alerts tab
    DeploymentDetail->>DeploymentAlerts: Renders Alerts form
    DeploymentAlerts->>DeploymentAlertsContainer: Requests current alert data
    DeploymentAlertsContainer->>API: Fetch deployment alerts
    API-->>DeploymentAlertsContainer: Returns alert data
    DeploymentAlertsContainer-->>DeploymentAlerts: Provides alert data, max threshold
    User->>DeploymentAlerts: Edits alert settings (enable, select channel, set threshold)
    DeploymentAlerts->>DeploymentAlertsContainer: Calls upsert with new settings
    DeploymentAlertsContainer->>API: Sends updated alert config
    API-->>DeploymentAlertsContainer: Confirms update
    DeploymentAlertsContainer-->>DeploymentAlerts: Notifies success, invalidates cache
    DeploymentAlerts->>DeploymentDetail: Triggers badge update if changes are unsaved
Loading

Possibly related PRs

  • akash-network/console#1441: Refactors validation and input constraints in DeploymentBalanceAlert, which is now superseded and replaced by these changes.
  • akash-network/console#1432: Implements backend API routes and controller for deployment alerts, directly supporting the frontend logic in this PR.
  • akash-network/console#1400: Simplifies container tests by introducing a child capturer utility for invoking container methods directly; related to test improvements in alert components.

Suggested reviewers

  • baktun14

Poem

In the garden of code, where alerts now bloom,
Forms unified, errors banished to their tomb.
Badges on tabs, a crimson delight,
Rabbits rejoice—UI feels just right!
With channels and thresholds, conversions anew,
🐇 Cheers to the team, and the code they grew!

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-20T10_29_34_451Z-debug-0.log


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3095cd9 and ff59646.

📒 Files selected for processing (3)
  • apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx (3 hunks)
  • apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.spec.tsx (1 hunks)
  • apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx
  • apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: test-deploy-web-build
  • GitHub Check: validate-deploy-web
🔇 Additional comments (5)
apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.spec.tsx (5)

8-8: LGTM! Good use of test seeder.

The import of buildNotificationChannel from test seeders follows best practices for generating consistent test data.


10-16: LGTM! Well-structured test for empty state.

The test properly verifies both the select element and placeholder text are rendered when no data is provided.


24-29: LGTM! Good coverage of disabled state.

The test correctly verifies that the select element becomes disabled when the disabled prop is true.


31-37: LGTM! Excellent error state testing.

The test comprehensively verifies both visual error styling (red border) and error message display, providing good coverage of form validation feedback.


62-85: LGTM! Well-designed setup helper function.

The setup function provides excellent reusability with:

  • Proper form context creation using react-hook-form
  • Flexible parameter handling for different test scenarios
  • Correct error injection mechanism for testing validation states
  • Clean separation of test data generation

This approach makes the tests more maintainable and follows testing best practices.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ygrishajev ygrishajev force-pushed the feature/deployment-alerts-ui branch from 503a175 to f28e2ae Compare June 19, 2025 15:26
TODO:
- unit tests
- prompt to confirm user action when leaving the page with unsaved changes
@ygrishajev ygrishajev force-pushed the feature/deployment-alerts-ui branch from f28e2ae to dd07644 Compare June 19, 2025 15:27
@codecov
Copy link

codecov bot commented Jun 19, 2025

Codecov Report

Attention: Patch coverage is 72.89720% with 29 lines in your changes missing coverage. Please review.

Project coverage is 40.50%. Comparing base (fc814db) to head (ff59646).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...eb/src/components/deployments/DeploymentDetail.tsx 0.00% 8 Missing ⚠️
...ymentAlertsContainer/DeploymentAlertsContainer.tsx 83.33% 7 Missing ⚠️
.../deployments/DeploymentAlerts/DeploymentAlerts.tsx 86.11% 5 Missing ⚠️
...ionChannelSelectForm/NotificationChannelSelect.tsx 55.55% 4 Missing ⚠️
.../DeploymentBalanceAlert/DeploymentBalanceAlert.tsx 50.00% 3 Missing ⚠️
...ents/DeploymentCloseAlert/DeploymentCloseAlert.tsx 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1512      +/-   ##
==========================================
+ Coverage   40.33%   40.50%   +0.16%     
==========================================
  Files         872      871       -1     
  Lines       21097    21115      +18     
  Branches     3838     3835       -3     
==========================================
+ Hits         8510     8553      +43     
- Misses      11857    12243     +386     
+ Partials      730      319     -411     
Flag Coverage Δ *Carryforward flag
api 71.38% <ø> (ø) Carriedforward from dd07644
deploy-web 18.68% <72.89%> (+0.30%) ⬆️
notifications 89.21% <ø> (ø) Carriedforward from dd07644
provider-proxy 82.10% <ø> (ø) Carriedforward from dd07644

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...icationChannelsGuard/NotificationChannelsGuard.tsx 100.00% <100.00%> (ø)
...ents/DeploymentCloseAlert/DeploymentCloseAlert.tsx 75.00% <60.00%> (+28.33%) ⬆️
.../DeploymentBalanceAlert/DeploymentBalanceAlert.tsx 70.00% <50.00%> (+31.76%) ⬆️
...ionChannelSelectForm/NotificationChannelSelect.tsx 76.47% <55.55%> (-18.27%) ⬇️
.../deployments/DeploymentAlerts/DeploymentAlerts.tsx 88.09% <86.11%> (-11.91%) ⬇️
...ymentAlertsContainer/DeploymentAlertsContainer.tsx 87.50% <83.33%> (-12.50%) ⬇️
...eb/src/components/deployments/DeploymentDetail.tsx 0.00% <0.00%> (ø)

... and 136 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ygrishajev ygrishajev marked this pull request as ready for review June 19, 2025 15:35
@ygrishajev ygrishajev requested a review from a team as a code owner June 19, 2025 15:35
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.spec.tsx (1)

40-53: Verify disabled link accessibility.

The test checks for opacity-10 and cursor-not-allowed classes, but ensure the disabled link is also properly marked as disabled for screen readers. Consider adding aria-disabled="true" or similar accessibility attributes.

apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentAlerts.tsx (1)

108-114: Consider performance optimization for change detection.

The deep comparison using isEqual on every form value change could be performance-intensive for complex forms. Consider debouncing or optimizing this check if performance becomes an issue.

+ import { useCallback, useMemo } from "react";
+ import { debounce } from "lodash";

+ const debouncedCompare = useMemo(
+   () => debounce((provided: any, current: any) => {
+     const hasChangesNext = !isEqual(provided, current);
+     if (hasChanges !== hasChangesNext) {
+       setHasChanges(hasChangesNext);
+       onStateChange({ hasChanges: hasChangesNext });
+     }
+   }, 300),
+   [providedValues, onStateChange, hasChanges]
+ );

  useEffect(() => {
-   const hasChangesNext = !isEqual(providedValues, values);
-   if (hasChanges !== hasChangesNext) {
-     setHasChanges(hasChangesNext);
-     onStateChange({ hasChanges: hasChangesNext });
-   }
+   debouncedCompare(providedValues, values);
  }, [providedValues, onStateChange, values, hasChanges]);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc814db and dd07644.

📒 Files selected for processing (12)
  • apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx (5 hunks)
  • apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.tsx (3 hunks)
  • apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.spec.tsx (1 hunks)
  • apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.tsx (2 hunks)
  • apps/deploy-web/src/components/alerts/NotificationChannelsGuard/NotificationChannelsGuard.tsx (2 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentAlerts.spec.tsx (1 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentAlerts.tsx (1 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentBalanceAlert/DeploymentBalanceAlert.tsx (1 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentBalanceContainer/DeploymentBalanceContainer.tsx (0 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentCloseAlert/DeploymentCloseAlert.tsx (1 hunks)
  • apps/deploy-web/src/components/deployments/DeploymentDetail.tsx (7 hunks)
  • apps/deploy-web/tests/seeders/deploymentAlert.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/deploy-web/src/components/deployments/DeploymentBalanceContainer/DeploymentBalanceContainer.tsx
🧰 Additional context used
🧠 Learnings (1)
apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.tsx (1)
Learnt from: baktun14
PR: akash-network/console#1432
File: apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentCloseAlert.tsx:38-38
Timestamp: 2025-06-05T21:07:51.985Z
Learning: The ContactPointSelect component in apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx uses the useFormContext hook internally to connect to React Hook Form, so it doesn't need to be wrapped in a FormField component.
🔇 Additional comments (37)
apps/deploy-web/tests/seeders/deploymentAlert.ts (1)

1-26: LGTM! Well-structured test data seeder.

The seeder implementation is excellent:

  • Proper TypeScript typing with imported schema types
  • Realistic faker usage for generating test data
  • Reasonable default values and threshold ranges
  • Flexible override pattern for customization
  • Supports both alert types with appropriate properties
apps/deploy-web/src/components/alerts/NotificationChannelsGuard/NotificationChannelsGuard.tsx (3)

11-11: Good addition of FCWithFnChildren import.

The import properly supports the new function-as-children pattern being implemented.


40-40: Excellent architectural improvement with render prop pattern.

The type change from FCWithChildren to FCWithFnChildren<object, ChildrenProps> properly implements the function-as-children pattern, providing better data flow and component flexibility.


45-45: Proper implementation of function-as-children pattern.

The change from {children} to {children(notificationChannelList)} correctly passes the notification channel data as a function argument, enabling consuming components to access this data directly.

apps/deploy-web/src/components/deployments/DeploymentCloseAlert/DeploymentCloseAlert.tsx (4)

5-6: Good import changes for form context integration.

The imports properly support the refactor to use react-hook-form context and UI components for controlled form handling.


11-12: Excellent simplification to controlled component pattern.

The component signature and context usage properly implement the refactor to consume external form context instead of managing internal form state.


17-32: Well-implemented checkbox integration in fieldset label.

The "Enabled" checkbox is properly integrated using FormField with form context control. The positioning in the fieldset label provides good UX, and the disabled state flows through correctly.


37-39: Proper integration with controlled NotificationChannelSelect.

The NotificationChannelSelect usage with explicit name and disabled props aligns well with the centralized form management approach and maintains proper form field binding.

apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentAlerts.spec.tsx (4)

1-11: Excellent test setup improvements.

The updated imports and seeder usage provide more realistic and consistent test data, supporting the refactored component architecture.


13-47: Outstanding test refactor with realistic user interaction simulation.

The test now properly simulates user interactions with fireEvent instead of directly calling component methods. This provides much better test coverage and validates the actual user experience with the form.


54-78: Well-implemented mock components using form context.

The mock alert components properly use useFormContext and register form fields, accurately reflecting the refactored component architecture and enabling realistic form testing.


81-110: Improved test setup with seeded data and updated props.

The component props setup uses seeded data builders for consistency and includes the new props structure (maxBalanceThreshold, onStateChange) that align with the refactored component interface.

apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.tsx (5)

13-17: Good TypeScript interface for external props.

The ExternalProps type properly defines the required name and optional disabled props, supporting the refactor to make this a controlled component.


20-27: Excellent integration with form context and disabled state styling.

The component properly uses form context and implements good UX with disabled state styling on the label (cursor-not-allowed, red color). The dynamic form field naming via the name prop is well-implemented.


32-56: Outstanding form field integration with validation and error handling.

The FormField implementation is excellent:

  • Proper controlled select with form context binding
  • Visual error indication with red border on validation errors
  • Error message display below the field
  • Disabled state properly propagated to the select
  • Good accessibility with proper id and data-testid attributes

59-73: Well-implemented disabled state handling for the action link.

The link styling and click prevention when disabled provides good UX - users can clearly see the disabled state (opacity, cursor) and clicks are properly prevented.


79-83: Clean wrapper component implementation.

The wrapper properly forwards external props to the view component while maintaining the data container pattern.

apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.spec.tsx (1)

63-86: Well-structured test setup with good flexibility.

The new setup helper function provides excellent flexibility for testing different scenarios. The form context setup with conditional error handling is well-implemented.

apps/deploy-web/src/components/deployments/DeploymentDetail.tsx (3)

53-53: Good state management for badge functionality.

The badgedTabs state structure allows for extensibility to other tabs in the future while maintaining clean organization.


191-198: Properly memoized callback with correct dependencies.

The recordAlertsChange callback is correctly memoized with useCallback and includes the proper dependencies to prevent unnecessary re-renders.


265-267: Efficient conditional rendering approach.

Using CSS classes to conditionally show/hide the DeploymentAlerts component is more efficient than conditional rendering, as it avoids component unmounting/remounting when switching tabs.

apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.tsx (4)

43-51: Good dependency injection pattern for testability.

The dependencies injection pattern makes the component more testable by allowing mock implementations of external dependencies like pricing context.


67-87: Robust error handling in conversion logic.

The convert function properly handles edge cases where conversion might fail, throwing descriptive errors. The null checks for AKT conversion are important for reliability.


130-147: Improved error handling with async upsert.

Moving error handling inside the upsert function and making it async is a good pattern. This centralizes error management and provides better user feedback through notifications.


89-104: To understand how deeply nested alerts can be and whether merge might overwrite or drop fields, let’s pull in the type and surrounding code:

#!/bin/bash
# 1. Print the top of the container file to find the ContainerInput definition/imports
sed -n '1,200p' apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.tsx

# 2. Search within that directory for where ContainerInput is defined
rg -n "ContainerInput" -C 5 apps/deploy-web/src/components/alerts/DeploymentAlertsContainer
apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx (3)

238-254: Comprehensive pricing context mocking.

The mock pricing implementation with realistic conversion rates (1.5 for AKT, 1 for USDC) properly simulates the pricing context functionality needed for testing denomination conversions.


73-186: Excellent test coverage for different alert configurations.

The test cases cover all possible alert combinations (deployment closed only, balance only, and both) which ensures the container handles all expected scenarios correctly.


194-204: Good verification of side effects.

Testing query invalidation on successful mutation ensures the component properly refreshes cached data, which is crucial for maintaining data consistency.

apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentAlerts.tsx (4)

34-44: Well-structured zod schema for validation.

The schema structure clearly defines validation rules for both alert types with appropriate error messages. This provides good user feedback.


77-83: Dynamic schema validation with runtime constraints.

The dynamic schema extension with maxBalanceThreshold validation is a good approach for ensuring thresholds don't exceed available balance. This prevents user errors.


85-97: Smart default values calculation.

The logic for calculating default values (30% of max balance threshold, first notification channel) provides sensible defaults that improve user experience.


116-121: Robust form submission with error handling.

The async submission with conditional form reset only on success is a good pattern that maintains form state if the operation fails.

apps/deploy-web/src/components/deployments/DeploymentBalanceAlert/DeploymentBalanceAlert.tsx (5)

5-5: LGTM: Clean integration with react-hook-form

The addition of useFormContext aligns well with the refactoring goal of centralizing form management.


13-14: LGTM: Good addition of disabled prop

The optional disabled prop provides proper control over the component's interactive state, which is essential for form management.


24-36: LGTM: Well-structured checkbox integration

The FormField integration with CheckboxWithLabel follows react-hook-form best practices. The controlled component pattern is properly implemented with proper type casting for the boolean value.


52-66: LGTM: Good accessibility and UX design

The form input implementation includes:

  • Proper labeling with tooltip for user guidance
  • Appropriate step value (0.000001) for USD precision
  • Clear indication that the threshold is in USD
  • Proper disabled state handling

The CustomTooltip with InfoCircle provides helpful context for users.


16-17: ```shell
#!/bin/bash

Verify that DeploymentAlerts wraps its children in a FormProvider

grep -n "FormProvider" -n apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentAlerts.tsx
grep -n "useForm" -n apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentAlerts.tsx


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

stalniy
stalniy previously approved these changes Jun 20, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dd07644 and 3095cd9.

📒 Files selected for processing (3)
  • apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx (3 hunks)
  • apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.spec.tsx (1 hunks)
  • apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/deploy-web/src/components/alerts/DeploymentAlertsContainer/DeploymentAlertsContainer.spec.tsx
🧰 Additional context used
🧠 Learnings (1)
apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.tsx (1)
Learnt from: baktun14
PR: akash-network/console#1432
File: apps/deploy-web/src/components/deployments/DeploymentAlerts/DeploymentCloseAlert.tsx:38-38
Timestamp: 2025-06-05T21:07:51.985Z
Learning: The ContactPointSelect component in apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx uses the useFormContext hook internally to connect to React Hook Form, so it doesn't need to be wrapped in a FormField component.
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: validate-deploy-web
  • GitHub Check: test-deploy-web-build
🔇 Additional comments (6)
apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.spec.tsx (2)

14-16: LGTM: Following testing best practices.

Good use of getByLabelText as recommended in the past review comment, avoiding unnecessary test-ids for form field queries.


62-85: Well-structured test setup helper.

The setup function provides good flexibility for testing different scenarios with configurable data, disabled state, and field errors. The form context setup with proper error handling is excellent.

apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.tsx (4)

13-18: Clean props interface design.

The separation of external props and internal props with proper TypeScript typing provides good component API design.


25-27: Good conditional styling for disabled state.

The label properly reflects the disabled state with appropriate visual feedback using conditional classes.


55-69: Excellent disabled link behavior.

The link properly handles disabled state with visual feedback and prevents navigation when disabled. The preventDefault approach ensures proper UX.


29-53: ```shell
#!/bin/bash

Verify whether NotificationChannelSelect uses useFormContext internally

grep -R "useFormContext" -n apps/deploy-web/src/components/alerts/NotificationChannelSelectForm/NotificationChannelSelect.tsx || echo "NotificationChannelSelect: no useFormContext"

Confirm ContactPointSelect uses useFormContext and is not wrapped in FormField

grep -R "useFormContext" -n apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx || echo "ContactPointSelect: no useFormContext"
grep -R "FormField" -n apps/deploy-web/src/components/alerts/ContactPointSelectForm/ContactPointSelect.tsx || echo "ContactPointSelect: no FormField wrapper"


</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@ygrishajev ygrishajev force-pushed the feature/deployment-alerts-ui branch from 3095cd9 to ff59646 Compare June 20, 2025 10:28
@ygrishajev ygrishajev merged commit 04a55a9 into main Jun 20, 2025
27 checks passed
@ygrishajev ygrishajev deleted the feature/deployment-alerts-ui branch June 20, 2025 10:35
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.

2 participants

Comments