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

improvement: status type | edit/create mode #3185

Conversation

CREDO23
Copy link
Contributor

@CREDO23 CREDO23 commented Oct 25, 2024

Description

FIX #3165

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

Previous screenshots

Loom

Current screenshots

Loom

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced SVG caching to improve loading times for task status icons.
    • Enhanced TaskStatus component with dynamic text color adjustment based on background color.
    • Added localization support for new UI terms across multiple languages, including "SORT" and "ICON".
  • Improvements

    • Updated TaskStatusesForm to include new status types and improved color management.
    • Enhanced error handling for SVG loading in StatusesListCard.
  • Bug Fixes

    • Minor adjustments made to ensure consistent styling across components.
  • Documentation

    • Updated localization files to include new terms and ensure proper formatting.

@CREDO23 CREDO23 added WEB Web app Improvement Improvement Ever Teams labels Oct 25, 2024
@CREDO23 CREDO23 self-assigned this Oct 25, 2024
@CREDO23 CREDO23 linked an issue Oct 25, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes in this pull request introduce several enhancements across various components of the application. A new asynchronous function svgFetch is added for fetching and caching SVGs. The TaskStatus component is updated to dynamically set text colors based on background colors. Localization files are modified to include new key-value pairs for sorting and icons. Additionally, the TaskStatusesForm component is enhanced with new state variables and functions to manage status types and colors, addressing issues related to dropdown functionality.

Changes

File Path Change Summary
apps/web/app/services/server/fetch.ts Added svgFetch function for SVG fetching with caching. Introduced tasksStatusSvgCacheDuration.
apps/web/lib/features/task/task-status.tsx Integrated getTextColor for dynamic text color based on background. Minor adjustments to StatusDropdown.
apps/web/lib/settings/icon-items.tsx Enhanced IconItem with localization using useTranslations. Updated rendering logic for icons.
apps/web/lib/settings/list-card.tsx Replaced Image component with div for SVG icons. Introduced loadSVG function for fetching SVGs.
apps/web/lib/settings/task-statuses-form.tsx Added state variables and functions for managing status types and colors. Updated dropdown behavior.
apps/web/locales/*.json Added new localization keys for "SORT" and "ICON" in multiple language files. Updated existing keys.
apps/web/app/constants.ts Introduced constant tasksStatusSvgCacheDuration for SVG caching duration.
.vscode/settings.json Modified cSpell.words property format from multi-line to single-line.

Assessment against linked issues

Objective Addressed Explanation
Correct dropdown behavior for status types and icons (#3165)
System should randomly select an icon (#3165)
System should randomly select the color (#3165)

Suggested labels

bug, enhancement

Suggested reviewers

  • evereq
  • Cedric921

Poem

In the garden where icons play,
New colors bloom, brightening the day.
Fetching SVGs with a hop and a skip,
Enhancements abound, let the changes rip!
With translations added, our words take flight,
A joyful update, all feels just right! 🐇✨

Warning

There were issues while running the following tools:

🔧 eslint
apps/web/app/constants.ts

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.

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 (4)
apps/web/app/services/server/fetch.ts (1)

58-61: Add JSDoc documentation for the SVG fetch function.

The function lacks documentation about its purpose, parameters, and usage.

Add comprehensive documentation:

+/**
+ * Fetches SVG content from a given URL with validation and error handling.
+ * 
+ * @param url - The URL of the SVG resource to fetch
+ * @returns A Promise that resolves to the Response containing the SVG content
+ * @throws {Error} If the URL is invalid, the response is not OK, or the content is not SVG
+ * 
+ * @example
+ * ```typescript
+ * try {
+ *   const svgResponse = await fetchSvgContent('https://example.com/icon.svg');
+ *   const svgContent = await svgResponse.text();
+ * } catch (error) {
+ *   console.error('Failed to fetch SVG:', error);
+ * }
+ * ```
+ */
 export async function svgFetch(url: string): Promise<Response> {
apps/web/lib/settings/icon-items.tsx (1)

Line range hint 68-89: Consider improvements to the conditional rendering and error handling.

Several suggestions to enhance the component:

  1. The fallback case ignores the title prop, which might be unexpected
  2. The Image component lacks error handling for failed loads
  3. The translation key could be defined as a constant to avoid magic strings

Consider applying these improvements:

+ const ICON_TRANSLATION_KEY = 'common.ICON';
+ 
  return (
    <div
      title={title}
      className={clsxm(
        'flex items-center justify-start space-x-2 text-sm',
        'cursor-pointer mb-4 max-w-full',
        className
      )}
    >
      <div>
        {url ? (
          <div
            className={clsxm(
              'w-[17px] h-[17px]',
              'flex justify-center items-center',
              'rounded-full text-xs text-default dark:text-white',
              disabled && ['dark:text-default']
            )}
          >
            <Image
              src={url}
              alt={title || ''}
              width={20}
              height={20}
              decoding="async"
              data-nimg="1"
              loading="lazy"
+             onError={(e) => {
+               e.currentTarget.src = ''; // Add fallback image URL
+             }}
            />
          </div>
        ) : (
-         <span>{t('common.ICON')}</span>
+         <span>{title || t(ICON_TRANSLATION_KEY)}</span>
        )}
      </div>
    </div>
  );
apps/web/lib/settings/task-statuses-form.tsx (1)

33-34: Consider initializing randomColor with a value

Initialize randomColor with a random color value to avoid undefined states in the UI. This ensures the color picker always has a valid initial value.

-const [randomColor, setRandomColor] = useState<string | undefined>(undefined);
+const [randomColor, setRandomColor] = useState<string>(() => {
+  const letters = '0123456789ABCDEF';
+  let color = '#';
+  for (let i = 0; i < 6; i++) {
+    color += letters[Math.floor(Math.random() * 16)];
+  }
+  return color;
+});
apps/web/lib/features/task/task-status.tsx (1)

857-858: Consider handling edge cases in color determination.

While the implementation looks good, consider these improvements:

  1. The fallback color 'white' might not be suitable for all themes
  2. The background color could be undefined when active is false

Consider this improvement:

 style={{
   backgroundColor: active ? backgroundColor : undefined,
-  color: getTextColor(backgroundColor ?? 'white')
+  color: getTextColor(backgroundColor ?? (theme === 'dark' ? '#1B1D22' : 'white'))
 }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4efcacb and 74ffd3e.

📒 Files selected for processing (18)
  • apps/web/app/services/server/fetch.ts (1 hunks)
  • apps/web/lib/features/task/task-status.tsx (3 hunks)
  • apps/web/lib/settings/icon-items.tsx (4 hunks)
  • apps/web/lib/settings/list-card.tsx (4 hunks)
  • apps/web/lib/settings/task-statuses-form.tsx (8 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 (23)
apps/web/app/services/server/fetch.ts (1)

58-61: Verify SVG fetch usage across the codebase.

Let's ensure this new function is properly integrated with other components that need SVG fetching.

✅ Verification successful

The new svgFetch function is only used in one place for loading SVG icons

The codebase analysis shows that the svgFetch function is only used in apps/web/lib/settings/list-card.tsx for loading SVG icons in the loadSVG function. All other SVG usages in the codebase are static imports or direct path references. The function's current implementation is appropriate for its limited usage.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find potential usage points of SVG fetching in the codebase

echo "Searching for SVG-related fetch calls..."
rg -l "fetch.*svg|loadSVG|getSVG" --type ts --type tsx

echo -e "\nSearching for SVG URL patterns..."
rg "\.svg['\"]|/icons?/|/images?/" --type ts --type tsx

Length of output: 346


Script:

#!/bin/bash
# Let's try a different approach to find SVG-related patterns
# First, let's find all TypeScript files
echo "Finding TypeScript files with SVG-related patterns..."
rg -t ts "\.svg|fetch.*svg|loadSVG|getSVG|/icons?/|/images?/" -l

echo -e "\nChecking for actual implementations and usages..."
rg -t ts "\.svg|fetch.*svg|loadSVG|getSVG" -C 2

Length of output: 23920

apps/web/lib/settings/icon-items.tsx (3)

5-5: LGTM: Clean import addition for internationalization.

The addition of useTranslations hook import is well-placed and aligns with the internationalization requirements.


57-57: LGTM: Clean hook initialization.

The translation hook is properly initialized at the component level.


88-88: Verify translation key existence and consistency.

Let's ensure the translation key is properly defined across all language files.

✅ Verification successful

Translation key is properly defined and consistent across all locales

The translation key 'ICON' is correctly defined in all language files (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh) with appropriate translations for each locale. The usage in the code as t('common.ICON') is valid.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for the translation key in language files
echo "Checking for 'common.ICON' translation key in language files..."
rg -l '"ICON"' apps/web/messages/

Length of output: 237


Script:

#!/bin/bash
# First, let's find the correct location of translation files
fd -t f "en.json|de.json|fr.json|es.json" -x echo "=== {} ===" \; cat {}

# Also search for any usage of this translation key in the codebase
echo -e "\n=== Searching for translation key usage ==="
rg "common\.ICON"

Length of output: 414


Script:

#!/bin/bash
# Let's try a different approach to find translation files
echo "=== Looking for translation files ==="
fd -t f -e json . apps/web

# Let's also check the package.json to understand the i18n setup
echo -e "\n=== Checking package.json for i18n configuration ==="
fd -t f "package.json" -x cat {}

Length of output: 37255


Script:

#!/bin/bash
# Let's check the content of translation files to verify the key
echo "=== Checking translation files for 'common.ICON' key ==="
fd -t f -e json . apps/web/locales -x echo "=== {} ===" \; cat {}

# Also let's check for any other similar translation keys
echo -e "\n=== Checking for similar translation keys ==="
rg "ICON" apps/web/locales/

Length of output: 1418

apps/web/lib/settings/list-card.tsx (1)

8-9: LGTM! Imports are correctly added.

The new imports are necessary for the component's enhanced functionality.

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

232-234: LGTM! The translations are accurate and well-formatted.

The new Chinese translations for "MOVE_TO", "SORT", and "ICON" are correctly implemented and maintain consistency with the existing localization structure.

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

232-234: LGTM! Verify consistency across other language files.

The Hebrew translations for the new keys look correct and properly formatted.

Let's verify that these translations are consistently added across all mentioned language files:

✅ Verification successful

Translations for "SORT" and "ICON" are consistently present across all language files

The verification confirms that both "SORT" and "ICON" keys are properly added with appropriate translations in all checked language files (ar, bg, de, es, fr, it, nl, pl, pt, ru, zh), maintaining consistency across the entire localization system.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if SORT and ICON keys are present in all language files
# Expected: All language files should have these keys

# Test: Check for SORT and ICON keys in all JSON files
for lang in ar bg de es fr it nl pl pt ru zh; do
  echo "Checking $lang.json:"
  rg -A 1 '"SORT":' "apps/web/locales/$lang.json"
  rg -A 1 '"ICON":' "apps/web/locales/$lang.json"
done

Length of output: 2672

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

232-232: LGTM: Valid JSON syntax.

The trailing comma addition maintains proper JSON formatting and enables easier version control diffs for future additions.


233-234: LGTM: New translations look accurate.

The Arabic translations for "SORT" (فرز) and "ICON" (أيقونة) are correct and commonly used terms in Arabic UI localization. They appropriately maintain RTL (Right-to-Left) text direction which is crucial for Arabic language support.

Let's verify the consistency of these new keys across other language files:

✅ Verification successful

Translation keys are consistent across all locale files

The verification confirms that both "SORT" and "ICON" keys are properly implemented across all language files (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh) with appropriate translations for each language. The Arabic translations align well with the localization patterns used in other languages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the new keys exist in other locale files
# Test: Search for SORT and ICON keys in all locale files
rg '"SORT":|"ICON":' apps/web/locales/

Length of output: 1188

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

232-234: LGTM! Verify usage of new translations.

The new translations are clear and maintain consistency with the existing structure.

Let's verify that these new translations are being used in the UI components:

✅ Verification successful

✓ New translations are properly used in the UI

The new translation keys are actively used in the codebase:

  • "SORT" is used in apps/web/lib/settings/task-statuses-form.tsx
  • "ICON" is used in apps/web/lib/settings/icon-items.tsx
  • Both translations are properly integrated across multiple language files in both web and desktop apps
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for the usage of new translation keys in the codebase
echo "Searching for SORT translation key usage:"
rg "['\"](common\.)?SORT['\"]" --type ts --type tsx

echo "Searching for ICON translation key usage:"
rg "['\"](common\.)?ICON['\"]" --type ts --type tsx

Length of output: 357


Script:

#!/bin/bash
# Search for the usage of new translation keys in the codebase
echo "Searching for SORT translation key usage:"
rg "['\"](common\.)?SORT['\"]"

echo -e "\nSearching for ICON translation key usage:"
rg "['\"](common\.)?ICON['\"]"

# Also search for t function calls which might use these keys
echo -e "\nSearching for t function calls with these keys:"
rg "t\(['\"](?:common\.)?(?:SORT|ICON)['\"]"

Length of output: 2532

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

232-234: LGTM! The new translations are well-structured and accurate.

The additions follow the existing conventions and provide correct Dutch translations for the new keys.

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

232-234: LGTM! Verify consistency across language files.

The changes look good. The new translations for sorting and icons are properly added, and the comma after "MOVE_TO" maintains valid JSON syntax.

Let's verify that these keys exist across all language files:

✅ Verification successful

All translation keys are present and properly translated across language files

The verification confirms that both "SORT" and "ICON" keys are consistently present across all language files (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh) with appropriate translations for each language.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if SORT and ICON keys exist in all language files
# Expected: All language files should have these keys

# Test: Search for SORT and ICON keys in all locale files
echo "Checking SORT key..."
rg '"SORT"' apps/web/locales/
echo "Checking ICON key..."
rg '"ICON"' apps/web/locales/

Length of output: 1313

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

232-234: LGTM! The translations are properly structured and consistent.

The changes maintain proper JSON syntax and follow the localization patterns:

  • Added trailing comma after "MOVE_TO" translation
  • Added Polish translations for "SORT" ("Sortuj") and "ICON" ("Ikona")
apps/web/locales/it.json (1)

232-234: LGTM! The new localization keys are properly structured.

The added Italian translations for sorting and icon functionality maintain consistency with the existing localization patterns and appear to be grammatically correct.

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

232-234: LGTM! Translations and syntax are correct.

The changes look good:

  • The trailing comma after "MOVE_TO" maintains proper JSON syntax
  • The new translations for "SORT" ("Сортировать") and "ICON" ("Иконка") are accurate Russian translations
  • The changes are consistent with other language files mentioned in the summary

232-234: Verify consistency across all language files.

Let's ensure the new keys are present in all language files with proper translations.

✅ Verification successful

Let me try a different script to properly check the structure and content of these files.


Translation keys are consistent across all language files

The verification shows that both SORT and ICON keys are present in all language files (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh) with appropriate translations for each language. The keys are correctly placed under the common section as expected.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if all language files have the required keys
# Expected: All language files should have SORT and ICON keys under the common section

echo "Checking language files for required keys..."
for lang_file in $(fd -e json . apps/web/locales); do
  echo "Checking $lang_file..."
  
  # Check if the file has the required keys
  jq -r '.common | select(.SORT == null or .ICON == null) | path | join(".")' "$lang_file"
  
  if [ $? -eq 0 ]; then
    echo "✓ File has all required keys"
  else
    echo "⚠ Missing required keys"
  fi
done

Length of output: 6748


Script:

#!/bin/bash
# Let's first check the actual structure of one of the files to understand how they're organized
echo "Checking structure of ru.json:"
cat apps/web/locales/ru.json | head -n 10

echo -e "\nNow checking for SORT and ICON keys in all locale files:"
for lang_file in $(fd -e json . apps/web/locales); do
  echo -e "\nFile: $lang_file"
  # Search for the exact keys, showing 2 lines of context
  rg -A 2 '"(SORT|ICON)":\s*"' "$lang_file"
done

Length of output: 3621

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

232-234: LGTM! Translations are accurate and well-formatted.

The new translations maintain consistency with the existing localization patterns and correctly handle Portuguese accents.

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

232-232: LGTM: Proper JSON syntax correction.

The added comma after the "MOVE_TO" entry is correct and necessary for valid JSON syntax.


233-234: LGTM: Accurate Spanish translations added.

The new translations are linguistically correct:

  • "SORT" → "Ordenar"
  • "ICON" → "Ícono"

Both translations are accurate and properly use Spanish diacritical marks.

Let's verify the consistency of these new keys across other language files:

✅ Verification successful

Let me verify the actual content of these keys in all language files to ensure they are properly translated and not missing.


Spanish translations are consistent with other language files

The Spanish translations "Ordenar" for "SORT" and "Ícono" for "ICON" are properly implemented and consistent with the translations in all other language files. Each language file contains appropriate translations that reflect the correct meaning in their respective languages, including proper use of diacritical marks where needed (e.g. "Ícono" in Spanish and Portuguese, "Icône" in French).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the new keys (SORT, ICON) exist in other language files
# Expected: These keys should be present in all language files

echo "Checking for SORT and ICON keys in all language files..."
rg -l '"SORT":|"ICON":' apps/web/locales/

Length of output: 491


Script:

#!/bin/bash
# Check the actual values of SORT and ICON in all locale files
for file in $(find apps/web/locales -name "*.json"); do
  echo "=== $file ==="
  rg -A 1 '"SORT":|"ICON":' "$file"
done

Length of output: 2955

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

232-234: LGTM! Verify translations across all language files.

The German translations look appropriate:

  • "SORT": "Sortieren" (correct German translation for "Sort")
  • "ICON": "Symbol" (correct German translation for "Icon")

Let's verify that these new keys are consistently added across all language files mentioned in the AI summary:

✅ Verification successful

Both "SORT" and "ICON" keys are consistently present across all language files

The verification shows that:

  • "SORT" key is present in all 13 language files (ar, bg, de, en, es, fr, he, it, nl, pl, pt, ru, zh)
  • "ICON" key is present in all 13 language files with appropriate translations
  • Each translation appears culturally and linguistically appropriate for its target language
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the new keys "SORT" and "ICON" are present in all language files
# Expected: All language files should have these keys with appropriate translations

# Test: Search for SORT and ICON keys in all locale files
echo "Checking SORT translations:"
rg '"SORT"' apps/web/locales/
echo -e "\nChecking ICON translations:"
rg '"ICON"' apps/web/locales/

Length of output: 1347

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

232-234: LGTM! Verify translations across all locale files.

The French translations for "MOVE_TO", "SORT", and "ICON" are linguistically accurate and properly formatted.

Let's verify the consistency of these new keys across other locale files:

✅ Verification successful

All translation keys are properly synchronized across locale files

Based on the verification results:

  • "SORT" and "ICON" are present and properly translated in all web locale files (en, fr, de, es, it, nl, pl, pt, ru, zh, ar, bg, he)
  • "MOVE_TO" is also present and correctly translated across all locale files
  • The French translations are linguistically accurate:
    • "MOVE_TO": "Déplacer vers"
    • "SORT": "Trier"
    • "ICON": "Icône"
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if the new keys exist in all locale files
# Expected: All locale files should have these keys

# Find all locale files and check for the presence of the new keys
fd -e json -x sh -c 'echo "=== Checking {}" && jq -r ".common | select(.SORT != null and .ICON != null) | {SORT, ICON}" {}' . apps/web/locales/

Length of output: 3299


Script:

#!/bin/bash
# Let's check for the MOVE_TO key specifically since it wasn't captured in the previous query
fd -e json -x sh -c 'echo "=== Checking {}" && jq -r ".common.MOVE_TO" {}' . apps/web/locales/

Length of output: 3083

apps/web/lib/features/task/task-status.tsx (2)

36-36: LGTM: Good addition of contrast helper.

The import of getTextColor helper function is a good practice for ensuring text readability by dynamically determining the text color based on the background color.


1032-1032: LGTM: Consistent height styling.

The addition of "h-full" className to the Tooltip component maintains consistency with the styling approach used throughout the file.

apps/web/app/services/server/fetch.ts Outdated Show resolved Hide resolved
apps/web/lib/settings/list-card.tsx Show resolved Hide resolved
apps/web/lib/settings/list-card.tsx Outdated Show resolved Hide resolved
apps/web/lib/settings/list-card.tsx Outdated Show resolved Hide resolved
apps/web/lib/settings/task-statuses-form.tsx Show resolved Hide resolved
apps/web/lib/settings/task-statuses-form.tsx Show resolved Hide resolved
apps/web/lib/settings/task-statuses-form.tsx Show resolved Hide resolved
@evereq
Copy link
Member

evereq commented Oct 25, 2024

@CREDO23 :

  1. Please review suggestions by Coderabbit and resolve each one (adjust code or close each one)
  2. Please look in picture below, why selector for status has different default color compared to other, e.g. icon selector!?

image

@evereq evereq requested a review from Cedric921 October 25, 2024 16:53
@Cedric921 Cedric921 added this to the v0.2.0 milestone Oct 25, 2024
@CREDO23
Copy link
Contributor Author

CREDO23 commented Oct 25, 2024

@CREDO23 :

  1. Please review suggestions by Coderabbit and resolve each one (adjust code or close each one)
  2. Please look in picture below, why selector for status has different default color compared to other, e.g. icon selector!?

image

@evereq , @KostyaEver suggested stopping working on this ! I will continue after having a call with him and @GloireMutaliko21 !
So I will keep this as a draft for now !

@CREDO23 CREDO23 marked this pull request as draft October 25, 2024 17:12
Copy link
Contributor

@Cedric921 Cedric921 left a comment

Choose a reason for hiding this comment

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

I've just reviewed it,
The RabbitAI refactor suggestions is very pertinent (especially the ones I've stuck with 👍🏽) , When you will continue to work on this Task, try to integrate/fix them.
@CREDO23

@CREDO23 CREDO23 force-pushed the 3165-bug-settings--status-add-status-type-issue-in-editcreate-mode branch from 74ffd3e to 3a959b6 Compare November 7, 2024 03:02
@CREDO23 CREDO23 marked this pull request as ready for review November 7, 2024 03:04
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 (5)
apps/web/app/services/server/fetch.ts (1)

58-68: Enhance cache documentation.

Consider adding more detailed documentation about:

  • Cache entry lifetime
  • Memory implications
  • Cache invalidation strategy
-/** Tasks status SVG icons fetch */
-
-// In memory cache for performance
+/**
+ * Cache for Tasks Status SVG icons.
+ * 
+ * Implements an in-memory caching strategy to reduce network requests:
+ * - Lifetime: Controlled by tasksStatusSvgCacheDuration
+ * - Storage: Keeps Response object and timestamp
+ * - Invalidation: Automatic based on timestamp
+ */
apps/web/lib/settings/list-card.tsx (3)

31-35: Enhance type safety and error handling in useEffect.

The current implementation could benefit from additional type safety and error handling:

  1. Add type guard for statusIcon
  2. Add error boundary for SVG loading failures
 useEffect(() => {
-  if (statusIcon) {
+  if (typeof statusIcon === 'string' && statusIcon.trim()) {
     loadSVG(statusIcon, 'icon-container' + statusTitle, textColor);
+  } else {
+    console.warn('Invalid or empty statusIcon provided');
   }
 }, [statusIcon, statusTitle, textColor]);

108-108: Remove debug console.log statement.

Debug logging should be removed before merging to production.

- console.log(container);

102-103: Improve SVG color replacement logic.

The current regex pattern might miss complex SVG structures with different stroke attribute formats. Consider using a more robust approach:

- // Update the fill color in the SVG content
- svgContent = svgContent.replace(/stroke="[^"]*"/g, `stroke="${color}"`);
+ // Update all variations of stroke attributes
+ svgContent = svgContent
+   .replace(/stroke=["']([^"']*?)["']/g, `stroke="${color}"`)
+   .replace(/stroke:\s*([^;}]*)/g, `stroke: ${color}`);
apps/web/lib/settings/task-statuses-form.tsx (1)

271-275: Simplify complex ternary expression

The nested ternary expression for the active prop could be simplified for better readability.

-active={
-  selectedStatusType ? getIcon(selectedStatusType)
-    : edit
-    ? (iconList.find(
-        (icon) => icon.path === edit.icon
-      ) as IIcon) : null
-}
+active={
+  selectedStatusType 
+    ? getIcon(selectedStatusType)
+    : edit?.icon 
+      ? iconList.find(icon => icon.path === edit.icon) ?? null 
+      : null
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 74ffd3e and 3a959b6.

📒 Files selected for processing (19)
  • apps/web/app/constants.ts (1 hunks)
  • apps/web/app/services/server/fetch.ts (2 hunks)
  • apps/web/lib/features/task/task-status.tsx (4 hunks)
  • apps/web/lib/settings/icon-items.tsx (4 hunks)
  • apps/web/lib/settings/list-card.tsx (4 hunks)
  • apps/web/lib/settings/task-statuses-form.tsx (8 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 (15)
  • apps/web/lib/features/task/task-status.tsx
  • apps/web/lib/settings/icon-items.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/pl.json
  • apps/web/locales/pt.json
  • apps/web/locales/ru.json
  • apps/web/locales/zh.json
🔇 Additional comments (5)
apps/web/app/services/server/fetch.ts (1)

70-86: Verify SVG fetch integration with status type dropdown.

The SVG fetch implementation is part of the status type dropdown fix. Let's verify the integration points:

✅ Verification successful

Based on the search results, I can now provide a conclusive response about the SVG fetch implementation and its integration with the status type dropdown:

SVG fetch implementation is correctly integrated with status handling components

The codebase analysis shows:

  • svgFetch is used in StatusesListCard component for loading status icons
  • The implementation includes proper caching and error handling
  • The function is well integrated with various status-related components across the application

Key integration points found:

  • apps/web/lib/settings/list-card.tsx uses svgFetch for loading status icons with proper error handling
  • Status icons are consistently used across task status, priority, and label components
  • The cache implementation helps prevent unnecessary refetches
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for svgFetch usage in status-related components
echo "Searching for svgFetch usage in status components..."
rg -l "svgFetch" | grep -i "status"

# Search for SVG-related error handling in UI components
echo "Checking error handling in UI components..."
rg "catch.*svgFetch" 

Length of output: 268


Script:

#!/bin/bash
# Let's try a broader search to understand the SVG fetch usage
echo "Searching for all svgFetch references..."
rg "svgFetch" -A 3 -B 3

# Look for status-related components that might use SVG icons
echo "Searching for status icon usage..."
rg -i "status.*icon|icon.*status" -A 3 -B 3

# Check for any imports of the fetch module
echo "Checking imports of the fetch module..."
rg "from ['\"]\.\./services/server/fetch" -A 1 -B 1

Length of output: 69133

apps/web/lib/settings/list-card.tsx (2)

8-9: LGTM: Import statements are correctly added.

The new imports are necessary for the SVG loading functionality.


47-47: Skip review: ID generation security already addressed.

A previous review has already provided comprehensive feedback on improving ID generation security.

apps/web/app/constants.ts (1)

212-213: LGTM! Consider adding a descriptive comment.

The constant's value (1 hour) is reasonable for caching static SVG assets. Consider adding a comment to explain the duration choice.

+// Cache SVG assets for 1 hour to reduce unnecessary network requests
 export const tasksStatusSvgCacheDuration = 1000 * 60 * 60;

Let's verify how this constant is being used:

✅ Verification successful

Constant is correctly used for SVG caching in fetch service

The constant is properly imported and utilized in apps/web/app/services/server/fetch.ts for caching SVG responses. The implementation checks if the cached content is within the 1-hour duration before deciding to fetch a new SVG.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find all usages of the tasksStatusSvgCacheDuration constant
# Expected: Usage in SVG fetching/caching logic

rg "tasksStatusSvgCacheDuration" -A 5

Length of output: 1094

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

33-34: Implementation successfully addresses the status type dropdown issue

The changes correctly handle the status type selection and random color generation, fixing the reported bug where status type appeared in the wrong dropdown. The implementation:

  1. Properly manages status type selection
  2. Generates random colors for new statuses
  3. Correctly updates the form state

Also applies to: 193-197, 260-263

apps/web/app/services/server/fetch.ts Outdated Show resolved Hide resolved
apps/web/lib/settings/task-statuses-form.tsx Outdated Show resolved Hide resolved
@CREDO23 CREDO23 force-pushed the 3165-bug-settings--status-add-status-type-issue-in-editcreate-mode branch 2 times, most recently from b7f47e9 to 2227e2b Compare November 7, 2024 13:49
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 (4)
apps/web/app/services/server/fetch.ts (1)

62-68: Consider adding cache management features.

While the cache implementation is good, consider these improvements for production readiness:

  1. Add maximum cache size limit
  2. Implement cache cleanup for old entries
  3. Add stronger type safety
+// Maximum number of entries to store in cache
+const MAX_CACHE_SIZE = 100;
+
+type SvgCacheEntry = {
+  content: Response;
+  timestamp: number;
+};
+
-const tasksStatusSvgCache = new Map<
-  string,
-  {
-    content: Response;
-    timestamp: number;
-  }
->();
+const tasksStatusSvgCache = new Map<string, SvgCacheEntry>();
+
+function cleanupCache(): void {
+  const now = Date.now();
+  // Remove expired entries
+  for (const [url, entry] of tasksStatusSvgCache) {
+    if (now - entry.timestamp >= tasksStatusSvgCacheDuration) {
+      tasksStatusSvgCache.delete(url);
+    }
+  }
+  // Remove oldest entries if cache is too large
+  if (tasksStatusSvgCache.size > MAX_CACHE_SIZE) {
+    const entries = Array.from(tasksStatusSvgCache.entries());
+    entries.sort((a, b) => a[1].timestamp - b[1].timestamp);
+    const entriesToRemove = entries.slice(0, entries.length - MAX_CACHE_SIZE);
+    for (const [url] of entriesToRemove) {
+      tasksStatusSvgCache.delete(url);
+    }
+  }
+}
apps/web/lib/settings/task-statuses-form.tsx (3)

160-184: Consider optimizing status mappings

The implementation is good, but could be enhanced for better maintainability.

Consider moving STATUS_MAPPINGS outside the component and expanding it:

+const STATUS_MAPPINGS: Record<string, string> = {
+  'ready-for-review': 'ready',
+  'in-review': 'ready',
+  // Add more mappings as needed
+};

export const TaskStatusesForm = ({ ... }) => {
  // ...
  const getIcon = useCallback(
    (iconName: string | null) => {
      if (!iconName) return null;
-     const STATUS_MAPPINGS: Record<string, string> = {
-       'ready-for-review': 'ready'
-     };
      const name = STATUS_MAPPINGS[iconName] || iconName;

201-205: Potential race condition in color generation effect

The effect might trigger multiple color generations if selectedStatusType changes rapidly.

Consider debouncing the color generation:

+import { useCallback, useEffect, useMemo, useState } from 'react';
+import debounce from 'lodash/debounce';

 useEffect(() => {
+  const debouncedColorGeneration = debounce(() => {
     if (!edit && selectedStatusType) {
       setRandomColor(getRandomColor());
     }
+  }, 300);
+
+  debouncedColorGeneration();
+  return () => debouncedColorGeneration.cancel();
 }, [selectedStatusType, edit, getRandomColor]);

268-273: Consider unifying status type state management

The current implementation manages status type in both form values and component state, which could lead to synchronization issues.

Consider using a single source of truth:

 <StandardTaskStatusDropDown
-  onValueChange={(status) => {
-    setValue('template', status)
-    setSelectedStatusType(status)
-  }}
+  onValueChange={useCallback((status) => {
+    setValue('template', status);
+    setSelectedStatusType(status);
+  }, [setValue, setSelectedStatusType])}
   className="h-14 shrink-0"
   defaultValue={edit?.value}
 />
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3a959b6 and 2227e2b.

📒 Files selected for processing (2)
  • apps/web/app/services/server/fetch.ts (2 hunks)
  • apps/web/lib/settings/task-statuses-form.tsx (8 hunks)
🔇 Additional comments (1)
apps/web/lib/settings/task-statuses-form.tsx (1)

33-34: LGTM: Well-structured state management

The new state variables are properly typed and follow React's state management best practices. The null/undefined initial states are appropriate for their use cases.

apps/web/lib/settings/task-statuses-form.tsx Show resolved Hide resolved
@CREDO23 CREDO23 requested a review from Cedric921 November 7, 2024 17:07
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 2227e2b and 4925327.

📒 Files selected for processing (2)
  • .vscode/settings.json (1 hunks)
  • apps/web/components/ui/dropdown-menu.tsx (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .vscode/settings.json
🔇 Additional comments (1)
apps/web/components/ui/dropdown-menu.tsx (1)

Line range hint 1-1: Verify the status type dropdown fix.

The changes in this file appear to be unrelated to the main PR objective of fixing the status type appearing in the wrong dropdown. Could you please point to the specific changes that address this issue? This will help ensure the PR effectively resolves the reported bug.

apps/web/components/ui/dropdown-menu.tsx Outdated Show resolved Hide resolved
apps/web/components/ui/dropdown-menu.tsx Outdated Show resolved Hide resolved
@evereq
Copy link
Member

evereq commented Nov 8, 2024

@CREDO23 can you summarize yourself what changes this PR introduce from UX / UI point of view? How it worked before vs how it works now? Maybe record Loom or at min send screenshots please

@CREDO23
Copy link
Contributor Author

CREDO23 commented Nov 9, 2024

@CREDO23 can you summarize yourself what changes this PR introduce from UX / UI point of view? How it worked before vs how it works now? Maybe record Loom or at min send screenshots please

@evereq

  • Introduce the getTextColor function to set a suitable color accordingly the background of the status item
  • Fix background and size of dropdowns (status type, size, priority)
  • Autos elect the icon when the user selects/changes the status type
  • Auto select a random color when the user selects/changes the status type
  • Add in memory caching mechanism to improve UX/performance

@CREDO23 CREDO23 force-pushed the 3165-bug-settings--status-add-status-type-issue-in-editcreate-mode branch from 4925327 to 66b454e Compare November 9, 2024 05:13
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 (1)
apps/web/app/services/server/fetch.ts (1)

58-68: Consider implementing cache size limits and cleanup.

While the cache implementation is good, it could benefit from memory management features:

  1. Maximum cache size limit
  2. Periodic cleanup of expired entries

Consider enhancing the cache implementation:

const MAX_CACHE_SIZE = 100; // Adjust based on your needs

const tasksStatusSvgCache = new Map<string, {
  content: Response;
  timestamp: number;
}>();

// Add this function to manage cache size
function cleanupCache() {
  const now = Date.now();
  
  // Remove expired entries
  for (const [key, value] of tasksStatusSvgCache.entries()) {
    if (now - value.timestamp >= tasksStatusSvgCacheDuration) {
      tasksStatusSvgCache.delete(key);
    }
  }
  
  // If still over size limit, remove oldest entries
  if (tasksStatusSvgCache.size > MAX_CACHE_SIZE) {
    const entries = Array.from(tasksStatusSvgCache.entries())
      .sort((a, b) => a[1].timestamp - b[1].timestamp);
    
    const entriesToRemove = entries.slice(0, entries.length - MAX_CACHE_SIZE);
    for (const [key] of entriesToRemove) {
      tasksStatusSvgCache.delete(key);
    }
  }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4925327 and 66b454e.

📒 Files selected for processing (20)
  • .vscode/settings.json (1 hunks)
  • apps/web/app/constants.ts (1 hunks)
  • apps/web/app/services/server/fetch.ts (2 hunks)
  • apps/web/lib/features/task/task-status.tsx (4 hunks)
  • apps/web/lib/settings/icon-items.tsx (4 hunks)
  • apps/web/lib/settings/list-card.tsx (4 hunks)
  • apps/web/lib/settings/task-statuses-form.tsx (8 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 (19)
  • .vscode/settings.json
  • apps/web/app/constants.ts
  • apps/web/lib/features/task/task-status.tsx
  • apps/web/lib/settings/icon-items.tsx
  • apps/web/lib/settings/list-card.tsx
  • apps/web/lib/settings/task-statuses-form.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/pl.json
  • apps/web/locales/pt.json
  • apps/web/locales/ru.json
  • apps/web/locales/zh.json
🔇 Additional comments (3)
apps/web/app/services/server/fetch.ts (3)

1-1: LGTM: Import statement is correctly structured.

The import statement appropriately includes the new cache duration constant.


70-93: Previous review comments about error handling are still applicable.

The implementation still needs improvements in error handling and response validation as mentioned in the previous reviews.


70-93: Verify SVG fetch implementation usage.

Let's verify how this function is being used in the status type dropdown implementation.

✅ Verification successful

Let me check the actual usage context of svgFetch to better understand its implementation.


Let me check the complete implementation context of the SVG loading functionality to understand the full usage pattern.


SVG fetch implementation is properly used and cached

The verification shows that:

  • svgFetch is used appropriately in list-card.tsx for loading status icons with proper error handling
  • The implementation includes caching mechanism with tasksStatusSvgCache and configurable duration
  • The function is used within a well-structured component that handles SVG loading, color manipulation, and rendering
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check usage of svgFetch function and related components

# Check for svgFetch usage
echo "Checking svgFetch usage:"
rg -l "svgFetch"

# Check for status type dropdown related files
echo -e "\nChecking status type dropdown related files:"
rg -l "StatusType.*dropdown|dropdown.*StatusType"

# Check for SVG-related imports
echo -e "\nChecking SVG-related imports:"
rg -l "import.*\.svg"

Length of output: 448


Script:

#!/bin/bash
# Check the implementation details of svgFetch usage in list-card.tsx
echo "Content of list-card.tsx where svgFetch is used:"
rg -A 5 -B 5 "svgFetch" "apps/web/lib/settings/list-card.tsx"

# Check if there are any other SVG-related fetch operations
echo -e "\nChecking for other SVG fetch patterns:"
rg -l "fetch.*svg|svg.*fetch"

Length of output: 1047


Script:

#!/bin/bash
# Get the complete context of SVG loading implementation
echo "Complete context of SVG loading in list-card.tsx:"
rg -A 15 -B 15 "loadSVG" "apps/web/lib/settings/list-card.tsx"

# Check for any SVG-related cache implementations
echo -e "\nChecking for SVG cache related code:"
rg "tasksStatusSvgCache" --type ts

Length of output: 2527

@CREDO23 CREDO23 force-pushed the 3165-bug-settings--status-add-status-type-issue-in-editcreate-mode branch from 66b454e to 8d95317 Compare November 11, 2024 10:07
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

🧹 Outside diff range and nitpick comments (1)
apps/web/app/services/server/fetch.ts (1)

58-68: Enhance cache documentation.

Consider adding more detailed documentation about:

  • Cache expiration strategy
  • Memory implications
  • Cache invalidation approach
-/** Tasks status SVG icons fetch */
-
-// In memory cache for performance
+/**
+ * In-memory cache for SVG responses to improve performance and reduce network calls.
+ * Cache entries expire after the duration specified in tasksStatusSvgCacheDuration.
+ * Note: This cache is cleared when the server restarts.
+ */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 66b454e and 8d95317.

📒 Files selected for processing (20)
  • .vscode/settings.json (1 hunks)
  • apps/web/app/constants.ts (1 hunks)
  • apps/web/app/services/server/fetch.ts (2 hunks)
  • apps/web/lib/features/task/task-status.tsx (4 hunks)
  • apps/web/lib/settings/icon-items.tsx (4 hunks)
  • apps/web/lib/settings/list-card.tsx (4 hunks)
  • apps/web/lib/settings/task-statuses-form.tsx (8 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 (18)
  • .vscode/settings.json
  • apps/web/app/constants.ts
  • apps/web/lib/features/task/task-status.tsx
  • apps/web/lib/settings/icon-items.tsx
  • apps/web/lib/settings/list-card.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/pl.json
  • apps/web/locales/pt.json
  • apps/web/locales/ru.json
  • apps/web/locales/zh.json
🧰 Additional context used
📓 Learnings (1)
apps/web/lib/settings/task-statuses-form.tsx (1)
Learnt from: CREDO23
PR: ever-co/ever-teams#3185
File: apps/web/lib/settings/task-statuses-form.tsx:187-199
Timestamp: 2024-11-07T14:04:24.336Z
Learning: In `apps/web/lib/settings/task-statuses-form.tsx`, when generating colors in the `getRandomColor` function, prefer to keep generating them randomly to have more than five colors, even if it might affect color accessibility.
🔇 Additional comments (7)
apps/web/lib/settings/task-statuses-form.tsx (7)

33-34: LGTM: New state management for status type and color

The addition of selectedStatusType and randomColor state variables properly separates the status type selection from the icon selection, addressing the core issue.


160-184: LGTM: Well-structured icon retrieval function

The getIcon function is well-implemented with proper null checks and status mapping. The use of a STATUS_MAPPINGS object makes it easy to maintain special cases.


187-199: LGTM: Random color generation as requested

The implementation aligns with the requirement to keep generating colors randomly for more variety, as confirmed in the learnings.


268-273: LGTM: Improved status type handling

The status type selection now properly updates both the form value and the selected status type state.


279-284: LGTM: Enhanced icon selection logic

The IconPopover's active state now correctly depends on the selected status type first, falling back to edit state when needed.


301-303: LGTM: Proper state cleanup

The status type state is properly reset when the form is submitted or cancelled, preventing stale state issues.

Also applies to: 314-314


42-50: Verify support for new status types and sizes

New status type 'backlog' and additional task sizes have been added. Let's verify that these new values are properly supported throughout the codebase.

apps/web/app/services/server/fetch.ts Show resolved Hide resolved
@evereq
Copy link
Member

evereq commented Nov 14, 2024

@CREDO23 what is with this PR, can it be merged / ready for review? CC: @Cedric921

@CREDO23
Copy link
Contributor Author

CREDO23 commented Nov 15, 2024

@CREDO23 what is with this PR, can it be merged / ready for review? CC: @Cedric921

Yes @evereq, it can be merged !
@Cedric921 can review it before as well !

)}
</div>
<span className={clsxm('text-normal', 'whitespace-nowrap text-ellipsis overflow-hidden capitalize')}>
Copy link
Member

Choose a reason for hiding this comment

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

@CREDO23 why this "title" was here and now we don't need it? How it was displayed before (e.g. was icon + title) and how it's displayed now (only icon!?). I just don't understand how {title} can be replaced with static {t('common.ICON')}?

@evereq
Copy link
Member

evereq commented Nov 18, 2024

@CREDO23 see my comment above. I am merging this anyway, but if need more fixes create new branches based on develop please.

@evereq evereq merged commit 5b1a6bd into develop Nov 18, 2024
13 checks passed
@evereq evereq deleted the 3165-bug-settings--status-add-status-type-issue-in-editcreate-mode branch November 18, 2024 19:25
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.

[Bug] Settings | Status - add Status type issue in Edit/Create mode
3 participants