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

[Feat] Team's tasks | Assigned / Unassigned option #3532

Merged

Conversation

CREDO23
Copy link
Contributor

@CREDO23 CREDO23 commented Jan 21, 2025

Description

Closes #3454

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 on my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

Loom

Summary by CodeRabbit

  • New Features

    • Improved task assignment logic with clearer state determination
    • Enhanced UI interactivity for task assignment dropdown menu
  • Style

    • Added cursor-pointer class to dropdown menu items
    • Updated text labels to reflect task assignment state more clearly

@CREDO23 CREDO23 self-assigned this Jan 21, 2025
@CREDO23 CREDO23 linked an issue Jan 21, 2025 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Jan 21, 2025

Walkthrough

The pull request modifies the DropdownMenuTask.tsx component to improve task assignment functionality. The changes introduce a boolean isAssigned to determine task assignment status, replacing direct member ID checks. The code now simplifies the assignment logic, updates UI interactions by adding cursor-pointer class to dropdown menu items, and enhances the text display for assigning and unassigning tasks. Additionally, new toast messages are added in multiple languages to provide feedback when a task is unassigned.

Changes

File Change Summary
apps/web/components/pages/team/tasks/DropdownMenuTask.tsx - Replaced member with isAssigned boolean
- Updated handleAssignment function logic
- Added cursor-pointer class to dropdown menu items
- Modified text display for task assignment state
apps/web/locales/ar.json - Added toast message for unassigned tasks
apps/web/locales/bg.json - Added toast message for unassigned tasks
apps/web/locales/de.json - Added toast message for unassigned tasks
- Updated syntax for existing key
apps/web/locales/en.json - Added toast message for unassigned tasks
apps/web/locales/es.json - Added toast message for unassigned tasks
apps/web/locales/fr.json - Added toast message for unassigned tasks
- Updated syntax for existing key
apps/web/locales/he.json - Added toast message for unassigned tasks
- Updated syntax for existing key
apps/web/locales/it.json - Added toast message for unassigned tasks
- Updated syntax for existing key
apps/web/locales/nl.json - Added toast message for unassigned tasks
apps/web/locales/pl.json - Added toast message for unassigned tasks
apps/web/locales/pt.json - Added toast message for unassigned tasks
apps/web/locales/ru.json - Added toast message for unassigned tasks
apps/web/locales/zh.json - Added toast message for unassigned tasks

Assessment against linked issues

Objective Addressed Explanation
Implement "Unassign Task" functionality [#3454]
Show confirmation toast for task unassignment [#3454] Toast implementation not visible in this diff
Toggle between "Assign Task" and "Unassign Task" [#3454]

Possibly related PRs

Suggested labels

Timesheets

Suggested reviewers

  • evereq
  • Cedric921

Poem

🐰 A rabbit's tale of tasks so bright,
Code refactored with pure delight
Assignments flow with grace and ease
No more complex member squeeze!
Dropdown magic, clear and clean
Task management's new routine! 🚀


📜 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 d50cb1c and 06b1166.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (14)
  • apps/web/components/pages/team/tasks/DropdownMenuTask.tsx (2 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 (1)
  • apps/web/components/pages/team/tasks/DropdownMenuTask.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: deploy
🔇 Additional comments (14)
apps/web/locales/zh.json (1)

752-755: LGTM! Translation looks good.

The Chinese translation for the unassigned task message is accurate and maintains consistent meaning with the feature's purpose.

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

752-755: LGTM! Translation looks good.

The Hebrew translation for the unassigned task message is accurate and maintains consistent meaning with the feature's purpose.

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

752-755: LGTM! Translation looks good.

The Arabic translation for the unassigned task message is accurate and maintains consistent meaning with the feature's purpose.

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

753-755: LGTM! Toast message added for unassigned tasks.

The English translation for the unassigned task toast message is clear and properly structured.

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

753-755: LGTM! Dutch translation added for unassigned task toast.

The Dutch translation "Taak niet toegewezen" is properly structured and consistent with the English version.

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

753-755: LGTM! Bulgarian translation added for unassigned task toast.

The Bulgarian translation "Задачата не е възложена" is properly structured and consistent with other language versions.

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

752-755: Polish translations look good!

The translation "Zadanie nieprzypisane" is grammatically correct and consistent with the unassigned task context.

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

752-755: Italian translations look good!

The translation "Attività non assegnata" is grammatically correct with proper gender agreement and consistent with the unassigned task context.

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

752-755: Russian translations look good!

The translation "Задача не назначена" is grammatically correct with proper gender agreement and consistent with the unassigned task context.


752-755: Excellent consistency across locale files!

The translations for the unassigned task message are consistently implemented across all locale files with:

  • Proper grammatical structure in each language
  • Consistent JSON structure and placement
  • Appropriate gender agreement where applicable
apps/web/locales/pt.json (1)

753-756: LGTM! The Portuguese translation is accurate and culturally appropriate.

The translation "Tarefa não atribuída" correctly conveys the meaning of "Task unassigned" in Portuguese, maintaining both semantic accuracy and natural language flow.

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

752-755: LGTM! The Spanish translation is accurate and culturally appropriate.

The translation "Tarea no asignada" correctly conveys the meaning of "Task unassigned" in Spanish, maintaining both semantic accuracy and natural language flow.

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

752-755: LGTM! The German translation is accurate and culturally appropriate.

The translation "Aufgabe nicht zugewiesen" correctly conveys the meaning of "Task unassigned" in German, maintaining both semantic accuracy and natural language flow.

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

752-755: LGTM! The French translation is accurate and culturally appropriate.

The translation "Tâche non attribuée" correctly conveys the meaning of "Task unassigned" in French, maintaining both semantic accuracy and natural language flow.


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
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/web/components/pages/team/tasks/DropdownMenuTask.tsx (1)

69-69: Fix inconsistent className spacing.

While the addition of cursor-pointer improves UX, there's inconsistent spacing in the className values:

  • Line 69: " cursor-pointer"
  • Line 76: "relative cursor-pointer"
  • Line 80: " cursor-pointer"
  • Line 84: " cursor-pointer"
-    className=" cursor-pointer"
+    className="cursor-pointer"

Also applies to: 76-76, 80-80, 84-85

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f40a8bf and d50cb1c.

📒 Files selected for processing (1)
  • apps/web/components/pages/team/tasks/DropdownMenuTask.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (2)
apps/web/components/pages/team/tasks/DropdownMenuTask.tsx (2)

29-34: Clean implementation of assignment toggle logic!

The updated handleAssignment function is more straightforward and properly memoized with the correct dependencies.


20-20: Verify integration with task filtering feature.

The isAssigned flag correctly identifies task assignment status, but ensure that this status is properly integrated with the task filtering feature mentioned in the PR objectives.

✅ Verification successful

Assignment status properly integrated with filtering system

The isAssigned flag is correctly integrated with the task filtering feature. It's used to populate the assigned/unassigned task groups, which are then filtered through the tab-based navigation system and can be further refined using additional filters.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for task filtering implementation
rg -l "isAssigned.*filter|filter.*isAssigned" --type tsx

Length of output: 86


Script:

#!/bin/bash
# Search with correct file extensions and broader patterns
rg -t ts -t tsx "filter.*task|task.*filter" -l
rg -t ts -t tsx "(assigned|unassigned).*\b(filter|status)" -l

Length of output: 168


Script:

#!/bin/bash
# Find all potential TypeScript/React files first
fd "\.(tsx?|jsx?)$" | grep -i "task"

# Search for filtering logic without file type restrictions
rg "filter.*task|task.*filter" --type-not test --type-not spec
rg "(assigned|unassigned).*(filter|status)" --type-not test --type-not spec

Length of output: 17648


Script:

#!/bin/bash
# Check content of potential filtering-related files
echo "=== Task Filters Component ==="
cat apps/web/lib/features/task/task-filters.tsx || true

echo -e "\n=== Filter Button Component ==="
cat apps/web/components/pages/team/tasks/FilterButton.tsx || true

echo -e "\n=== Task Filter Store ==="
cat apps/web/app/stores/task-filter.ts || true

Length of output: 20996

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 (4)
apps/web/components/pages/team/tasks/DropdownMenuTask.tsx (4)

20-21: Remove unused member variable.

The member variable on line 21 appears to be unused after the introduction of isAssigned. Consider removing it to improve code clarity.

  const isAssigned = task?.members?.some((m) => m?.user?.id === user?.id);
- const member = activeTeam?.members?.find((m) => m?.employee?.user?.id === user?.id);

29-34: Optimize useCallback dependencies.

The assignment logic looks good, but if you remove the unused member variable as suggested above, you should also consider creating a custom hook for the assignment logic to avoid the memberInfo dependency.

Consider extracting the assignment logic into a custom hook:

const useTaskAssignment = (task: ITeamTask) => {
  const { user } = useAuthenticateUser();
  const isAssigned = task?.members?.some((m) => m?.user?.id === user?.id);
  const { assignTask, unassignTask } = useTaskActions(); // New hook for task actions

  const handleAssignment = useCallback(() => {
    if (isAssigned) {
      unassignTask(task);
    } else {
      assignTask(task);
    }
  }, [isAssigned, task, assignTask, unassignTask]);

  return { isAssigned, handleAssignment };
};

69-69: Fix inconsistent className spacing.

The className values have inconsistent spacing before cursor-pointer. Some have a leading space, while others don't.

- className=" cursor-pointer"
+ className="cursor-pointer"

Also applies to: 76-76, 80-80, 84-84


69-73: Add error handling and user feedback for clipboard operation.

The clipboard operation should include error handling and provide feedback to the user when the task ID is copied.

 <DropdownMenuItem
   className="cursor-pointer"
-  onClick={() => taskEdition?.task?.id && navigator.clipboard.writeText(taskEdition.task.id)}
+  onClick={async () => {
+    if (taskEdition?.task?.id) {
+      try {
+        await navigator.clipboard.writeText(taskEdition.task.id);
+        // Add toast or notification: "Task ID copied to clipboard"
+      } catch (error) {
+        // Add error notification
+        console.error('Failed to copy task ID:', error);
+      }
+    }
+  }}
 >
   Copy Task ID
 </DropdownMenuItem>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f40a8bf and d50cb1c.

📒 Files selected for processing (1)
  • apps/web/components/pages/team/tasks/DropdownMenuTask.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Codacy Static Code Analysis

@CREDO23 CREDO23 marked this pull request as draft January 21, 2025 18:58
Copy link

Report too large to display inline

View full report↗︎

@CREDO23 CREDO23 marked this pull request as ready for review January 21, 2025 19:21
@evereq evereq merged commit 25d0024 into develop Jan 21, 2025
14 checks passed
@evereq evereq deleted the 3454-feat-implement-unassign-task-from-teams-tasks-page branch January 21, 2025 19:30
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.

[Feat] Implement "Unassign Task" from Team's Tasks page
2 participants