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 modal before deleting a task status #3309

Conversation

CREDO23
Copy link
Contributor

@CREDO23 CREDO23 commented Nov 11, 2024

Description

Fix #3124

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Current screenshots

loom

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a confirmation modal for deleting task statuses that are currently in use, enhancing user safety and preventing accidental deletions.
    • Added customizable properties to dropdown menu components for improved flexibility.
  • Localization

    • Added confirmation messages for task status deletion in multiple languages, including English, Spanish, French, German, Hebrew, Italian, Dutch, Polish, Portuguese, Russian, and Chinese, to enhance user experience across different locales.

@CREDO23 CREDO23 added WEB Web app Improvement Improvement Ever Teams labels Nov 11, 2024
@CREDO23 CREDO23 self-assigned this Nov 11, 2024
Copy link
Contributor

coderabbitai bot commented Nov 11, 2024

Walkthrough

The pull request introduces enhancements to the dropdown menu components by adding optional properties (className and children) to DropdownMenuSubContent and DropdownMenuContent. A new confirmation modal component, DeleteTaskStatusConfirmationModal, is added to manage task status deletions, ensuring users confirm actions on statuses currently in use. Localization files are updated across multiple languages to include a confirmation message for deleting task statuses. The overall structure and functionality of existing components remain intact while improving user interaction and error handling.

Changes

File Path Change Summary
apps/web/components/ui/dropdown-menu.tsx Added className and children props to DropdownMenuSubContent and DropdownMenuContent.
apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx Introduced DeleteTaskStatusConfirmationModal component for confirming deletion of task statuses.
apps/web/lib/settings/task-statuses-form.tsx Added useTeamTasks hook and updated onDelete to check if a status is in use before deletion.
apps/web/locales/ar.json Added "DELETE_STATUS_CONFIRMATION" key with Arabic message.
apps/web/locales/bg.json Added "DELETE_STATUS_CONFIRMATION" key with Bulgarian message.
apps/web/locales/de.json Added "DELETE_STATUS_CONFIRMATION" key with German message.
apps/web/locales/en.json Added "DELETE_STATUS_CONFIRMATION" key with English message.
apps/web/locales/es.json Added "DELETE_STATUS_CONFIRMATION" key with Spanish message.
apps/web/locales/fr.json Added "DELETE_STATUS_CONFIRMATION" key with French message.
apps/web/locales/he.json Added "DELETE_STATUS_CONFIRMATION" key with Hebrew message.
apps/web/locales/it.json Added "DELETE_STATUS_CONFIRMATION" key with Italian message.
apps/web/locales/nl.json Added "DELETE_STATUS_CONFIRMATION" key with Dutch message.
apps/web/locales/pl.json Added "DELETE_STATUS_CONFIRMATION" key with Polish message.
apps/web/locales/pt.json Added "DELETE_STATUS_CONFIRMATION" key with Portuguese message.
apps/web/locales/ru.json Added "DELETE_STATUS_CONFIRMATION" key with Russian message.
apps/web/locales/zh.json Added "DELETE_STATUS_CONFIRMATION" key with Chinese message.

Possibly related PRs

Suggested labels

feature

Suggested reviewers

  • evereq
  • Cedric921

🐇 In the meadow, changes bloom bright,
Dropdowns now dance, a beautiful sight.
A modal appears, to confirm with care,
Deleting a status? Handle with flair!
New keys in languages, all set to say,
"Confirm your choice, before you stray!" 🌼

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.

apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx

Oops! Something went wrong! :(

ESLint: 8.46.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/apps/web/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.


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

@CREDO23 CREDO23 changed the title add confirmation modal before deleteing a task status if used add confirmation modal before deleteing a task status Nov 11, 2024
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: 9

🧹 Outside diff range and nitpick comments (6)
apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx (2)

7-12: Add JSDoc documentation for the interface props

While the interface is well-structured, adding JSDoc documentation for each prop would improve code maintainability and developer experience.

+/**
+ * Props for the DeleteTaskStatusModal component
+ */
 interface DeleteTaskStatusModalProps {
+  /** Controls the visibility of the modal */
 	open: boolean;
+  /** Callback function to close the modal */
 	closeModal: () => void;
+  /** Task status object to be deleted */
 	status : ITaskStatusItemList;
+  /** Callback function called when deletion is cancelled */
 	onCancel: () => void;
 }

1-78: Consider implementing a reusable confirmation modal pattern

Since confirmation modals are common UI patterns, consider extracting the core functionality into a reusable ConfirmationModal component. This would promote consistency across the application and reduce code duplication for similar use cases.

Example approach:

  1. Create a generic ConfirmationModal component
  2. Make this component extend that base component
  3. Standardize the confirmation modal pattern across the application

Would you like me to provide an example implementation of this pattern?

apps/web/components/ui/dropdown-menu.tsx (1)

Line range hint 61-74: Remove redundant types and avoid type casting to 'any'

The same issues as in DropdownMenuSubContent need to be addressed here:

  1. Redundant type definitions
  2. Unsafe type casting

Apply this diff to fix both issues:

const DropdownMenuContent = React.forwardRef<
  React.ElementRef<typeof DropdownMenuPrimitive.Content>,
- React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>  & {
-   className?: string;
-   children?: React.ReactNode
- }
+ React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
  <DropdownMenuPrimitive.Portal>
    <DropdownMenuPrimitive.Content
      ref={ref}
      sideOffset={sideOffset}
      className={cn(
        "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
        className
      )}
-     {...(props as any)}
+     {...props}
    />
  </DropdownMenuPrimitive.Portal>
))
apps/web/lib/settings/task-statuses-form.tsx (2)

156-158: Improve code formatting consistency

The spacing and formatting in these lines differ from the rest of the file. Consider maintaining consistent formatting:

-  const {isOpen : isDeleteConfirmationOpen , closeModal : closeDeleteConfirmationModal, openModal : openDeleteConfirmationModal} = useModal()
-  const [statusToDelete, setStatusToDelete] = useState<ITaskStatusItemList | null>(null)
-  const {tasks} = useTeamTasks()
+  const { 
+    isOpen: isDeleteConfirmationOpen, 
+    closeModal: closeDeleteConfirmationModal, 
+    openModal: openDeleteConfirmationModal 
+  } = useModal();
+  const [statusToDelete, setStatusToDelete] = useState<ITaskStatusItemList | null>(null);
+  const { tasks } = useTeamTasks();

313-313: Fix modal rendering indentation

The modal rendering uses tabs instead of spaces. Maintain consistent indentation:

-	  {statusToDelete && <DeleteTaskStatusConfirmationModal onCancel={() => setStatusToDelete(null)} status={statusToDelete} open={isDeleteConfirmationOpen} closeModal={closeDeleteConfirmationModal}/>}
+    {statusToDelete && (
+      <DeleteTaskStatusConfirmationModal
+        onCancel={() => setStatusToDelete(null)}
+        status={statusToDelete}
+        open={isDeleteConfirmationOpen}
+        closeModal={closeDeleteConfirmationModal}
+      />
+    )}
apps/web/locales/en.json (1)

335-337: Improve message capitalization and grammar.

The confirmation message has inconsistent capitalization. The word "Delete" is unnecessarily capitalized mid-sentence.

Apply this diff to improve the message:

-			"DELETE_STATUS_CONFIRMATION": "You are about to Delete the Status {statusName} that is used by active tasks; please confirm action"
+			"DELETE_STATUS_CONFIRMATION": "You are about to delete the status {statusName} that is used by active tasks. Please confirm action."
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 1a1d0c6 and 3ec0b91.

📒 Files selected for processing (16)
  • apps/web/components/ui/dropdown-menu.tsx (2 hunks)
  • apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx (1 hunks)
  • apps/web/lib/settings/task-statuses-form.tsx (5 hunks)
  • apps/web/locales/ar.json (1 hunks)
  • apps/web/locales/bg.json (1 hunks)
  • apps/web/locales/de.json (1 hunks)
  • apps/web/locales/en.json (1 hunks)
  • apps/web/locales/es.json (1 hunks)
  • apps/web/locales/fr.json (1 hunks)
  • apps/web/locales/he.json (1 hunks)
  • apps/web/locales/it.json (1 hunks)
  • apps/web/locales/nl.json (1 hunks)
  • apps/web/locales/pl.json (1 hunks)
  • apps/web/locales/pt.json (1 hunks)
  • apps/web/locales/ru.json (1 hunks)
  • apps/web/locales/zh.json (1 hunks)
🔇 Additional comments (13)
apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx (1)

26-27: Verify translation keys exist

Ensure all translation keys used in the component exist in the localization files.

✅ Verification successful

Let me try a different approach to verify the translation keys.


Translation keys verified successfully

All required translation keys are present in the locale file:

  • pages.taskStatus.DELETE_STATUS_CONFIRMATION
  • common.NO
  • common.YES
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if all required translation keys exist in the English locale file
REQUIRED_KEYS=(
  "pages.taskStatus.DELETE_STATUS_CONFIRMATION"
  "common.NO"
  "common.YES"
)

# Find and check the English locale file
LOCALE_FILE=$(fd -t f "en.json" -E "node_modules")

for key in "${REQUIRED_KEYS[@]}"; do
  echo "Checking key: $key"
  cat "$LOCALE_FILE" | jq --arg key "$key" 'getpath($key | split("."))'
done

Length of output: 1183


Script:

#!/bin/bash
# First, let's check the exact path of the locale files
fd -t f "en.json"

# Then let's examine the content of the web locale file
cat apps/web/locales/en.json | jq '
  paths(scalars) |
  map(tostring) |
  join(".")
'

Length of output: 19341

apps/web/components/ui/dropdown-menu.tsx (1)

Line range hint 1-1: Verify dropdown menu usage in the confirmation modal

Since these components will be used in the task status deletion confirmation modal, let's verify their integration.

apps/web/lib/settings/task-statuses-form.tsx (2)

2-2: LGTM: Import changes are appropriate

The addition of useTeamTasks hook is well-placed and necessary for the new functionality.


18-18: Verify DeleteTaskStatusConfirmationModal implementation

Let's verify the modal component implementation and its usage across the codebase:

✅ Verification successful

DeleteTaskStatusConfirmationModal implementation is properly integrated

The component is correctly implemented and used:

  • Component exists at apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx
  • It's properly imported in task-statuses-form.tsx
  • The component handles task status deletion with proper loading states and error handling
  • The deletion functionality is consistently implemented across the codebase with corresponding API endpoints and hooks
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the DeleteTaskStatusConfirmationModal component and its usage

# Check if the modal component exists
echo "Checking for DeleteTaskStatusConfirmationModal component..."
rg -l "DeleteTaskStatusConfirmationModal" --type tsx

# Check for other components that might need similar confirmation
echo "\nChecking for other task status deletion usage..."
rg "deleteTaskStatus\(" --type tsx -A 2

Length of output: 390


Script:

#!/bin/bash
# Let's try without the --type flag and use more generic search patterns

# Check if the modal component exists
echo "Checking for DeleteTaskStatusConfirmationModal component..."
rg -l "DeleteTaskStatusConfirmationModal"

# Check for the component implementation
echo -e "\nChecking component implementation..."
rg -A 5 "export.*DeleteTaskStatusConfirmationModal"

# Check for task status deletion usage
echo -e "\nChecking for task status deletion usage..."
rg "deleteTaskStatus" -A 2

Length of output: 6166

apps/web/locales/zh.json (1)

335-337: LGTM! The localization entry is well-structured.

The new taskStatus section with the confirmation message is properly formatted, includes the necessary placeholder, and maintains consistent indentation with the rest of the file.

apps/web/locales/he.json (1)

335-337: LGTM! Verify translations across all locales.

The Hebrew translation for the delete status confirmation message is well-structured and clearly communicates the action and its implications.

Let's verify that this translation key exists across all localization files with consistent messaging:

✅ Verification successful

Let me try a different approach to verify the translations by checking the entire taskStatus object across all locale files.


Let me try one more approach to check the raw content of the files, as the jq queries might not be working as expected.


Translation key is consistently present across all locale files

The DELETE_STATUS_CONFIRMATION message is properly implemented in all 13 locale files (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh). Each translation:

  • Maintains the {statusName} placeholder
  • Conveys the same meaning about deleting a status used by active tasks
  • Requests confirmation from the user
  • Is properly formatted for the respective language
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistency of DELETE_STATUS_CONFIRMATION translations across all locale files.

# Find all locale files
fd -e json . apps/web/locales/ --exec sh -c '
  echo "=== $1 ==="
  # Extract the DELETE_STATUS_CONFIRMATION key and its value
  jq -r ".taskStatus.DELETE_STATUS_CONFIRMATION // empty" "$1"
  echo ""
' sh

Length of output: 648


Script:

#!/bin/bash
# Description: Check the taskStatus object across all locale files
fd -e json . apps/web/locales/ --exec sh -c '
  echo "=== $1 ==="
  jq -r ".taskStatus" "$1"
  echo ""
' sh

Length of output: 616


Script:

#!/bin/bash
# Check raw content of locale files focusing on taskStatus
for file in $(fd -e json . apps/web/locales/); do
  echo "=== $file ==="
  grep -A 2 '"taskStatus"' "$file"
  echo ""
done

Length of output: 4567

apps/web/locales/ar.json (1)

335-337: LGTM! Translation key and message are well-structured.

The new translation key is properly placed in the taskStatus section and includes a clear confirmation message with appropriate placeholder for the status name.

Let's verify the consistency of this translation key across other locale files:

✅ Verification successful

Let me gather more information to verify if the translation key exists in all locale files and check their content.


Missing translation key in all locale files

The DELETE_STATUS_CONFIRMATION key under taskStatus is missing in all locale files, including the Arabic one where it should be present according to the review. This suggests that either:

  • The changes haven't been committed yet
  • The file path or JSON structure in the review is incorrect
  • The review is examining a different branch or state

Let's verify the exact content of the Arabic locale file:


Translation key exists and is properly formatted

The DELETE_STATUS_CONFIRMATION key exists under taskStatus in the Arabic locale file with the correct placeholder {statusName}. The translation is well-structured and matches the review comment exactly.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the DELETE_STATUS_CONFIRMATION key exists in all locale files
# and verify the placeholder consistency.

# Find all locale files
fd -e json . apps/web/locales/ --exec sh -c '
  echo "=== Checking {}" &&
  # Extract the DELETE_STATUS_CONFIRMATION key and verify placeholder
  jq -r ".taskStatus.DELETE_STATUS_CONFIRMATION // empty" {} | grep -o "{statusName}" || true
'

Length of output: 735


Script:

#!/bin/bash
# Get the actual translation strings from all locale files
fd -e json . apps/web/locales/ --exec sh -c '
  echo "=== File: {}" &&
  jq -r ".taskStatus.DELETE_STATUS_CONFIRMATION // \"[MISSING]\"" {}
'

Length of output: 728


Script:

#!/bin/bash
# Check the actual content of ar.json
cat apps/web/locales/ar.json

Length of output: 28316

apps/web/locales/en.json (1)

335-337: Verify localization placeholder usage across other language files.

The message uses the {statusName} placeholder. Let's verify its consistent implementation across other language files.

✅ Verification successful

The {statusName} placeholder is consistently implemented across all locale files

The verification shows that the {statusName} placeholder is present and correctly formatted in all language files (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh) under apps/web/locales/. No inconsistencies were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the DELETE_STATUS_CONFIRMATION key and statusName placeholder are consistently implemented across all locale files.

# Find all locale files
fd -e json -d 1 . apps/web/locales/ -x sh -c '
  echo "=== Checking {}" 
  jq -r ".pages.taskStatus.DELETE_STATUS_CONFIRMATION // empty" {} | grep -o "{statusName}" || echo "statusName placeholder not found"
'

Length of output: 874

apps/web/locales/nl.json (1)

335-337: LGTM! The Dutch translation for task status deletion confirmation is well implemented.

The translation is grammatically correct, properly formatted, and effectively communicates the warning message about deleting a status that's in use by active tasks.

apps/web/locales/it.json (1)

335-337: LGTM! Translation looks good.

The Italian translation for the task status deletion confirmation message is properly structured and grammatically correct. The placeholder {statusName} is correctly maintained for dynamic content.

Let's verify that this translation key exists across other language files:

✅ Verification successful

Translation key is consistent across all locale files

The DELETE_STATUS_CONFIRMATION key is present in all 13 language files (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh) with proper translations. Each translation:

  • Maintains the {statusName} placeholder correctly
  • Conveys the same meaning about deleting a status used by active tasks
  • Follows appropriate grammar and punctuation for its language
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the DELETE_STATUS_CONFIRMATION key exists in all locale files
# Expected: The key should exist in all language files (en.json, es.json, de.json, etc.)

# Search for the translation key in all locale files
rg -l "DELETE_STATUS_CONFIRMATION" apps/web/locales/

Length of output: 377


Script:

#!/bin/bash
# Let's verify the content and structure of the translation key across all locale files
rg --json "DELETE_STATUS_CONFIRMATION" apps/web/locales/ | jq -r '.data.lines.text' 2>/dev/null

Length of output: 2046

apps/web/locales/ru.json (1)

335-337: LGTM! The translation is clear and properly formatted.

The Russian translation for the task status deletion confirmation message is well-structured and accurately conveys:

  1. The action being taken
  2. The status name (via {statusName} placeholder)
  3. The current usage status
  4. The need for confirmation

Let's verify the consistency of this translation key across other language files:

apps/web/locales/pt.json (1)

335-337: LGTM! The translation is well-structured and clear.

The new taskStatus section with the confirmation message is properly implemented:

  • Uses proper placeholder format for dynamic content
  • Clearly communicates the impact of deleting a status that's in use
  • Maintains consistent JSON structure
apps/web/locales/fr.json (1)

335-337: LGTM! Translation looks good.

The French translation for the task status deletion confirmation is well-structured and grammatically correct. The message clearly communicates the warning about deleting a status that's in use.

Let's verify that this translation key exists in other language files for consistency:

✅ Verification successful

Translation key is present in all locale files

The verification confirms that the DELETE_STATUS_CONFIRMATION key exists in all language files (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh), ensuring consistent translation coverage across the application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the DELETE_STATUS_CONFIRMATION key exists in all locale files
# Expected: The key should be present in all language files to ensure complete translations

# Find all locale files
fd -e json -d 1 . "apps/web/locales" --exec sh -c '
  echo "Checking {}"
  jq -e ".pages.taskStatus.DELETE_STATUS_CONFIRMATION" "{}" > /dev/null 2>&1
  if [ $? -eq 0 ]; then
    echo "✓ Key found"
  else
    echo "✗ Missing translation key"
  fi
'

Length of output: 845

@CREDO23 CREDO23 changed the title add confirmation modal before deleteing a task status Add confirmation modal before deleting a task status Nov 11, 2024
@CREDO23 CREDO23 force-pushed the 3124-task-status--user-deletes-status-what-should-be-instead-for-active-tasks branch from 3ec0b91 to 932078c Compare November 11, 2024 23:26
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

🧹 Outside diff range and nitpick comments (4)
apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx (1)

61-79: Enhance loading state accessibility

While the loading state is properly handled with disabled buttons and visual feedback, consider adding ARIA attributes for better screen reader support.

 <Button
   disabled={deleteTaskStatusLoading}
   variant="outline"
   type="button"
   onClick={handleCloseModal}
+  aria-busy={deleteTaskStatusLoading}
   className="rounded-md font-light text-md dark:text-white dark:bg-slate-700 dark:border-slate-600"
 >
   {t('common.NO')}
 </Button>
 <Button
   loading={deleteTaskStatusLoading}
   disabled={deleteTaskStatusLoading}
   onClick={handleDeleteTaskStatus}
   variant="primary"
   type="submit"
+  aria-busy={deleteTaskStatusLoading}
   className=" rounded-md font-light text-md dark:text-white"
 >
   {t('common.YES')}
 </Button>
apps/web/lib/settings/task-statuses-form.tsx (3)

156-158: LGTM with minor formatting suggestion

The state management setup for the confirmation modal is well-structured. Consider adding spaces after colons in the destructuring assignment for consistency.

-  const {isOpen : isDeleteConfirmationOpen , closeModal : closeDeleteConfirmationModal, openModal : openDeleteConfirmationModal} = useModal()
+  const { isOpen: isDeleteConfirmationOpen, closeModal: closeDeleteConfirmationModal, openModal: openDeleteConfirmationModal } = useModal()

289-302: Consider enhancing error handling UX

The error handling implementation is good, but the user experience could be improved by adding error notifications.

  } catch (error) {
-   console.error(error);
+   console.error('Failed to process status deletion:', error);
+   // Consider using your notification system here, e.g.:
+   // showErrorNotification({
+   //   message: t('common.ERRORS.FAILED_TO_DELETE_STATUS'),
+   //   error: error
+   // });
  }

317-317: Fix indentation for consistency

The modal rendering line uses tabs instead of spaces, which is inconsistent with the rest of the file.

-	  {statusToDelete && <DeleteTaskStatusConfirmationModal onCancel={() => setStatusToDelete(null)} status={statusToDelete} open={isDeleteConfirmationOpen} closeModal={closeDeleteConfirmationModal}/>}
+    {statusToDelete && (
+      <DeleteTaskStatusConfirmationModal
+        onCancel={() => setStatusToDelete(null)}
+        status={statusToDelete}
+        open={isDeleteConfirmationOpen}
+        closeModal={closeDeleteConfirmationModal}
+      />
+    )}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3ec0b91 and 932078c.

📒 Files selected for processing (16)
  • apps/web/components/ui/dropdown-menu.tsx (2 hunks)
  • apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx (1 hunks)
  • apps/web/lib/settings/task-statuses-form.tsx (5 hunks)
  • apps/web/locales/ar.json (1 hunks)
  • apps/web/locales/bg.json (1 hunks)
  • apps/web/locales/de.json (1 hunks)
  • apps/web/locales/en.json (1 hunks)
  • apps/web/locales/es.json (1 hunks)
  • apps/web/locales/fr.json (1 hunks)
  • apps/web/locales/he.json (1 hunks)
  • apps/web/locales/it.json (1 hunks)
  • apps/web/locales/nl.json (1 hunks)
  • apps/web/locales/pl.json (1 hunks)
  • apps/web/locales/pt.json (1 hunks)
  • apps/web/locales/ru.json (1 hunks)
  • apps/web/locales/zh.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (13)
  • apps/web/components/ui/dropdown-menu.tsx
  • apps/web/locales/ar.json
  • apps/web/locales/bg.json
  • apps/web/locales/de.json
  • apps/web/locales/en.json
  • apps/web/locales/es.json
  • apps/web/locales/fr.json
  • apps/web/locales/he.json
  • apps/web/locales/it.json
  • apps/web/locales/nl.json
  • apps/web/locales/pt.json
  • apps/web/locales/ru.json
  • apps/web/locales/zh.json
🔇 Additional comments (5)
apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx (2)

1-12: LGTM! Clean imports and well-defined interface

The imports are minimal and necessary, and the interface is well-typed with clear prop definitions.


14-24: LGTM! Comprehensive JSDoc documentation

The JSDoc documentation is complete and accurately describes the component and its props.

apps/web/lib/settings/task-statuses-form.tsx (2)

2-2: LGTM: Import changes align with feature requirements

The new imports for useTeamTasks and DeleteTaskStatusConfirmationModal are appropriate for implementing the confirmation modal feature.

Also applies to: 18-18


289-302: Verify implementation meets PR objectives

The implementation correctly fulfills the PR requirements by:

  1. Checking if the status is in use before deletion
  2. Showing the confirmation modal only when necessary
  3. Safely handling the deletion process

Let's verify the implementation by checking for any existing task statuses in use.

Also applies to: 317-317

✅ Verification successful

Implementation correctly handles task status deletion

The verification confirms that the implementation properly handles task status deletion:

  1. The code checks if a status is in use by comparing against the task's status field
  2. The confirmation modal is shown only when the status is in use (via setStatusToDelete and openDeleteConfirmationModal)
  3. The deletion process is handled safely with proper error handling

Evidence from the codebase:

  • The task status is used across multiple components and screens, confirming the importance of safe deletion
  • The delete confirmation modal (delete-status-confirmation-modal.tsx) exists and is properly integrated
  • The status deletion logic is consistent between the form and the confirmation modal
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find task statuses that are currently in use
# This helps verify that the confirmation modal will be shown appropriately

# Search for task status assignments in the codebase
rg -l 'status["\s]*[:=]' --type ts --type tsx | grep -v test

Length of output: 90


Script:

#!/bin/bash
# Let's try a different approach to find task status usage
# First, let's find the task status related files
rg -l "TaskStatus" --type typescript

# Then look for specific task status usage patterns
rg "status\." --type typescript -A 2

Length of output: 145


Script:

#!/bin/bash
# Search for task status related patterns without specifying file type
rg -l "TaskStatus"

# Look for status usage in the codebase
rg "status\." -A 2

# Also search for the specific component
fd "task-statuses-form"

Length of output: 16427

apps/web/locales/pl.json (1)

335-337: LGTM! The Polish translation is well-structured.

The translation key and message are clear, properly formatted, and effectively communicate the task status deletion confirmation to Polish users.

Note: As mentioned in the previous review, this translation key needs to be added to all other language files (en.json, es.json, zh.json, etc.) to maintain consistency in the application's internationalization.

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

🧹 Outside diff range and nitpick comments (2)
apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx (2)

41-44: Move ID validation to prop type or component initialization

The status ID validation should be handled earlier, either through TypeScript types or component initialization, rather than during the delete operation.

interface DeleteTaskStatusModalProps {
-  status: ITaskStatusItemList;
+  status: ITaskStatusItemList & { id: string }; // Ensure id is required
}

export function DeleteTaskStatusConfirmationModal(props: DeleteTaskStatusModalProps) {
   const { closeModal, open, status, onCancel } = props;
+  
+  if (!status.id) {
+    console.error('Status ID is required');
+    return null;
+  }

61-99: Add loading state announcement for screen readers

While the loading state is visually handled, add an aria-live region to announce the loading state for screen readers.

 <Card className="w-full" shadow="custom">
+  {deleteTaskStatusLoading && (
+    <div aria-live="polite" className="sr-only">
+      {t('common.DELETING_STATUS')}
+    </div>
+  )}
   <div className="w-full flex flex-col justify-between gap-6">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 932078c and 9b7d39a.

📒 Files selected for processing (1)
  • apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx (1 hunks)
🔇 Additional comments (3)
apps/web/lib/features/task-status/delete-status-confirmation-modal.tsx (3)

1-12: LGTM: Clean imports and well-defined interface

The imports are appropriate and the interface is well-typed with clear prop definitions.


14-30: LGTM: Well-documented component with proper hook usage

The JSDoc documentation is accurate and the component is properly structured with appropriate hook usage.


34-37: LGTM: Clean modal closing logic

The modal closing logic is well-implemented with proper callback optimization.

@CREDO23 CREDO23 requested review from evereq and Cedric921 November 12, 2024 17:13
@evereq evereq merged commit fb2c1a6 into develop Nov 14, 2024
13 checks passed
@evereq evereq deleted the 3124-task-status--user-deletes-status-what-should-be-instead-for-active-tasks branch November 14, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Status | user deletes Status, what should be instead for active tasks
2 participants