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

fix: moved dropdowns to chart component + added pending icon #5824

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

gakshita
Copy link
Collaborator

@gakshita gakshita commented Oct 14, 2024

Summary

  • Added icon for pending state
  • Moved chart dropdown to chart component
  • Copy fixes

Summary by CodeRabbit

  • New Features

    • Introduced a new PendingState icon component for improved user feedback.
    • Enhanced the SidebarChart component with new estimate handling features and a user-friendly selection interface.
    • Updated button visibility logic in the CycleListItemAction component for better responsiveness based on user context.
  • Bug Fixes

    • Streamlined estimate management logic in the issue-progress component for improved performance.
    • Corrected grammatical inconsistencies in messaging related to archiving cycles across multiple components.
  • Refactor

    • Reorganized and redefined estimate options for clarity and efficiency.
    • Updated text labels for improved clarity in user messaging.

Copy link
Contributor

coderabbitai bot commented Oct 14, 2024

Walkthrough

The changes in this pull request include the introduction of a new PendingState React component for rendering a pending state icon and modifications to the SidebarChart component to enhance estimate type handling. Additionally, the issue-progress.tsx file has undergone significant simplifications in its estimate management logic, while the CycleListItemAction component's button visibility logic has been updated based on new conditions. Minor text corrections were also made in various components for grammatical accuracy.

Changes

File Path Change Summary
packages/ui/src/icons/index.ts Added export for pending-icon.
packages/ui/src/icons/pending-icon.tsx Introduced PendingState component with props for rendering an SVG icon.
web/ce/components/cycles/analytics-sidebar/base.tsx Enhanced SidebarChart with new hooks and handlers for estimate type management.
web/core/components/cycles/analytics-sidebar/issue-progress.tsx Removed and redefined cycleEstimateOptions, eliminated onChange handler, simplified logic.
web/core/components/cycles/list/cycle-list-item-action.tsx Modified button visibility logic based on isMobile, isActive, and searchParams.
web/app/[workspaceSlug]/(projects)/active-cycles/header.tsx Changed label text from "Active Cycles" to "Active cycles".
web/core/components/cycles/analytics-sidebar/sidebar-header.tsx Updated text for archiving cycles from singular to plural for clarity.
web/core/components/cycles/quick-actions.tsx Corrected text in the description for archiving cycles from singular to plural.

Suggested labels

✨feature, 🌐frontend, 🐛bug

Suggested reviewers

  • SatishGandham
  • sriramveeraghanta

Poem

🐇 In the garden where changes bloom,
New icons sprout, dispelling gloom.
Estimates dance with a brand new flair,
While buttons hide with a clever stare.
Hooray for the code, let’s give a cheer,
For every new feature that brings us near! 🌼


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: 3

🧹 Outside diff range and nitpick comments (5)
packages/ui/src/icons/pending-icon.tsx (1)

15-16: Use camelCase for JSX attributes.

In React, HTML attributes should be written in camelCase. Please update the following attributes:

-      fill-rule="evenodd"
-      clip-rule="evenodd"
+      fillRule="evenodd"
+      clipRule="evenodd"

Apply this change to both path elements (lines 15-16 and 21-22).

Also applies to: 21-22

packages/ui/src/icons/index.ts (1)

34-34: LGTM! Consider maintaining alphabetical order.

The addition of the pending icon export is correct and aligns with the PR objectives. This change makes the new pending icon component available for use throughout the application, which is great.

As a minor suggestion, consider maintaining the alphabetical order of exports in this file. You could move the new export statement to maintain consistency with the existing structure, placing it between "photo-filter-icon" and "planned-icon".

Here's a suggested placement for the new export:

export * from "./photo-filter-icon";
+ export * from "./pending-icon";
export * from "./planned-icon";

This small reorganization would enhance the file's readability and make it easier to locate specific icons in the future.

web/core/components/cycles/list/cycle-list-item-action.tsx (1)

214-214: Approve changes with a minor suggestion for readability.

The modification to the button's visibility logic aligns well with the PR objective of moving dropdowns to the chart component. The implementation correctly hides the "More details" button when the cycle is active and the peekCycle parameter is present in the URL.

To improve readability, consider extracting the visibility condition into a separate variable:

const isButtonVisible = isMobile || (isActive && !searchParams.has("peekCycle"));

// Then use it in the className
className={`z-[1] flex text-custom-primary-200 text-xs gap-1 flex-shrink-0 ${
  isButtonVisible ? "flex" : "hidden group-hover:flex"
}`}

This change would make the logic easier to understand at a glance and potentially easier to maintain in the future.

web/ce/components/cycles/analytics-sidebar/base.tsx (1)

39-39: Consider renaming the variable for clarity

The variable name isCurrentEstimateTypeIsPoints is a bit verbose and can be simplified for better readability. Consider renaming it to isEstimateTypePoints.

Apply this diff to fix:

- const isCurrentEstimateTypeIsPoints = estimateDetails && estimateDetails?.type === EEstimateSystem.POINTS;
+ const isEstimateTypePoints = estimateDetails && estimateDetails?.type === EEstimateSystem.POINTS;

Remember to update all occurrences of this variable in the file.

web/core/components/cycles/analytics-sidebar/issue-progress.tsx (1)

28-32: Define the options type before its usage

The options type is used in cycleEstimateOptions before it is defined later in the code. Defining the type before its usage can enhance readability and make the code easier to understand.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 701af73 and c141450.

📒 Files selected for processing (5)
  • packages/ui/src/icons/index.ts (1 hunks)
  • packages/ui/src/icons/pending-icon.tsx (1 hunks)
  • web/ce/components/cycles/analytics-sidebar/base.tsx (3 hunks)
  • web/core/components/cycles/analytics-sidebar/issue-progress.tsx (4 hunks)
  • web/core/components/cycles/list/cycle-list-item-action.tsx (1 hunks)
🧰 Additional context used
🪛 Biome
web/ce/components/cycles/analytics-sidebar/base.tsx

[error] 36-36: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

🔇 Additional comments (1)
packages/ui/src/icons/pending-icon.tsx (1)

1-5: LGTM: Imports and component declaration are well-structured.

The import statements and component declaration are correctly implemented. The use of the ISvgIcons interface for props promotes type safety, and providing default values for width and height is a good practice.

Comment on lines 6 to 25
<svg
width={width}
height={height}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12Z"
fill="#455068"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 5C12.5523 5 13 5.44772 13 6V11.382L16.4472 13.1056C16.9412 13.3526 17.1414 13.9532 16.8944 14.4472C16.6474 14.9412 16.0468 15.1414 15.5528 14.8944L11.5528 12.8944C11.214 12.725 11 12.3788 11 12V6C11 5.44772 11.4477 5 12 5Z"
fill="#455068"
/>
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

Consider making the icon color customizable.

The SVG implementation looks good and should correctly render a pending state icon. However, the fill color is currently hardcoded as "#455068". To improve the icon's reusability across different color schemes, consider using the color prop to set the fill color dynamically.

Here's a suggested modification:

-      fill="#455068"
+      fill={color || "#455068"}

Apply this change to both path elements (lines 18 and 24).

📝 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
<svg
width={width}
height={height}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12Z"
fill="#455068"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 5C12.5523 5 13 5.44772 13 6V11.382L16.4472 13.1056C16.9412 13.3526 17.1414 13.9532 16.8944 14.4472C16.6474 14.9412 16.0468 15.1414 15.5528 14.8944L11.5528 12.8944C11.214 12.725 11 12.3788 11 12V6C11 5.44772 11.4477 5 12 5Z"
fill="#455068"
/>
<svg
width={width}
height={height}
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12Z"
fill={color || "#455068"}
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 5C12.5523 5 13 5.44772 13 6V11.382L16.4472 13.1056C16.9412 13.3526 17.1414 13.9532 16.8944 14.4472C16.6474 14.9412 16.0468 15.1414 15.5528 14.8944L11.5528 12.8944C11.214 12.725 11 12.3788 11 12V6C11 5.44772 11.4477 5 12 5Z"
fill={color || "#455068"}
/>

@@ -29,41 +33,82 @@ export const SidebarChart: FC<ProgressChartProps> = observer((props) => {
const totalEstimatePoints = cycleDetails?.total_estimate_points || 0;
const totalIssues = cycleDetails?.total_issues || 0;
const estimateType = getEstimateTypeByCycleId(cycleId);

const isCurrentProjectEstimateEnabled = projectId && areEstimateEnabledByProjectId(projectId) ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Simplify unnecessary boolean ternary operator

The ternary operator in line 36 is unnecessary because the expression already evaluates to a boolean value. You can simplify the code by removing the ternary operator.

Apply this diff to fix:

- const isCurrentProjectEstimateEnabled = projectId && areEstimateEnabledByProjectId(projectId) ? true : false;
+ const isCurrentProjectEstimateEnabled = Boolean(projectId && areEstimateEnabledByProjectId(projectId));
📝 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
const isCurrentProjectEstimateEnabled = projectId && areEstimateEnabledByProjectId(projectId) ? true : false;
const isCurrentProjectEstimateEnabled = Boolean(projectId && areEstimateEnabledByProjectId(projectId));
🧰 Tools
🪛 Biome

[error] 36-36: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

Comment on lines 28 to 32
export const cycleEstimateOptions: options[] = [
{ value: "issues", label: "issues" },
{ value: "points", label: "points" },
];

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

Consider renaming options type to Options for consistency

The type options is currently in lowercase. In TypeScript, it's conventional to use PascalCase for type and interface names. Renaming options to Options will improve code readability and maintain consistency throughout the codebase.

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 (3)
web/core/components/cycles/quick-actions.tsx (1)

118-118: Approved: Grammar correction improves clarity.

The change from "cycle" to "cycles" correctly fixes the grammatical error in the description. This improvement enhances the clarity and professionalism of the user interface.

Consider capitalizing the first letter of the description for consistency with other UI text:

-      description: isCompleted ? undefined : "Only completed cycles can\nbe archived.",
+      description: isCompleted ? undefined : "Only completed cycles can\nbe archived.",
web/core/components/cycles/analytics-sidebar/issue-progress.tsx (2)

63-63: LGTM: Good addition of cycle-related functions.

The inclusion of getPlotTypeByCycleId and getEstimateTypeByCycleId from the useCycle hook is a good change. It centralizes the logic for retrieving cycle-specific data, which aligns with the removal of the estimate type selector.

Consider adding a comment explaining the purpose of these newly added functions for better code readability.


Line range hint 160-173: LGTM: Simplified rendering of chart components.

The changes to the JSX structure, particularly the simplified rendering of SidebarChartRoot and CycleProgressStats, align well with the removal of the estimate type selector and progress percentage display. The addition of plotType as a prop to CycleProgressStats is consistent with earlier changes.

Consider adding a comment explaining the significance of chartDistributionData and why the CycleProgressStats component is conditionally rendered based on its presence.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c141450 and 82a1313.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (4)
  • web/app/[workspaceSlug]/(projects)/active-cycles/header.tsx (1 hunks)
  • web/core/components/cycles/analytics-sidebar/issue-progress.tsx (4 hunks)
  • web/core/components/cycles/analytics-sidebar/sidebar-header.tsx (1 hunks)
  • web/core/components/cycles/quick-actions.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • web/app/[workspaceSlug]/(projects)/active-cycles/header.tsx
  • web/core/components/cycles/analytics-sidebar/sidebar-header.tsx
🧰 Additional context used
🔇 Additional comments (2)
web/core/components/cycles/analytics-sidebar/issue-progress.tsx (2)

10-10: LGTM: Import and type definition changes look good.

The addition of TCyclePlotType and TProgressSnapshot imports, along with the redefinition of cycleEstimateOptions, align well with the changes in the component logic. These modifications improve type safety and simplify the options structure.

Also applies to: 28-31


Line range hint 48-51: Consider renaming options type to Options for consistency

As previously suggested, it's recommended to rename the options type to Options using PascalCase. This change would improve code readability and maintain consistency with TypeScript naming conventions for types and interfaces.


import { ISvgIcons } from "./type";

export const PendingState: React.FC<ISvgIcons> = ({ width = "10", height = "11", className, color }) => (
Copy link
Collaborator

Choose a reason for hiding this comment

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

Set #455068 as the default color instead of hardcoding, so that we can override if required.

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 (2)
web/core/components/cycles/analytics-sidebar/issue-progress.tsx (2)

Line range hint 159-173: LGTM! Component simplification aligns with PR objectives.

The modifications to the CycleAnalyticsProgress component successfully simplify its logic by moving the estimate type selection to the chart component. This change improves the separation of concerns and aligns with the PR objectives.

Consider adding a brief comment above the SidebarChartRoot component to explain its purpose or any important props it receives. This would enhance code readability for future maintainers.

+ // Render the main cycle analytics chart
 <SidebarChartRoot workspaceSlug={workspaceSlug} projectId={projectId} cycleId={cycleId} />

Line range hint 1-179: Overall, excellent refactoring that improves component structure and separation of concerns.

The changes in this file successfully achieve the PR objectives by:

  1. Moving dropdown functionality to the chart component.
  2. Simplifying the CycleAnalyticsProgress component.
  3. Improving type definitions and constant exports.

These modifications enhance the maintainability and readability of the code. The separation of concerns is now clearer, with the SidebarChartRoot component handling more of the chart-specific logic.

As the codebase evolves, consider creating a separate file for shared types and constants related to cycle analytics. This would further improve modularity and reusability across different components dealing with cycle data.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 82a1313 and e10c831.

📒 Files selected for processing (3)
  • packages/ui/src/icons/pending-icon.tsx (1 hunks)
  • web/ce/components/cycles/analytics-sidebar/base.tsx (3 hunks)
  • web/core/components/cycles/analytics-sidebar/issue-progress.tsx (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/ui/src/icons/pending-icon.tsx
  • web/ce/components/cycles/analytics-sidebar/base.tsx
🧰 Additional context used
🔇 Additional comments (2)
web/core/components/cycles/analytics-sidebar/issue-progress.tsx (2)

27-39: LGTM! New type and constants are well-defined.

The new Options type and the exported constants cycleEstimateOptions and cycleChartOptions are well-defined and follow TypeScript conventions. The naming is consistent and clear.

Note: This change addresses the previous suggestion to rename options to Options for consistency.


10-10: LGTM! Import and hook usage updates are appropriate.

The changes to the import statement and the useCycle hook usage are consistent with the modifications in the component. The removal of unused functions from the hook destructuring improves code cleanliness.

Also applies to: 62-62

@SatishGandham SatishGandham merged commit 4b450f8 into preview Oct 14, 2024
14 of 15 checks passed
@SatishGandham SatishGandham deleted the fix-cycle-progress-dropdown branch October 14, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants