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

[WEB-2226]chore: updated 'Issue states' settings ui #6338

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

mathalav55
Copy link
Collaborator

@mathalav55 mathalav55 commented Jan 7, 2025

Description

Updates 'Issue states' settings to match with project states settings.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

References

WEB-2226

Summary by CodeRabbit

  • New Features

    • Added multiline description input using TextArea in state form
    • Introduced group expansion functionality for state management
    • Enhanced state group visualization with improved layout and icons
  • Bug Fixes

    • Improved drag-and-drop component responsiveness
    • Updated effect dependencies to better handle state changes
  • Style

    • Refined form and state item layouts
    • Adjusted padding and styling for state components

@mathalav55 mathalav55 added 🌟enhancement New feature or request 🌐frontend labels Jan 7, 2025
@mathalav55 mathalav55 added this to the v0.24.2 milestone Jan 7, 2025
@mathalav55 mathalav55 self-assigned this Jan 7, 2025
Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

Walkthrough

This pull request introduces modifications to several components within the project states management system. The changes primarily focus on enhancing the user interface and interaction for state management, including improvements to form inputs, group item rendering, and state item styling. The modifications include adding a TextArea for descriptions, implementing group expansion functionality, and refining the visual presentation of state-related components.

Changes

File Change Summary
web/core/components/project-states/create-update/form.tsx Added TextArea for description input, improved form layout with space-y-2 class
web/core/components/project-states/group-item.tsx Added group expansion props, modified rendering logic for state groups
web/core/components/project-states/group-list.tsx Introduced state management for group expansion with groupsExpanded state
web/core/components/project-states/state-item-title.tsx Removed padding classes from outer div
web/core/components/project-states/state-item.tsx Updated useEffect dependency array, added background and padding classes

Sequence Diagram

sequenceDiagram
    participant User
    participant GroupList
    participant GroupItem
    participant StateItem

    User->>GroupList: Interact with states
    GroupList->>GroupList: Manage groupsExpanded state
    GroupList->>GroupItem: Pass expansion handlers
    GroupItem->>GroupItem: Toggle group visibility
    GroupItem->>StateItem: Render states when expanded
Loading

Possibly related PRs

Suggested labels

🧹chore

Suggested reviewers

  • SatishGandham
  • sriramveeraghanta
  • rahulramesha

Poem

🐰 Hopping through code with glee,
States and groups now dance free!
TextArea blooms, icons sway,
Expansion magic finds its way.
A rabbit's code, both sleek and bright! 🚀


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

🔭 Outside diff range comments (1)
web/core/components/project-states/create-update/form.tsx (1)

Line range hint 31-46: Improve error handling and user feedback.

The current error handling only logs to console, which isn't helpful for users. Consider implementing proper error feedback.

 const formSubmit = async (event: FormEvent<HTMLFormElement>) => {
   event.preventDefault();

   const name = formData?.name || undefined;
   if (!formData || !name) {
     let currentErrors: Partial<Record<keyof IState, string>> = {};
     if (!name) currentErrors = { ...currentErrors, name: "Name is required" };
     setErrors(currentErrors);
     return;
   }

   try {
     await onSubmit(formData);
   } catch (error) {
-    console.log("error", error);
+    // Set form-level error
+    setErrors((prev) => ({
+      ...prev,
+      form: "Failed to save state. Please try again.",
+    }));
+    // Optionally, propagate error to parent
+    props.onError?.(error);
   }
 };

You'll need to:

  1. Add onError to the TStateForm type
  2. Display the form-level error message to users
🧹 Nitpick comments (6)
web/core/components/project-states/create-update/form.tsx (2)

86-94: Consider adjusting TextArea layout behavior.

While the TextArea implementation is good, consider setting both min-height and max-height to prevent unexpected layout shifts during user input.

-        className="w-full text-sm min-h-14 resize-none"
+        className="w-full text-sm min-h-14 max-h-32 resize-y"

This change would:

  • Allow vertical resizing for better UX
  • Prevent the form from growing too tall
  • Maintain a consistent layout

96-103: Add loading state to the submit button.

Consider adding a loading indicator to provide visual feedback during form submission.

-          <Button type="submit" variant="primary" size="sm" disabled={buttonDisabled}>
+          <Button 
+            type="submit" 
+            variant="primary" 
+            size="sm" 
+            disabled={buttonDisabled}
+            loading={isSubmitting}
+          >
             {buttonTitle}
           </Button>

You'll need to add an isSubmitting state:

const [isSubmitting, setIsSubmitting] = useState(false);

const formSubmit = async (event: FormEvent<HTMLFormElement>) => {
  event.preventDefault();
  setIsSubmitting(true);
  try {
    await onSubmit(formData);
  } catch (error) {
    console.log("error", error);
  } finally {
    setIsSubmitting(false);
  }
};
web/core/components/project-states/group-list.tsx (2)

20-27: Consider memoizing the collapse handler.

While the implementation is correct, consider using useCallback for the handler to prevent unnecessary re-renders of child components.

-  const handleGroupCollapse = (groupKey: TStateGroups) => {
+  const handleGroupCollapse = useCallback((groupKey: TStateGroups) => {
     setGroupsExpanded((prev) => {
       if (prev.includes(groupKey)) {
         return prev.filter((key) => key !== groupKey);
       }
       return prev;
     });
-  };
+  }, []);

29-36: Consider memoizing the expand handler.

Similar to the collapse handler, consider using useCallback here as well.

-  const handleExpand = (groupKey: TStateGroups) => {
+  const handleExpand = useCallback((groupKey: TStateGroups) => {
     setGroupsExpanded((prev) => {
       if (prev.includes(groupKey)) {
         return prev;
       }
       return [...prev, groupKey];
     });
-  };
+  }, []);
web/core/components/project-states/group-item.tsx (1)

42-45: Consider memoizing derived values.

The currentStateExpanded value could be memoized to prevent unnecessary recalculations.

+ const currentStateExpanded = useMemo(() => 
+   groupsExpanded.includes(groupKey),
+   [groupsExpanded, groupKey]
+ );
- const currentStateExpanded = groupsExpanded.includes(groupKey);
web/core/components/project-states/state-item.tsx (1)

131-131: Consider extracting className to a constant.

The className string is quite long and could be extracted for better maintainability.

+ const stateItemClassName = cn(
+   "relative border border-custom-border-100 bg-custom-background-100 py-3 px-3.5 rounded group",
+   isDragging ? `opacity-50` : `opacity-100`,
+   totalStates === 1 ? `cursor-auto` : `cursor-grab`
+ );

  <div
    ref={draggableElementRef}
-   className={cn(
-     "relative border border-custom-border-100 bg-custom-background-100 py-3 px-3.5 rounded group",
-     isDragging ? `opacity-50` : `opacity-100`,
-     totalStates === 1 ? `cursor-auto` : `cursor-grab`
-   )}
+   className={stateItemClassName}
  >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 906d095 and 48a730e.

📒 Files selected for processing (5)
  • web/core/components/project-states/create-update/form.tsx (2 hunks)
  • web/core/components/project-states/group-item.tsx (1 hunks)
  • web/core/components/project-states/group-list.tsx (3 hunks)
  • web/core/components/project-states/state-item-title.tsx (1 hunks)
  • web/core/components/project-states/state-item.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-web
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
web/core/components/project-states/create-update/form.tsx (2)

6-6: LGTM! Import changes are well-organized.

The addition of TextArea import aligns with the form's enhanced description field functionality.


62-70: Well-structured layout with proper spacing!

The form layout effectively uses flexbox for:

  • Horizontal spacing between color picker and inputs
  • Proper containment of the color picker
  • Consistent vertical spacing in the main content area
web/core/components/project-states/group-list.tsx (1)

17-18: LGTM! Well-typed state management.

The state initialization with proper TypeScript types ensures type safety.

web/core/components/project-states/state-item-title.tsx (1)

26-26: Verify padding removal impact.

The removal of padding classes (py-4 px-2) might affect the component's layout and touch targets for interactive elements.

✅ Verification successful

Padding removal is properly handled.

The removal of padding classes is safe as spacing is maintained through:

  • Flex container with gap utilities
  • Inner text container padding (px-2)
  • Properly sized interactive elements
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if padding is handled by parent components
rg -l 'py-[2-4]|px-[2-4]' --type ts --type tsx

Length of output: 76


Script:

#!/bin/bash
# Search for padding classes in TypeScript and TypeScript React files
rg -l 'py-[2-4]|px-[2-4]' --type-add 'tsx:*.{tsx,ts}' --type tsx

# Get context around StateItemTitle usage
rg -B 3 -A 3 "StateItemTitle" --type-add 'tsx:*.{tsx,ts}' --type tsx

# Look at the complete file content to understand component structure
cat web/core/components/project-states/state-item-title.tsx

Length of output: 30631

web/core/components/project-states/group-item.tsx (1)

19-21: LGTM! Well-defined prop types.

The new props are properly typed with TypeScript, ensuring type safety.

web/core/components/project-states/state-item.tsx (1)

110-110: LGTM! Proper effect dependencies.

The addition of disabled to the dependency array is correct as it affects the drag behavior.

Comment on lines +54 to +80
<div className="flex justify-between items-center gap-2">
<div
className="w-full flex items-center cursor-pointer py-1"
onClick={() => (!currentStateExpanded ? handleExpand(groupKey) : handleGroupCollapse(groupKey))}
>
<div
className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden transition-colors hover:bg-custom-background-80 cursor-pointer text-custom-primary-100/80 hover:text-custom-primary-100"
onClick={() => !createState && setCreateState(true)}
className={cn(
"flex-shrink-0 w-5 h-5 rounded flex justify-center items-center overflow-hidden transition-all",
{
"rotate-0": currentStateExpanded,
"-rotate-90": !currentStateExpanded,
}
)}
>
<Plus className="w-4 h-4" />
<ChevronDown className="w-4 h-4" />
</div>
<div className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden">
<StateGroupIcon stateGroup={groupKey} height="16px" width="16px" />
</div>
)}
<div className="text-base font-medium text-custom-text-200 capitalize px-1">{groupKey}</div>
</div>
<div
className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden transition-colors hover:bg-custom-background-80 cursor-pointer text-custom-primary-100/80 hover:text-custom-primary-100"
onClick={() => !createState && setCreateState(true)}
>
<Plus className="w-4 h-4" />
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add ARIA attributes for accessibility.

The expandable section should have proper ARIA attributes for better accessibility.

 <div
   className="flex justify-between items-center gap-2"
+  role="button"
+  aria-expanded={currentStateExpanded}
+  aria-controls={`group-${groupKey}-content`}
 >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div className="flex justify-between items-center gap-2">
<div
className="w-full flex items-center cursor-pointer py-1"
onClick={() => (!currentStateExpanded ? handleExpand(groupKey) : handleGroupCollapse(groupKey))}
>
<div
className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden transition-colors hover:bg-custom-background-80 cursor-pointer text-custom-primary-100/80 hover:text-custom-primary-100"
onClick={() => !createState && setCreateState(true)}
className={cn(
"flex-shrink-0 w-5 h-5 rounded flex justify-center items-center overflow-hidden transition-all",
{
"rotate-0": currentStateExpanded,
"-rotate-90": !currentStateExpanded,
}
)}
>
<Plus className="w-4 h-4" />
<ChevronDown className="w-4 h-4" />
</div>
<div className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden">
<StateGroupIcon stateGroup={groupKey} height="16px" width="16px" />
</div>
)}
<div className="text-base font-medium text-custom-text-200 capitalize px-1">{groupKey}</div>
</div>
<div
className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden transition-colors hover:bg-custom-background-80 cursor-pointer text-custom-primary-100/80 hover:text-custom-primary-100"
onClick={() => !createState && setCreateState(true)}
>
<Plus className="w-4 h-4" />
</div>
<div
className="flex justify-between items-center gap-2"
role="button"
aria-expanded={currentStateExpanded}
aria-controls={`group-${groupKey}-content`}
>
<div
className="w-full flex items-center cursor-pointer py-1"
onClick={() => (!currentStateExpanded ? handleExpand(groupKey) : handleGroupCollapse(groupKey))}
>
<div
className={cn(
"flex-shrink-0 w-5 h-5 rounded flex justify-center items-center overflow-hidden transition-all",
{
"rotate-0": currentStateExpanded,
"-rotate-90": !currentStateExpanded,
}
)}
>
<ChevronDown className="w-4 h-4" />
</div>
<div className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden">
<StateGroupIcon stateGroup={groupKey} height="16px" width="16px" />
</div>
<div className="text-base font-medium text-custom-text-200 capitalize px-1">{groupKey}</div>
</div>
<div
className="flex-shrink-0 w-6 h-6 rounded flex justify-center items-center overflow-hidden transition-colors hover:bg-custom-background-80 cursor-pointer text-custom-primary-100/80 hover:text-custom-primary-100"
onClick={() => !createState && setCreateState(true)}
>
<Plus className="w-4 h-4" />
</div>

@pushya22 pushya22 merged commit f4c4848 into preview Jan 7, 2025
13 of 14 checks passed
@pushya22 pushya22 deleted the chore-issue_states_ui branch January 7, 2025 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟enhancement New feature or request 🌐frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants