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

chore: issue detail refactor #6768

Closed
wants to merge 4 commits into from

Conversation

vamsikrishnamathala
Copy link
Collaborator

@vamsikrishnamathala vamsikrishnamathala commented Mar 18, 2025

Description

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

Screenshots and Media (if applicable)

Test Scenarios

References

Summary by CodeRabbit

  • New Features

    • Introduced additional work item widgets in the issue details view for enhanced information display.
    • Implemented an improved sorting mechanism for work items.
    • Added a new method to generate unique keys for SWR cache.
  • Refactor

    • Streamlined the sidebar component by removing an unnecessary view property.
  • Documentation

    • Expanded available exports from the constants module for easier access.

Copy link
Contributor

coderabbitai bot commented Mar 18, 2025

Walkthrough

This pull request introduces a new TypeScript component along with its associated type for rendering additional widgets related to work items in the issue detail area. The new component is exported through the module’s index to facilitate easier imports and is integrated with the existing collapsible widget component. Additionally, a new sorting function is added to the issue store helpers, and a redundant prop has been removed from the sidebar component.

Changes

File(s) Change Summary
web/ce/components/issues/issue-detail-widgets/additional-widgets.tsx, web/ce/components/issues/issue-detail-widgets/index.ts, web/core/components/issues/issue-detail-widgets/issue-detail-widget-collapsibles.tsx Introduces a new type (TWorkItemAdditionalWidgets) and functional component (WorkItemAdditionalWidgets); re-exports the module; integrates the new widget in the collapsible component.
web/ce/store/issue/helpers/base-issue-store.ts Adds a new function workItemSortWithOrderByExtended to sort work items using getIssueIds.
web/core/components/issues/issue-detail/sidebar.tsx Removes the isPeekView prop from the WorkItemAdditionalSidebarProperties component.
packages/constants/src/index.ts, packages/constants/src/swr-keys.ts, packages/utils/src/common.ts Adds new exports and a new enum (SWR_KEYS); introduces a new function getSwrKey for generating unique SWR cache keys.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Collapsibles as IssueDetailWidgetCollapsibles
    participant Widgets as WorkItemAdditionalWidgets
    User->>Collapsibles: Load issue details
    Collapsibles->>Widgets: Render Additional Widgets<br/>(workspaceSlug, projectId, workItemId, disabled)
    Widgets-->>Collapsibles: Return rendered widget
Loading
sequenceDiagram
    participant Caller as Client Code
    participant IssueStore as BaseIssueStore
    participant IssuesUtil as BaseIssueUtils (getIssueIds)
    Caller->>IssueStore: Call workItemSortWithOrderByExtended(array, key)
    IssueStore->>IssuesUtil: Invoke getIssueIds(array)
    IssuesUtil-->>IssueStore: Return sorted IDs
    IssueStore-->>Caller: Return sorted work items
Loading

Possibly related PRs

Suggested labels

🌟improvement, 🌐frontend

Suggested reviewers

  • prateekshourya29
  • sriramveeraghanta

Poem

I'm just a rabbit hopping through the code,
Discovering changes on every new road.
A widget here, a sort function there,
And props removed with meticulous care.
I celebrate these tweaks with a cheerful hop—
Happy coding, may your fixes never stop! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @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: 0

🧹 Nitpick comments (2)
web/ce/store/issue/helpers/base-issue-store.ts (1)

4-4: Remove unused parameter or implement its functionality

The function workItemSortWithOrderByExtended has an unused key parameter that doesn't affect the function's behavior. Either remove this parameter or implement its intended functionality.

- export const workItemSortWithOrderByExtended = (array: TIssue[], key?: string) => getIssueIds(array);
+ export const workItemSortWithOrderByExtended = (array: TIssue[]) => getIssueIds(array);

Additionally, since this function is a simple wrapper around getIssueIds, consider either adding more functionality or documenting why this abstraction is necessary.

web/ce/components/issues/issue-detail-widgets/additional-widgets.tsx (1)

10-10: Add documentation to explain component purpose

The component currently renders an empty fragment, which is fine for initial refactoring. Consider adding JSDoc comments to document the component's purpose and any plans for future implementation.

+ /**
+  * A component for rendering additional widgets related to work items in the issue detail area.
+  * Currently a placeholder for future implementation.
+  */
export const WorkItemAdditionalWidgets: FC<TWorkItemAdditionalWidgets> = (props) => <></>;
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f22642 and e2648f4.

📒 Files selected for processing (5)
  • web/ce/components/issues/issue-detail-widgets/additional-widgets.tsx (1 hunks)
  • web/ce/components/issues/issue-detail-widgets/index.ts (1 hunks)
  • web/ce/store/issue/helpers/base-issue-store.ts (1 hunks)
  • web/core/components/issues/issue-detail-widgets/issue-detail-widget-collapsibles.tsx (2 hunks)
  • web/core/components/issues/issue-detail/sidebar.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • web/core/components/issues/issue-detail/sidebar.tsx
🧰 Additional context used
🧬 Code Definitions (1)
web/core/components/issues/issue-detail-widgets/issue-detail-widget-collapsibles.tsx (1)
web/ce/components/issues/issue-detail-widgets/additional-widgets.tsx (1) (1)
  • WorkItemAdditionalWidgets (10:10)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (4)
web/ce/components/issues/issue-detail-widgets/index.ts (1)

1-1: Good use of barrel file pattern

Using a barrel file pattern to re-export the components from additional-widgets module promotes cleaner imports throughout the application. This approach aligns with common React/TypeScript project organization best practices.

web/core/components/issues/issue-detail-widgets/issue-detail-widget-collapsibles.tsx (2)

14-14: LGTM - Import added correctly

The import for the new WorkItemAdditionalWidgets component is correctly added.


72-78: LGTM - Component integration looks good

The WorkItemAdditionalWidgets component is properly integrated at the end of the other collapsible widgets. The naming pattern change from issueId to workItemId suggests a possible shift in terminology or abstraction, which is consistent with good refactoring practices.

web/ce/components/issues/issue-detail-widgets/additional-widgets.tsx (1)

3-8: Type definition looks good

The type definition follows TypeScript best practices with clear property names and types.

@vamsikrishnamathala vamsikrishnamathala marked this pull request as draft March 24, 2025 06:54
@vamsikrishnamathala vamsikrishnamathala marked this pull request as ready for review March 24, 2025 10:40
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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e2648f4 and a622697.

📒 Files selected for processing (3)
  • packages/constants/src/index.ts (1 hunks)
  • packages/constants/src/swr-keys.ts (1 hunks)
  • packages/utils/src/common.ts (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/constants/src/swr-keys.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (2)
packages/constants/src/index.ts (1)

32-32: Good addition - follows consistent pattern!

The new export for "swr-keys" follows the same pattern as the existing exports in this file, maintaining consistency in the codebase.

packages/utils/src/common.ts (1)

3-3: Good addition of import for SWR keys.

The import statement for SWR_KEYS is correctly placed at the top of the file along with other imports.

Comment on lines 43 to 54
/**
* Generates a unique key for SWR cache
* @param workspaceSlug - The slug of the workspace
* @param label - The label for the cache key
* @param params - The parameters for the cache key
* @returns The unique key in array format
*/
export const getSwrKey = (workspaceSlug: string, label: SWR_KEYS, params: string[] = []) => [
label,
workspaceSlug,
...params,
];
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Well-documented utility function, but consider enum values.

The getSwrKey function is well-documented with JSDoc comments and has a clear purpose. However, according to the summary, the SWR_KEYS enum is currently empty. This could lead to inconsistent key usage if developers create their own string literals instead of using predefined enum values.


🏁 Script executed:

#!/bin/bash
# Check if the SWR_KEYS enum has any values defined

echo "Checking content of SWR_KEYS enum:"
fd -e ts -e tsx "swr-keys.ts" --exec cat {} \;

Length of output: 152


Please update the SWR_KEYS enum values.

The getSwrKey utility function is well-documented and clear. However, the verification confirms that the SWR_KEYS enum remains empty (in swr-keys.ts), which risks inconsistent cache key usage if developers start using arbitrary string literals. I suggest either:

  • Defining preset values: Populate the enum with the intended cache keys to ensure consistency.
  • Documenting intentional emptiness: If the enum is intentionally left empty for future expansion, add a clear comment explaining this decision.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a622697 and 85e639f.

📒 Files selected for processing (2)
  • packages/constants/src/swr-keys.ts (1 hunks)
  • packages/utils/src/common.ts (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
packages/utils/src/common.ts (1)
packages/constants/src/swr-keys.ts (1)
  • TSWRKey (7-7)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (python)
🔇 Additional comments (1)
packages/constants/src/swr-keys.ts (1)

1-7: Empty enum limits type safety benefits

The structure established here (enum + const object + type alias) is a good TypeScript pattern for extensible constants with type safety. However, the SWR_KEYS_CORE enum is currently empty, which means:

  1. The getSwrKey function in common.ts cannot be effectively used yet
  2. Developers might resort to using arbitrary string literals for cache keys
  3. You're missing the opportunity to standardize cache key naming

This issue was previously flagged in an earlier review. Please either:

  • Populate the enum with the intended cache keys to ensure consistency
  • If intentionally left empty for future expansion, add a comment explaining this decision

Comment on lines +42 to +54

/**
* Generates a unique key for SWR cache
* @param workspaceSlug - The slug of the workspace
* @param label - The label for the cache key
* @param params - The parameters for the cache key
* @returns The unique key in array format
*/
export const getSwrKey = (workspaceSlug: string, label: TSWRKey, params: string[] = []) => [
label,
workspaceSlug,
...params,
];
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

Well-documented utility function for consistent SWR key generation

The getSwrKey function is well-designed with comprehensive JSDoc comments that clearly explain its purpose and parameters. The function provides a structured approach to generating SWR cache keys, which will help maintain consistency throughout the application.

However, the function depends on the TSWRKey type which is currently based on an empty SWR_KEYS_CORE enum (as seen in the second file). This significantly limits the function's utility in its current state.

While the structure is good, you should populate the SWR_KEYS_CORE enum with actual values to make this function immediately useful. This would also prevent developers from using inconsistent string literals for cache keys.

@vamsikrishnamathala
Copy link
Collaborator Author

Discarding swr keys changes for now.

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.

1 participant