Skip to content

feat(contact-point): implements edit ui#1413

Merged
ygrishajev merged 10 commits intoakash-network:mainfrom
domhhv:feat/contact-point-edit-ui
Jun 3, 2025
Merged

feat(contact-point): implements edit ui#1413
ygrishajev merged 10 commits intoakash-network:mainfrom
domhhv:feat/contact-point-edit-ui

Conversation

@domhhv
Copy link
Contributor

@domhhv domhhv commented May 29, 2025

Closes #1396

TODO:

  • add tests

Screenshot:

Screenshot 2025-06-04 at 19 38 35

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced the ability to edit contact points, including updating names and email addresses.
    • Added form validation for email addresses with inline validation on submit and improved form reset behavior when editing existing contact points.
    • Implemented success and error notifications for edit operations.
    • Enhanced navigation, allowing users to return to the contact points list after editing.
    • Simplified layout and navigation for creating and editing contact points with custom headers and back links.
  • Bug Fixes

    • Improved handling of email input and validation to ensure accurate data entry.
  • Tests

    • Added tests for contact point editing functionality, covering success and error notification scenarios.
    • Updated form validation tests to reflect refined validation behavior.
  • Style

    • Updated tab layout to display fewer tabs per row for better visual arrangement.

@domhhv domhhv requested a review from a team as a code owner May 29, 2025 19:47
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 29, 2025

Walkthrough

A new contact point editing feature was implemented, introducing a container component for managing API interactions and form state. The contact point form was refactored to simplify email handling and validation. The edit page was updated to use these components, enabling full edit functionality and navigation upon completion or cancellation. A test suite was added to verify the container's API interactions and notification behavior.

Changes

File(s) Change Summary
.../ContactPointEditContainer/ContactPointEditContainer.tsx Added new container component for fetching, updating, and managing edit state of contact points.
.../ContactPointEditContainer/ContactPointEditContainer.spec.tsx Added tests for ContactPointEditContainer covering successful patch and error notification scenarios.
.../ContactPointForm/ContactPointForm.tsx Refactored form: simplified email validation, changed emails field to array, updated submit/reset logic.
.../ContactPointForm/ContactPointForm.spec.tsx Modified validation test to simulate partial form submission with filled name field.
.../EditContactPointPage.tsx Implemented edit page: integrated container, form, and navigation for editing contact points.
.../AlertsLayout.tsx Reduced TabsList grid columns from six to two for layout adjustment.
.../CreateContactPointPage.tsx Refactored page layout: replaced AlertsLayout with simpler Layout and custom header with back link.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EditPage
    participant EditContainer
    participant API
    participant Form

    User->>EditPage: Navigates to edit page
    EditPage->>EditContainer: Mounts with contact point ID
    EditContainer->>API: Patch contact point on edit
    API-->>EditContainer: Returns success or error
    EditContainer->>Form: Passes onEdit handler and loading state
    User->>Form: Edits and submits form
    Form->>EditContainer: Calls edit handler with new values
    EditContainer->>EditPage: Calls onEditSuccess callback on success
    EditPage->>User: Navigates back or shows notification
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement contact point edit view reusing ContactPointForm and following CreateContactPointsPage
Implement a dedicated edit container managing API mutation and state
Show notifications about mutation state (success/error)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes detected.

Possibly related PRs

Suggested reviewers

  • ygrishajev

Poem

🐇
In fields of forms, I hop with glee,
Editing contacts, so easily!
Emails now in strings, not arrays,
Validation clear as sunny rays.
A click, a patch, a gentle cheer—
The edit page is live this year!
🥕

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-03T12_59_06_434Z-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 dd3e1db and 20adaa0.

📒 Files selected for processing (1)
  • apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test-deploy-web-build
✨ 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.

@codecov
Copy link

codecov bot commented May 29, 2025

Codecov Report

Attention: Patch coverage is 61.22449% with 19 lines in your changes missing coverage. Please review.

Project coverage is 37.09%. Comparing base (449a646) to head (20adaa0).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...web/src/components/alerts/EditContactPointPage.tsx 0.00% 11 Missing ⚠️
...nents/alerts/ContactPointForm/ContactPointForm.tsx 77.77% 4 Missing ⚠️
...b/src/components/alerts/CreateContactPointPage.tsx 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1413      +/-   ##
==========================================
+ Coverage   37.07%   37.09%   +0.02%     
==========================================
  Files         831      832       +1     
  Lines       19799    19827      +28     
  Branches     3633     3646      +13     
==========================================
+ Hits         7340     7355      +15     
+ Misses      12128    11750     -378     
- Partials      331      722     +391     
Flag Coverage Δ *Carryforward flag
api 68.14% <ø> (-0.04%) ⬇️ Carriedforward from dd3e1db
deploy-web 15.84% <61.22%> (+0.10%) ⬆️
notifications 88.50% <ø> (ø) Carriedforward from dd3e1db
provider-proxy 80.09% <ø> (ø) Carriedforward from dd3e1db

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

Files with missing lines Coverage Δ
.../deploy-web/src/components/alerts/AlertsLayout.tsx 0.00% <ø> (ø)
...ctPointEditContainer/ContactPointEditContainer.tsx 100.00% <100.00%> (ø)
...nents/alerts/ContactPointForm/ContactPointForm.tsx 83.33% <77.77%> (-4.17%) ⬇️
...b/src/components/alerts/CreateContactPointPage.tsx 0.00% <0.00%> (ø)
...web/src/components/alerts/EditContactPointPage.tsx 0.00% <0.00%> (ø)

... and 138 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.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 88a3f61 and 6c5fb77.

📒 Files selected for processing (3)
  • apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.tsx (1 hunks)
  • apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx (4 hunks)
  • apps/deploy-web/src/components/alerts/EditContactPointPage.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/deploy-web/src/components/alerts/EditContactPointPage.tsx (4)
apps/deploy-web/src/components/alerts/AlertsLayout.tsx (1)
  • AlertsLayout (27-66)
apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.tsx (1)
  • ContactPointEditContainer (24-76)
apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx (1)
  • ContactPointForm (48-172)
apps/deploy-web/src/utils/urlUtils.ts (1)
  • UrlService (16-75)
apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.tsx (3)
packages/http-sdk/src/generated/NotificationSDK.ts (1)
  • ContactPointPatchInput (277-284)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (32-34)
apps/deploy-web/src/hooks/useNotificator.tsx (1)
  • useNotificator (5-19)
🪛 GitHub Actions: Deploy Web CI
apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.tsx

[error] 27-27: Type error: No overload matches this call. Argument of type '{ path: { id: string | string[]; }; }' is not assignable to parameter of type 'void'. Type 'string | string[]' is not assignable to type 'string'.

🔇 Additional comments (4)
apps/deploy-web/src/components/alerts/EditContactPointPage.tsx (1)

2-27: LGTM! Clean implementation of the edit contact point feature.

The implementation effectively uses the container pattern to separate data management from UI concerns. The navigation logic is appropriate - using router.back() for successful edits and redirecting to the contact points list for cancellation.

apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.tsx (1)

39-76: Excellent container pattern implementation.

The container effectively manages:

  • Data fetching and mutation logic
  • Success/error notification handling
  • Proper data transformation (emails array ↔ comma-separated string)
  • Clean render props pattern for passing data to child components

The use of useWhen hooks for side effects and proper dependency arrays in useCallback demonstrates good React patterns.

apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx (2)

17-37: Well-designed email validation for comma-separated input.

The validation logic properly:

  • Splits comma-separated emails and trims whitespace
  • Filters out empty strings
  • Validates each email individually using Zod's email validator
  • Provides clear error messages

This is a clean approach for handling multiple emails in a single input field.


70-89: Good form management and data transformation logic.

The implementation effectively:

  • Prevents unnecessary form resets by checking if the form is empty before applying new values
  • Transforms the comma-separated email string back to an array format expected by the container
  • Uses appropriate revalidation mode for edit scenarios

The data flow integration with the container component is seamless.

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 (1)
apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.tsx (1)

68-80: Consider adding query state handling.

The render prop implementation is solid with proper fallbacks. However, consider exposing query loading/error states to provide better UX while fetching initial data.

  return (
    <>
      {children({
        values: {
          name: query.data?.data?.name ?? "",
          emails: query.data?.data?.config.addresses ?? []
        },
        onEdit: edit,
-       isLoading: mutation.isPending
+       isLoading: mutation.isPending,
+       isQueryLoading: query.isLoading,
+       queryError: query.error
      })}
    </>
  );
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 6c5fb77 and 55b8c38.

📒 Files selected for processing (4)
  • apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.spec.tsx (1 hunks)
  • apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.tsx (1 hunks)
  • apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx (3 hunks)
  • apps/deploy-web/src/components/alerts/EditContactPointPage.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/deploy-web/src/components/alerts/EditContactPointPage.tsx
  • apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.tsx (3)
packages/http-sdk/src/generated/NotificationSDK.ts (1)
  • ContactPointPatchInput (277-284)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (32-34)
apps/deploy-web/src/hooks/useNotificator.tsx (1)
  • useNotificator (5-19)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test-deploy-web-build
🔇 Additional comments (8)
apps/deploy-web/src/components/alerts/ContactPointEditContainer/ContactPointEditContainer.spec.tsx (3)

1-18: LGTM: Well-structured test setup.

The test imports and setup are comprehensive, properly using testing utilities, faker for data generation, and necessary context providers.


20-49: LGTM: Comprehensive success test case.

The test properly verifies the API call structure and success notification behavior. Good use of waitFor for async testing.


84-120: LGTM: Well-designed test setup function.

The setup function properly configures mocks, test data, and context providers. Good use of the container testing utility to capture child props.

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

12-27: LGTM: Well-structured type definitions.

The type definitions properly leverage TypeScript's utility types and create a clean contract for the component. Good that id is now a prop rather than extracted from URL params, addressing previous review concerns.


29-41: LGTM: Proper component setup.

The component correctly uses hooks and context providers. The API calls are properly configured with the id prop, which resolves the previous type concerns with useParams().


43-55: LGTM: Well-implemented edit function.

The edit callback properly transforms the input data for the API call and uses useCallback for performance optimization.


57-64: LGTM: Proper success handling.

The success notification and callback handling are correctly implemented with appropriate dependencies and test IDs.


66-66: LGTM: Basic error handling implemented.

The error notification is properly triggered on mutation failure with the correct test ID.

@ygrishajev
Copy link
Contributor

a couple of non blocking improvement suggestions:

  1. remove duplicate emails
  2. disable submit button if no changes to the form are made

Copy link
Contributor

@ygrishajev ygrishajev left a comment

Choose a reason for hiding this comment

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

Ok, so just to keep it visible. The page not has contact point resolution via getServerSideProps. Meaning that:

  1. container should not query a contact point if it's already on the props
  2. the form provided values should be renamed to initialValues and treated as such - only set once via defatultValues; all the logic trying to fix form states should be now removed possibly as it should just work as is normally

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: 0

🧹 Nitpick comments (2)
apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx (2)

78-78: Update error message to be context-appropriate.

The error message mentions "create" but this form is used for both creating and editing contact points.

-        setError("Failed to create contact point. Please try again.");
+        setError("Failed to save contact point. Please try again.");

101-101: Make header dynamic based on context.

The header currently says "New Email Contact Point" but this form is used for both creating and editing. Consider making it dynamic based on whether initialValues are provided.

-      <h2 className="text-lg font-semibold">New Email Contact Point</h2>
+      <h2 className="text-lg font-semibold">
+        {initialValues?.name ? "Edit Email Contact Point" : "New Email Contact Point"}
+      </h2>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b3535f3 and 410ad7c.

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

14-17: LGTM: Email validation schema simplified appropriately.

The email validation has been moved from schema preprocessing to runtime validation in the submit handler, which provides better error handling and user feedback.


19-19: Good type separation for form vs. data values.

The DataValues type properly distinguishes between the form's internal string representation and the external array format expected by the API.


22-36: Props interface updated correctly for edit functionality.

The interface properly supports both create and edit scenarios with optional initialValues and appropriate default values.


40-45: Initial values transformation implemented correctly.

The memoized transformation from array to comma-separated string handles the form's internal representation properly.


55-82: Email parsing and validation logic is robust.

The submit handler properly addresses the previous review feedback by filtering empty strings and handles validation, deduplication, and error reporting well. The use of Array.from(new Set(...)) for deduplication is a good practice.


86-89: Change detection logic implemented correctly.

The hasChanges logic properly compares current form values with initial values to enable/disable submission appropriately.


145-145: Submit button correctly disabled when no changes.

The button properly implements the requirement from the PR feedback to disable submission when no changes have been made, improving UX by preventing unnecessary API calls.

ygrishajev
ygrishajev previously approved these changes Jun 3, 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: 1

🧹 Nitpick comments (1)
apps/deploy-web/src/components/alerts/CreateContactPointPage.tsx (1)

25-27: Consider navigation consistency.

The navigation callbacks use different approaches:

  • onCreate uses router.back() (browser back)
  • onCancel uses router.push(UrlService.contactPoints()) (specific route)

This inconsistency might confuse users about where they'll end up after different actions.

For consistency, consider using the same navigation approach for both callbacks:

-      <ContactPointCreateContainer onCreate={router.back}>
+      <ContactPointCreateContainer onCreate={() => router.push(UrlService.contactPoints())}>

This ensures users always return to the contact points list regardless of the action taken.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 410ad7c and dd3e1db.

📒 Files selected for processing (4)
  • apps/deploy-web/src/components/alerts/AlertsLayout.tsx (1 hunks)
  • apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx (3 hunks)
  • apps/deploy-web/src/components/alerts/CreateContactPointPage.tsx (1 hunks)
  • apps/deploy-web/src/components/alerts/EditContactPointPage.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • apps/deploy-web/src/components/alerts/AlertsLayout.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/deploy-web/src/components/alerts/EditContactPointPage.tsx
  • apps/deploy-web/src/components/alerts/ContactPointForm/ContactPointForm.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test-deploy-web-build
🔇 Additional comments (2)
apps/deploy-web/src/components/alerts/CreateContactPointPage.tsx (2)

2-3: LGTM! Imports look correct.

The new imports for navigation and UI components align well with the refactored header structure.

Also applies to: 10-10


17-28: Well-structured refactor with clean separation.

The refactor successfully replaces the previous AlertsLayout/AlertTabs structure with a cleaner, more focused layout. The render props pattern with ContactPointCreateContainer provides good separation of concerns between UI and business logic.

@ygrishajev ygrishajev merged commit e370baf into akash-network:main Jun 3, 2025
27 checks passed
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.

Implement contact point edit vew

3 participants

Comments