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-2907] chore: issue store updated and code refactor #6279

Merged
merged 2 commits into from
Dec 26, 2024

Conversation

anmolsinghbhatia
Copy link
Collaborator

@anmolsinghbhatia anmolsinghbhatia commented Dec 26, 2024

Description

This PR includes following changes:

  • Refined UX copy for the issue layout.
  • Updated the issue store and performed code refactoring.

Type of Change

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

References

[WEB-2907]

Summary by CodeRabbit

  • New Features

    • Introduced an isEpic property across various components to differentiate between standard issues and epics, enhancing user interactions.
    • Updated input placeholders and required messages in forms to reflect whether an epic or standard issue is being created.
  • Bug Fixes

    • Improved logic for grouping and displaying issues based on their epic status in the Kanban and list layouts.
  • Chores

    • Streamlined component props and internal logic for better maintainability and clarity in handling issue types.

Copy link
Contributor

coderabbitai bot commented Dec 26, 2024

Walkthrough

The pull request introduces a comprehensive enhancement to issue management by adding an isEpic property across multiple components and stores. This change allows for more nuanced handling of issues and epics throughout the application, enabling components to differentiate between standard issues and epics. The modifications span various files in the web core, affecting type definitions, component props, store logic, and rendering behaviors.

Changes

File Path Change Summary
web/ce/components/issues/quick-add/root.tsx Added isEpic boolean property to TQuickAddIssueFormRoot type
web/core/components/issues/create-issue-toast-action-items.tsx Added optional isEpic property to conditionally handle issue/epic URLs and labels
web/core/components/issues/issue-layouts/*/quick-add/form/*.tsx Updated multiple quick-add form components to support isEpic prop for dynamic placeholders and messages
web/core/components/issues/issue-layouts/kanban/*.tsx Modified Kanban components to incorporate isEpic in grouping and rendering logic
web/core/store/issue/*.ts Refactored stores to handle epic-related details and initialization

Suggested Reviewers

  • rahulramesha
  • SatishGandham
  • sriramveeraghanta

Poem

🐰 Epic tales of code so bright,
Rabbit hops through issues' might,
isEpic flag now takes the stage,
Transforming workflows page by page,
A coding dance of pure delight! 🚀

Suggested Labels

🌟enhancement

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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.

@anmolsinghbhatia anmolsinghbhatia marked this pull request as ready for review December 26, 2024 14:08
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 (15)
web/core/components/issues/issue-layouts/quick-add/form/kanban.tsx (1)

15-15: Placeholder text updated based on isEpic.
This dynamic placeholder is helpful. Consider if any i18n or additional customization might be required.

web/core/components/issues/issue-layouts/quick-add/form/gantt.tsx (2)

21-23: Good approach for dynamic placeholders and validation messages.
Using isEpic to switch between "Epic" and "Issue" is a clean pattern. Consider centralizing strings in a constants file if you anticipate multiple similar dynamic expressions across the codebase.


29-29: Informative guidance for user input.
Displaying a dynamic message is beneficial for user experience. If you plan to localize the app, ensure this string is also covered.

web/ce/components/issues/quick-add/root.tsx (1)

37-37: Properly pulling isEpic from props.
The destructuring pattern is clear. Consider providing a default value (e.g., false) to avoid potential undefined instances if this prop is used across multiple apps or libraries.

web/core/store/issue/issue.store.ts (1)

42-42: Initializing the service within the constructor.
This approach is fine; if you require specialized configuration in the future, consider injecting dependencies instead for improved testability.

web/core/components/issues/issue-layouts/calendar/quick-add-issue-actions.tsx (2)

31-31: Destructuring default for isEpic.
Defaulting to false is a good move, ensuring no unintended truthy usage. Keep consistent defaults across other similar props.


126-127: Conditional menu items.
This approach for toggling "New Epic" vs. "New Issue" and adding the "Add existing issue" only if !isEpic is intuitive. Use caution if you eventually need “Add existing epic.”

web/ce/store/issue/issue-details/activity.store.ts (1)

100-100: Check for null/undefined comment object
Before calling currentStore.comment.getCommentsByIssueId(issueId), consider ensuring currentStore.comment is defined to prevent a runtime error if comment is missing or uninitialized.

-    const comments = currentStore.comment.getCommentsByIssueId(issueId) || [];
+    const comments = currentStore?.comment?.getCommentsByIssueId(issueId) || [];
web/core/store/issue/root.store.ts (2)

70-70: Document the new epicDetail property.

Consider adding a brief code comment to explain how epicDetail is expected to be used or how it interacts with other issue-related properties. This clarification helps maintain consistency for future contributors.


138-138: Ensure parallel definitions between issueDetail and epicDetail.

Both properties are logically similar, so it might be useful to maintain a uniform approach to naming, documentation, and usage patterns for clarity. Optionally, confirm that any watchers, reactions, or additional initializations required for epicDetail are mirrored from issueDetail.

web/core/components/issues/issue-layouts/kanban/kanban-group.tsx (1)

288-288: Overlay styling for epics.

You're passing isEpic to <GroupDragOverlay />. Consider customizing the overlay style or adding a distinct visual marker to differentiate epic items if that’s part of the product requirements.

web/core/components/issues/issue-layouts/quick-add/form/list.tsx (2)

22-22: Validation message alignment.

The required field message matches the placeholder logic. Keep the user’s mental model consistent by ensuring any longer disclaimers or tooltips also reflect the correct type.


28-28: Improve user guidance for adding multiple epics or issues.

The dynamic text is helpful. If this pattern is repeated elsewhere (e.g., Kanban Quick Add), ensure consistency across all quick-add flows.

web/core/components/issues/create-issue-toast-action-items.tsx (2)

30-30: Consider extracting the URL pattern to avoid duplication

The URL pattern is duplicated between the issueLink variable and the href attribute below. Consider extracting it into a utility function or constant to maintain DRY principles.

+const getItemUrl = (workspaceSlug: string, projectId: string, issueId: string, isEpic: boolean) =>
+  `${workspaceSlug}/projects/${projectId}/${isEpic ? "epics" : "issues"}/${issueId}`;

-const issueLink = `${workspaceSlug}/projects/${projectId}/${isEpic ? "epics" : "issues"}/${issueId}`;
+const issueLink = getItemUrl(workspaceSlug, projectId, issueId, isEpic);

52-52: Simplify the template literal

The template literal can be simplified as it's only concatenating static strings.

-{`View ${isEpic ? "epic" : "issue"}`}
+{`View ${isEpic ? "epic" : "issue"}`}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 36b3328 and 43d703d.

📒 Files selected for processing (18)
  • web/ce/components/issues/quick-add/root.tsx (2 hunks)
  • web/ce/store/issue/issue-details/activity.store.ts (2 hunks)
  • web/core/components/issues/create-issue-toast-action-items.tsx (3 hunks)
  • web/core/components/issues/issue-layouts/calendar/quick-add-issue-actions.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/kanban/default.tsx (1 hunks)
  • web/core/components/issues/issue-layouts/kanban/kanban-group.tsx (3 hunks)
  • web/core/components/issues/issue-layouts/list/default.tsx (1 hunks)
  • web/core/components/issues/issue-layouts/quick-add/form/calendar.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/quick-add/form/gantt.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/quick-add/form/kanban.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/quick-add/form/list.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/quick-add/form/spreadsheet.tsx (2 hunks)
  • web/core/components/issues/issue-layouts/quick-add/root.tsx (6 hunks)
  • web/core/components/issues/issue-layouts/utils.tsx (2 hunks)
  • web/core/hooks/store/use-issue-detail.ts (1 hunks)
  • web/core/store/issue/issue.store.ts (4 hunks)
  • web/core/store/issue/root.store.ts (3 hunks)
  • web/core/store/root.store.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • web/core/store/root.store.ts
🔇 Additional comments (40)
web/core/hooks/store/use-issue-detail.ts (1)

12-12: Consider graceful fallback for epicDetail.
While the logic is straightforward, if epicDetail is ever undefined, returning it could cause runtime issues. As a precaution, consider providing a fallback or verifying that this property is set.

web/core/components/issues/issue-layouts/quick-add/form/kanban.tsx (2)

6-6: New prop isEpic is well introduced.
The introduction of isEpic helps differentiate epic vs. standard issue creation.


23-23: User guidance text improved.
Using conditional text to instruct the user is a clear UX enhancement. Good job!

web/core/components/issues/issue-layouts/quick-add/form/spreadsheet.tsx (4)

6-6: isEpic property introduction is consistent.
This maintains parity with the other quick-add forms.


19-19: Dynamic placeholder logic.
Nicely done. This keeps the form user-friendly for both issues and epics.


21-21: Required message is now context-aware.
This is a good detail to guide users accurately.


27-27: Instruction text clarifies epic vs. issue creation.
Enhances user understanding of the form’s functionality.

web/core/components/issues/issue-layouts/quick-add/form/calendar.tsx (4)

6-6: Addition of isEpic to props.
This is consistent with other quick-add forms.


10-12: Conditional animation logic for isOpen.
Looks good. No concurrency or performance concerns noted.


23-23: Dynamic placeholder text.
Great for distinguishing epics from standard issues at a glance.


25-25: Context-aware required message.
This ensures the user is prompted correctly for epics vs. issues.

web/core/components/issues/issue-layouts/quick-add/form/gantt.tsx (1)

7-7: Great usage of destructuring for new prop.
The isEpic prop is properly extracted here, ensuring that the conditionals in subsequent lines work seamlessly.

web/ce/components/issues/quick-add/root.tsx (2)

33-33: New boolean prop complements the existing type definitions.
Declaring isEpic here is straightforward and consistent. Ensure no references require the prop to be optional when it’s defined as required.


74-74: Prop forwarding ensures layout-specific handling.
Passing isEpic to the layout form fosters a clean separation of concerns. This fosters easy expansions if new flags are introduced in the future (e.g., isBug, isFeature).

web/core/store/issue/issue.store.ts (3)

6-6: Ensuring type safety for TIssue usage.
Although this line is annotated, it appears standard. No issues are apparent here.


33-33: Constructor simplification.
Removing the serviceType indicates a shift toward a default service usage. Verify if any legacy code references serviceType or if you need polymorphism in the future.


88-90: Selective update of persistent layer.
By excluding epics from updatePersistentLayer, you preserve them from further persistence changes. Double-check that this is the intended logic and won’t result in inconsistent data for epics.

web/core/components/issues/issue-layouts/calendar/quick-add-issue-actions.tsx (3)

27-27: Optional isEpic prop broadens usage scenarios.
Having this prop allows smoother transitions between epic-related and standard issue flows.


122-122: User-friendly button label.
Changing the label to "New Epic" assists user understanding. Great for immediate clarity on which entity is being created.


131-131: isEpic forwarded correctly.
Propagating isEpic through the quick-add flow helps maintain consistent logic.

web/ce/store/issue/issue-details/activity.store.ts (2)

96-97: Ensure store properties are defined before use
It appears that this.serviceType correctly selects epicDetail or issueDetail, but please confirm that both this.store.issue.epicDetail and this.store.issue.issueDetail are always defined to avoid potential undefined errors.


113-113: Validate comment retrieval logic
You already check if comment is falsy after retrieval. This logic is solid for handling a nonexistent comment scenario; no further action needed.

web/core/components/issues/issue-layouts/quick-add/root.tsx (5)

9-9: Imported new constants
Importing updated constants EIssueLayoutTypes and EIssueServiceType is consistent with the rest of the PR. This looks good.


33-37: “isEpic” property additions
The addition of isEpic fields across form types (TQuickAddIssueForm, TQuickAddIssueButton, TQuickAddIssueRoot) effectively distinguishes epic creation from regular issues. Implementation aligns well with the rest of the codebase.

Also applies to: 50-50


67-67: Default value for “isEpic”
Defaulting the prop to false is a safe choice to avoid breaking existing logic when the property is not provided.


116-119: Conditional messaging for epic creation
The logic for conditionally displaying “epic” or “issue” during creation and success messages is clear and user-friendly.

Also applies to: 125-125


173-173: Dynamic UI elements for epics
Your conditional rendering of epics vs. issues (button labels, text) provides a smooth user experience. No issues found.

Also applies to: 177-177, 185-185

web/core/components/issues/issue-layouts/list/default.tsx (1)

87-87: Indicating “isEpic” for grouped issues
Passing the isEpic prop into getGroupByColumns ensures correct grouping logic for epics. This approach is consistent with other layout components.

web/core/components/issues/issue-layouts/kanban/default.tsx (1)

101-101: Kanban grouping for epics
Passing isEpic into the Kanban columns aligns with your epic/issue distinction. This is a good, minimal change that maintains consistency.

web/core/store/issue/root.store.ts (1)

226-229: Confirm the instantiation sequence and the default service type.

  1. this.issues = new IssueStore(); omits the service type, relying on the IssueStore default. Ensure that the default aligns with the intended usage.
  2. Using separate service types for issueDetail (ISSUES) and epicDetail (EPICS) is a solid approach to keep them scoped. Confirm all references in the rest of the codebase.
web/core/components/issues/issue-layouts/kanban/kanban-group.tsx (2)

85-85: Set default isEpic to false.

Providing a default of false is a practical choice, preventing undefined checks. Ensure that all calling components properly handle isEpic when they want to differentiate epic vs. non-epic items.


316-316: Enable or disable the quick-add form for epics.

This line effectively extends epic creation to the quick-add form. If there are differences in validation or permissible fields for epics vs. issues, ensure those are enforced here or in downstream logic.

web/core/components/issues/issue-layouts/utils.tsx (3)

71-71: Type extension for isEpic property.

Introducing an optional isEpic is consistent with the rest of the PR’s enhancements. Confirm that all references to TGetGroupByColumns properly handle the new property if omitted.


81-81: Default parameter usage for isEpic.

Providing isEpic = false achieves well-defined behavior. Confirm that no existing code paths rely on this property being undefined.


88-88: Conditionally naming "All Epics" vs. "All Issues".

The conditional naming is straightforward and effective. Ensure that the rest of the UI, including pagination and search, also correctly references "Epics" if isEpic is set.

web/core/components/issues/issue-layouts/quick-add/form/list.tsx (2)

6-6: Name alignment with epic vs. issue.

isEpic is being passed as part of the props. This is consistent with the rest of the PR. Make sure at the call site that isEpic is set accurately.


20-20: Contextual placeholder text.

Using "Epic Title" vs. "Issue Title" enhances clarity. This subtle UI distinction is beneficial for users. Good approach.

web/core/components/issues/create-issue-toast-action-items.tsx (3)

13-13: LGTM: Type definition is well-structured

The optional isEpic boolean property is correctly added to the type definition.


17-17: LGTM: Props destructuring with sensible defaults

The isEpic prop is correctly destructured with a default value of false, ensuring backward compatibility.


47-47: Use the suggested URL utility here as well

If you implement the URL utility function suggested above, you can also use it here:

-href={`/${workspaceSlug}/projects/${projectId}/${isEpic ? "epics" : "issues"}/${issueId}/`}
+href={`/${getItemUrl(workspaceSlug, projectId, issueId, isEpic)}/`}

@pushya22 pushya22 merged commit 756a71c into preview Dec 26, 2024
20 of 22 checks passed
@pushya22 pushya22 deleted the fix-project-epics-fixes-and-improvement branch December 26, 2024 14:31
@coderabbitai coderabbitai bot mentioned this pull request Dec 27, 2024
2 tasks
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.

3 participants