Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Confirmation Pop-up to Prevent Accidental Exception Deletions #10283

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from

Conversation

modamaan
Copy link
Contributor

@modamaan modamaan commented Jan 30, 2025

Proposed Changes

Vinu.TV._.CARE.-.confirm.dialog.2025-01-31.01-44-05.mp4

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced confirmation dialogs for deleting schedule exceptions, removing availability entries, and deleting schedule templates, enhancing user interaction and reducing accidental deletions.
    • Enhanced user prompts with clearer confirmation messages and warnings regarding the permanent removal of templates.
  • Bug Fixes

    • Improved user experience by preventing accidental deletions through confirmation steps.

@modamaan modamaan requested a review from a team as a code owner January 30, 2025 02:01
Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

The pull request implements confirmation dialogs for deleting schedule exceptions, removing availability entries, and deleting schedule templates across various components. The previous direct delete actions are replaced with dialogs that require user confirmation before proceeding. Additionally, new localization keys are added to support confirmation messages, enhancing user interaction and preventing accidental deletions.

Changes

File Change Summary
src/pages/Scheduling/ScheduleExceptions.tsx, src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx, src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx Introduced dialog confirmation mechanisms for deleting schedule exceptions, removing availability entries, and deleting schedule templates. Added state variables to manage dialog visibility.
public/locale/en.json Added new localization keys for confirmation messages related to deletions and updated existing keys to reflect changes in messaging.

Assessment against linked issues

Objective Addressed Explanation
Add Confirmation Pop-up for Exception Deletion [#10259] A confirmation dialog has been implemented for deleting schedule exceptions.

Possibly related PRs

  • User Availabilities Exception related fixes #9977: The changes in the main PR, which involve adding a confirmation dialog for deleting schedule exceptions, are related to the modifications in the retrieved PR that also focus on user interactions with exceptions, specifically in the context of managing availability entries and exceptions. Both PRs enhance user confirmation processes before deletion actions.
  • Confirm Dialog For Navigation on Edited Questionnaire Form #9838: The changes in the main PR, which involve adding a confirmation dialog for deleting schedule exceptions, are related to the retrieved PR that also implements a confirmation dialog, but for navigating away from an edited questionnaire form, as both modifications enhance user interaction by requiring confirmation before proceeding with potentially destructive actions.
  • Fix the accessibility issue by adding DialogTitle to DialogContent and making the facility title responsive #10106: The changes in the main PR, which involve implementing a confirmation dialog for deleting schedule exceptions, are related to the changes in the retrieved PR that also focus on enhancing dialog functionality by adding a DialogTitle for accessibility. Both PRs modify dialog components to improve user interaction and confirmation processes.

Suggested labels

needs testing, needs review

Suggested reviewers

  • rithviknishad
  • Jacobjeevan

Poem

🐰 In the garden of schedules, we take great care,
A dialog appears, a moment to spare.
"Are you sure?" it asks, with a gentle nudge,
No more accidental clicks, we won't hold a grudge!
With templates and exceptions, deletion's a breeze,
A rabbit's delight, with confirmations to please! 🗓️

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 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 036002c and 4d7ebbc.

📒 Files selected for processing (2)
  • public/locale/en.json (2 hunks)
  • src/pages/Scheduling/ScheduleExceptions.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/pages/Scheduling/ScheduleExceptions.tsx
  • public/locale/en.json
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

Copy link

netlify bot commented Jan 30, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 4d7ebbc
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67a26e15db285100081e4361
😎 Deploy Preview https://deploy-preview-10283--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rithviknishad
Copy link
Member

https://github.blog/news-insights/product-news/introducing-draft-pull-requests/

@rithviknishad rithviknishad marked this pull request as draft January 30, 2025 05:17
@modamaan modamaan marked this pull request as ready for review January 30, 2025 20:07
@github-actions github-actions bot added the merge conflict pull requests with merge conflict label Feb 1, 2025
Copy link

github-actions bot commented Feb 1, 2025

Conflicts have been detected against the base branch. Please rebase your branch against the base branch.
cc: @modamaan

See: https://docs.ohc.network/docs/contributing#how-to-resolve-merge-conflicts

@Jacobjeevan Jacobjeevan added the waiting for related PR a co-related detail PR is under construction label Feb 3, 2025
@nihal467
Copy link
Member

nihal467 commented Feb 3, 2025

@modamaan what is the status on the PR

@modamaan
Copy link
Contributor Author

modamaan commented Feb 3, 2025

@nihal467 Waiting to update ConfirmDialog #10048

@modamaan
Copy link
Contributor Author

modamaan commented Feb 3, 2025

@rithviknishad #10048 Has work started on the ConfirmDialog?

@github-actions github-actions bot added needs-triage question Further information is requested labels Feb 3, 2025
@AdityaJ2305
Copy link
Contributor

@Jacobjeevan, can we use the existing alert-dialog component we have ? 🤔

@rithviknishad
Copy link
Member

rithviknishad commented Feb 4, 2025

@modamaan use the alert dialog. #10048 would be deleting ConfirmDialog and use AlertDialog instead, and not modify ConfirmDialog.

@Jacobjeevan Jacobjeevan removed question Further information is requested waiting for related PR a co-related detail PR is under construction needs-triage labels Feb 4, 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: 0

🧹 Nitpick comments (3)
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx (3)

141-141: Consider using consistent state variable naming.

The state variables for managing dialog visibility use different naming patterns:

  • isDialogOpen in ScheduleTemplateEditor
  • openDialog in AvailabilityEditor

Consider using consistent naming across both components for better maintainability.

-  const [openDialog, setOpenDialog] = useState(false);
+  const [isDialogOpen, setDialogOpen] = useState(false);

Also applies to: 332-332


266-302: Consider disabling the confirm button during deletion.

The confirm button should be disabled while deletion is in progress to prevent accidental double-clicks.

   <AlertDialogAction
+    disabled={isDeleting}
     onClick={() => {
       deleteTemplate();
       setDialogOpen(false);
     }}
   >
     {t("confirm")}
   </AlertDialogAction>

395-431: Remove redundant onClick handler in AlertDialogTrigger.

The onClick handler in the trigger button is redundant as AlertDialogTrigger already handles opening the dialog.

   <Button
     variant="ghost"
     size="icon"
-    onClick={() => setOpenDialog(true)}
     disabled={isDeleting}
     className="text-red-600 hover:text-red-700 hover:bg-red-50"
   >

Also, consider disabling the confirm button during deletion to prevent double-clicks:

   <AlertDialogAction
+    disabled={isDeleting}
     onClick={() => {
       deleteAvailability();
       setOpenDialog(false);
     }}
   >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4ec2166 and 036002c.

📒 Files selected for processing (4)
  • public/locale/en.json (2 hunks)
  • src/pages/Scheduling/ScheduleExceptions.tsx (4 hunks)
  • src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx (4 hunks)
  • src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx
  • src/pages/Scheduling/ScheduleExceptions.tsx
  • public/locale/en.json
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (1)
src/pages/Scheduling/components/EditScheduleTemplateSheet.tsx (1)

18-29: LGTM!

The new imports for Alert and AlertDialog components are well-organized and necessary for implementing the confirmation dialogs.

@modamaan
Copy link
Contributor Author

modamaan commented Feb 4, 2025

District.Admin._.confirm-Popup.Chrome.2025-02-04.21-48-48.mp4

@modamaan modamaan requested a review from Jacobjeevan February 4, 2025 16:30
Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

lgtm, minor things:

src/pages/Scheduling/ScheduleExceptions.tsx Outdated Show resolved Hide resolved
public/locale/en.json Outdated Show resolved Hide resolved
@rithviknishad rithviknishad removed the merge conflict pull requests with merge conflict label Feb 4, 2025
type="button"
variant="secondary"
size="sm"
className="text-gray-600 hover:text-gray-900"
Copy link
Member

Choose a reason for hiding this comment

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

let's not modify the colors, also use danger variant for destructive actions

Suggested change
className="text-gray-600 hover:text-gray-900"

Comment on lines +398 to +402
variant="ghost"
size="icon"
onClick={() => setOpenDialog(true)}
disabled={isDeleting}
className="text-red-600 hover:text-red-700 hover:bg-red-50"
Copy link
Member

Choose a reason for hiding this comment

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

let's not modify classNames of buttons. looses the point of having variants and consistent designs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Confirmation Pop-up When Removing an Exception to Prevent Accidental Deletions
5 participants