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: progress chart changes #5707

Merged
merged 4 commits into from
Oct 1, 2024
Merged

Chore: progress chart changes #5707

merged 4 commits into from
Oct 1, 2024

Conversation

gakshita
Copy link
Collaborator

@gakshita gakshita commented Sep 26, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced CycleSidebarHeader and CycleSidebarDetails components for enhanced sidebar functionality in cycle management.
    • Added a new button for opening cycle overviews, improving navigation and user interaction.
  • Improvements

    • Enhanced conditional rendering in cycle list actions for better user experience.
  • Bug Fixes

    • Resolved issues with redundant exports in the analytics sidebar module.
  • Documentation

    • Updated documentation for newly added components and features.

Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

Walkthrough

The pull request introduces new exports for sidebar components in the cycle management system, specifically adding sidebar-header and sidebar-details modules. It also includes the creation of two new React components, CycleSidebarHeader and CycleSidebarDetails, which enhance the functionality of the sidebar by displaying detailed cycle information and managing user interactions. Additionally, modifications are made to existing components to improve interactivity and layout.

Changes

Files Change Summary
web/core/components/cycles/analytics-sidebar/index.ts Added exports for new modules: sidebar-header and sidebar-details. Redundant export for root module included.
web/core/components/cycles/analytics-sidebar/sidebar-details.tsx Introduced CycleSidebarDetails component, which displays detailed cycle information and manages state with MobX.
web/core/components/cycles/analytics-sidebar/sidebar-header.tsx Introduced CycleSidebarHeader component, which manages cycle interactions and user permissions, including modals for archiving and deleting cycles.
web/core/components/cycles/list/cycle-list-item-action.tsx Added a new button for opening a cycle overview and updated rendering logic based on isActive prop, enhancing interactivity.

Possibly related PRs

Suggested labels

🧹chore, 🌟improvement, ⚙️backend

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

🐰 In the garden where cycles spin,
New headers and details, let the fun begin!
With each hop and click, we manage with glee,
A sidebar so bright, as bright as can be!
Let's track our progress, in style we shall play,
A cycle of joy, in every way! 🌼✨


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

🧹 Outside diff range and nitpick comments (24)
web/ce/components/cycles/analytics-sidebar/index.ts (1)

1-1: LGTM! Good step towards code splitting and modularity.

This change aligns well with the PR objective of "progress chart code splitting". It improves code organization by separating the sidebar chart functionality into its own module, which can enhance maintainability and potentially allow for lazy loading of components.

A few points to consider:

  1. Using wildcard exports (*) can sometimes lead to naming conflicts. Ensure that the exported entities from "sidebar-chart" don't clash with other imports where this module is used.
  2. For better clarity, consider explicitly listing the main exports in a comment above this line. This can serve as quick documentation for developers using this module.
web/ce/components/cycles/index.ts (1)

1-2: LGTM! Consider adding explanatory comments.

The creation of this index file is a good step towards better code organization and potential code splitting. It aligns well with the PR objective and follows common JavaScript/TypeScript practices.

Consider adding a brief comment at the top of the file to explain its purpose, which could help other developers understand the intent behind this file more quickly. For example:

// Central export point for cycle-related components.
// This file facilitates easier imports and potential code splitting.

export * from "./active-cycle";
export * from "./analytics-sidebar";

This addition would enhance the file's self-documentation without changing its functionality.

packages/ui/src/icons/in-progress-icon.tsx (2)

5-5: Component definition looks good, but there's an unused prop.

The component definition follows React best practices and uses TypeScript for type safety. However, the color prop is destructured but not used in the component.

Consider removing the unused color prop or utilizing it in the SVG if it's intended for future use:

-export const InProgressState: React.FC<ISvgIcons> = ({ width = "10", height = "11", className, color }) => (
+export const InProgressState: React.FC<ISvgIcons> = ({ width = "10", height = "11", className }) => (

6-17: SVG structure is good, but consider improving color customization.

The SVG structure effectively creates an "in progress" icon using two circles with different stroke styles. The className prop is correctly applied, allowing for external styling.

To improve the component's reusability, consider making the stroke color customizable:

  1. Use the color prop (currently unused) to set the stroke color.
  2. Provide a default color if none is specified.

Here's how you could modify the SVG:

 <svg
   width={width}
   height={height}
   viewBox="0 0 12 13"
   fill="none"
   xmlns="http://www.w3.org/2000/svg"
   className={className}
 >
-  <circle cx="6" cy="6.5" r="4.4" stroke="#EA8900" stroke-width="1.2" />
-  <circle cx="6" cy="6.5" r="2.4" stroke="#EA8900" stroke-width="1.2" stroke-dasharray="4 4" />
+  <circle cx="6" cy="6.5" r="4.4" stroke={color || "#EA8900"} stroke-width="1.2" />
+  <circle cx="6" cy="6.5" r="2.4" stroke={color || "#EA8900"} stroke-width="1.2" stroke-dasharray="4 4" />
 </svg>

This change would allow users of the component to customize the color while maintaining the default orange color if no color is specified.

packages/ui/src/icons/done-icon.tsx (1)

14-20: Use camelCase for SVG attributes to align with React conventions.

The SVG structure is correct, but the attribute names use kebab-case instead of camelCase, which is the convention in React for DOM properties.

Consider updating the SVG attributes to use camelCase:

- <circle cx="5" cy="5.5" r="4.4" stroke="#15A34A" stroke-width="1.2" />
+ <circle cx="5" cy="5.5" r="4.4" stroke="#15A34A" strokeWidth="1.2" />
  <path
-   fill-rule="evenodd"
-   clip-rule="evenodd"
+   fillRule="evenodd"
+   clipRule="evenodd"
    d="M2.5 5.59375L3.82582 6.91957L4.26777 6.47763L2.94194 5.15181L2.5 5.59375ZM4.26777 7.36152L7.36136 4.26793L6.91942 3.82599L3.82583 6.91958L4.26777 7.36152Z"
    fill="#15A34A"
  />

This change improves consistency with React conventions and prevents warnings in strict mode.

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

31-33: LGTM! Consider grouping related icons.

The new exports for planned, in-progress, and done icons are consistent with the existing pattern and support the progress chart functionality mentioned in the PR title. These additions will likely enhance the visualization of task progress in the UI.

Consider grouping related icons together in the file for better organization. For example, you could move these new exports next to other task-related icons if they exist, or add a comment to separate different categories of icons.

 export * from "./favorite-folder-icon";
+// Task progress icons
 export * from "./planned-icon";
 export * from "./in-progress-icon";
 export * from "./done-icon";

This grouping can improve code readability and make it easier to manage icons as the list grows.

web/ce/components/cycles/analytics-sidebar/sidebar-chart.tsx (3)

6-13: LGTM: Well-defined prop types with a minor suggestion.

The ProgressChartProps type is well-defined and uses appropriate TypeScript features. Good job on using union types for chartDistributionData and optional types for date properties.

Consider using more specific types for totalEstimatePoints, totalIssues, and plotType. For example:

totalEstimatePoints: number;
totalIssues: number;
plotType: 'points' | 'issues';

This would provide better type safety and autocompletion for the plotType prop.


14-57: LGTM: Well-structured component with minor improvement suggestions.

The SidebarBaseChart component is well-implemented, following React best practices. Good job on using optional chaining and conditional rendering based on data availability.

Consider the following improvements:

  1. Extract the legend rendering into a separate component for better modularity:
const ChartLegend = () => (
  <div className="relative flex items-center gap-2">
    {/* ... legend items ... */}
  </div>
);
  1. Use early return for the loading state to reduce nesting:
if (!cycleStartDate || !cycleEndDate || !completionChartDistributionData) {
  return (
    <Loader className="w-full h-[160px] mt-4">
      <Loader.Item width="100%" height="100%" />
    </Loader>
  );
}

// Rest of the component...
  1. Consider using a ternary operator instead of an if-else for rendering the ProgressChart based on plotType:
<ProgressChart
  distribution={completionChartDistributionData}
  startDate={cycleStartDate}
  endDate={cycleEndDate}
  totalIssues={plotType === "points" ? totalEstimatePoints : totalIssues}
  plotTitle={plotType}
/>

These changes would improve readability and reduce code duplication.


1-57: Consider performance optimizations and error handling.

The component is well-structured, but there are opportunities for improvement in terms of performance and error handling:

  1. Memoization: Consider using useMemo for expensive computations or React.memo for the component if it's expected to re-render frequently with the same props.

  2. Error Handling: Implement error boundaries or add proper error handling for potential issues with data fetching or processing.

  3. Accessibility: Ensure the chart is accessible by adding appropriate ARIA attributes and keyboard navigation support.

Here's an example of how you could implement these suggestions:

import React, { useMemo } from 'react';
import { ErrorBoundary } from 'react-error-boundary';

const SidebarBaseChart = React.memo((props: ProgressChartProps) => {
  const { chartDistributionData, cycleStartDate, cycleEndDate, totalEstimatePoints, totalIssues, plotType } = props;

  const completionChartDistributionData = useMemo(() => 
    chartDistributionData?.completion_chart, 
    [chartDistributionData]
  );

  // ... rest of the component logic

  return (
    <ErrorBoundary fallback={<ErrorFallback />}>
      {/* ... component JSX ... */}
    </ErrorBoundary>
  );
});

const ErrorFallback = () => (
  <div role="alert">
    <p>Something went wrong:</p>
    <pre>Error loading chart data</pre>
  </div>
);

This implementation adds memoization to prevent unnecessary re-renders and includes an error boundary for graceful error handling.

packages/ui/src/icons/planned-icon.tsx (2)

5-13: LGTM: Component declaration is well-structured. Consider using object destructuring for default values.

The component declaration follows React best practices and uses TypeScript for improved type safety. However, you could simplify the props destructuring by using object default values.

Consider refactoring the component declaration as follows:

export const PlannedState: React.FC<ISvgIcons> = ({
  width = "10",
  height = "11",
  className,
  color
}) => (
  <svg
    width={width}
    height={height}
    viewBox="0 0 12 13"
    fill="none"
    xmlns="http://www.w3.org/2000/svg"
    className={className}
  >
    {/* ... */}
  </svg>
);

This approach is more idiomatic in React and makes the default values more visible.


14-39: LGTM: SVG structure is well-formed. Consider allowing color customization.

The SVG structure is correct and uses appropriate techniques like clipping paths for complex shapes. The consistent use of fill color across paths is good for maintainability.

Consider allowing color customization through props. You can modify the path elements to use the color prop:

<path
  // ...other attributes
  fill={color || "#455068"}
/>

This change would make the icon more flexible for different color schemes while maintaining the default color.

packages/ui/src/progress/circular-progress-indicator.tsx (3)

12-12: LGTM! Consider adding JSDoc for the new prop.

The addition of the strokeColor prop with a default value is a good way to allow customization while maintaining backward compatibility.

Consider adding a JSDoc comment for the strokeColor prop in the ICircularProgressIndicator interface to describe its purpose and expected values. For example:

interface ICircularProgressIndicator {
  // ... other props ...
  /**
   * Custom stroke color for the progress indicator.
   * @default "stroke-custom-primary-100"
   */
  strokeColor?: string;
}

Line range hint 30-56: Remove commented-out code and update related styles.

The large commented-out <defs> section should be removed entirely rather than left as comments. This will improve code readability and maintainability.

Please make the following changes:

  1. Remove the commented-out <defs> section (lines 30-56).
  2. Update or remove the style prop on line 27 that references the now-removed filter:
    - style={{ filter: "url(#filter0_bi_377_19141)" }}
    + // Remove this line if the filter is no longer needed

If the filter functionality is still required, consider moving it to a separate SVG definitions file or implementing it using CSS filters instead.


58-58: LGTM! Consider adding a safeguard for direct color values.

The change correctly applies the custom stroke color. However, it assumes that strokeColor is always a CSS class name.

To make the component more flexible, consider allowing both CSS class names and direct color values (e.g., "#FF0000" or "rgb(255, 0, 0)"). You can achieve this by updating the className and adding a style prop:

className={`fill-none ${strokeColor.startsWith('stroke-') ? strokeColor : ''}`}
style={{ stroke: strokeColor.startsWith('stroke-') ? undefined : strokeColor }}

This change would allow users to pass either a CSS class name (prefixed with "stroke-") or a direct color value, making the component more versatile.

web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx (1)

73-80: Summary of changes and potential impact.

The changes in this file involve:

  1. Reducing the sidebar width and padding, making it more compact.
  2. Simplifying the CycleDetailsSidebar component by removing the cycleId prop.

These modifications appear to be part of a UI optimization and component simplification effort. While they seem reasonable, please ensure that:

  1. The new sidebar dimensions work well across different screen sizes and don't negatively impact the user experience.
  2. The CycleDetailsSidebar component still functions correctly without the cycleId prop.

Consider adding or updating tests to cover these changes and prevent potential regressions.

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

344-351: LGTM: Addition of "States" Tab.Panel with minor suggestion

The addition of the "States" Tab.Panel with the StateStatComponent is well-implemented and consistent with the changes in the progressStats array. This modification allows for the display of state-based statistics in the progress chart.

For consistency with the other Tab.Panel components, consider adding the filters prop to the StateStatComponent:

 <StateStatComponent
   distribution={distributionStateData}
   totalIssuesCount={totalIssuesCount}
   isEditable={isEditable}
+  filters={filters}
   handleFiltersUpdate={handleFiltersUpdate}
 />

This change would make the StateStatComponent props more consistent with the AssigneeStatComponent and LabelStatComponent.

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

142-145: LGTM! Consider minor readability improvement.

The addition of fetchActiveCycleProgressPro enhances the functionality by fetching active cycle progress alongside cycle details. This aligns well with the PR objective of progress chart code splitting.

For improved readability, consider extracting the condition check into a separate variable:

+ const shouldFetchProgress = projectId && cycleId;
- projectId &&
-   cycleId &&
-   this.rootIssueStore.rootStore.cycle.fetchActiveCycleProgressPro(workspaceSlug, projectId, cycleId);
+ if (shouldFetchProgress) {
+   this.rootIssueStore.rootStore.cycle.fetchActiveCycleProgressPro(workspaceSlug, projectId, cycleId);
+ }

This change would make the code more readable and consistent with the style used for fetchCycleDetails.

web/helpers/date-time.helper.ts (2)

368-377: LGTM! Consider using date-fns for consistency.

The getToday function is well-implemented and correctly handles both Date object and formatted string outputs. However, for consistency with the rest of the file, consider using date-fns functions like startOfDay and format.

Here's a suggested refactor using date-fns:

import { startOfDay, format } from 'date-fns';

export const getToday = (shouldFormat: boolean = false): Date | string => {
  const today = startOfDay(new Date());
  return shouldFormat ? format(today, 'yyyy-MM-dd') : today;
};

This refactor maintains the same functionality while leveraging the date-fns library for consistency with other functions in the file.


Line range hint 1-432: Overall improvement suggestion for date-time helper module

The new functions (getToday, dateFormatter, daysLeft, and generateDateArray) add valuable functionality to the date-time helper module. However, there's an opportunity to improve consistency across the entire file:

  1. Consistently use date-fns functions throughout the module. This will provide better timezone handling, reduce the risk of errors, and make the code more maintainable.
  2. Standardize error handling and input validation across all functions.
  3. Ensure all functions have clear, accurate JSDoc comments with examples.
  4. Consider grouping related functions (e.g., all formatting functions together) for better organization.

To implement these improvements:

  1. Review all existing functions and refactor them to use date-fns where appropriate.
  2. Create a common error handling utility for date-related errors.
  3. Update all JSDoc comments to follow a consistent format with accurate examples.
  4. Reorganize the file structure to group related functions together.

These changes will enhance the overall quality, consistency, and maintainability of the date-time helper module.

web/ce/components/cycles/active-cycle/root.tsx (1)

37-88: Remove Redundant Fragment Wrapping the Disclosure Component

The fragment wrapping the <Disclosure> component at lines 37 and 88 is unnecessary since <Disclosure> is a single root element in the return statement. Removing the fragment can simplify the code.

Apply this diff to remove the redundant fragment:

-   return (
-     <>
-       <Disclosure as="div" className="flex flex-shrink-0 flex-col" defaultOpen>
-         {({ open }) => (
-           <>
-             ...
-           </>
-         )}
-       </Disclosure>
-     </>
-   );
+   return (
+     <Disclosure as="div" className="flex flex-shrink-0 flex-col" defaultOpen>
+       {({ open }) => (
+         <>
+           ...
+         </>
+       )}
+     </Disclosure>
+   );
web/helpers/cycle.helper.ts (1)

8-20: Consider defining a separate interface for the progress chart data items

To enhance readability and reusability, consider defining an interface for the progress chart data items and then using it to define the array type. This can make the codebase more maintainable.

For example:

export interface IProgressChartDataItem {
  date: string;
  scope: number;
  completed: number;
  backlog: number;
  started: number;
  unstarted: number;
  cancelled: number;
  pending: number;
  ideal: number;
  actual: number;
}

export type TProgressChartData = IProgressChartDataItem[];
web/core/components/cycles/analytics-sidebar/sidebar-details.tsx (1)

121-123: Fix typo in comment

There's a typographical error in the comment. It should be "the projects" instead of "he projects".

Apply this diff to fix the typo:

 /**
- * NOTE: Render this section when estimate points of he projects is enabled and the estimate system is points
+ * NOTE: Render this section when estimate points of the projects is enabled and the estimate system is points
  */
web/core/components/cycles/analytics-sidebar/issue-progress.tsx (1)

Line range hint 95-101: Fix logical error in progressHeaderPercentage calculation

There is a logical error in the condition checking completedIssues and totalIssues. The condition currently compares completedIssues to itself, which is redundant and incorrect. It should check if totalIssues is not zero to prevent division by zero.

Apply this diff to correct the condition:

      : completedIssues != 0 && completedIssues != 0
+     : completedIssues != 0 && totalIssues != 0
web/core/components/cycles/analytics-sidebar/sidebar-header.tsx (1)

175-179: Improve the clarity of the error message

The error message can be rephrased for better readability and to avoid run-on sentences.

Consider updating the message:

- "You already have a cycle on the given dates, if you want to create a draft cycle, you can do that by removing both the dates."
+ "A cycle already exists for the selected dates. To create a draft cycle, please remove both the start and end dates."
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 150af98 and b9e774b.

📒 Files selected for processing (31)
  • packages/types/src/cycle/cycle.d.ts (5 hunks)
  • packages/ui/src/icons/done-icon.tsx (1 hunks)
  • packages/ui/src/icons/in-progress-icon.tsx (1 hunks)
  • packages/ui/src/icons/index.ts (1 hunks)
  • packages/ui/src/icons/planned-icon.tsx (1 hunks)
  • packages/ui/src/loader.tsx (1 hunks)
  • packages/ui/src/progress/circular-progress-indicator.tsx (3 hunks)
  • web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx (1 hunks)
  • web/ce/components/cycles/active-cycle/index.ts (1 hunks)
  • web/ce/components/cycles/active-cycle/root.tsx (1 hunks)
  • web/ce/components/cycles/analytics-sidebar/index.ts (1 hunks)
  • web/ce/components/cycles/analytics-sidebar/sidebar-chart.tsx (1 hunks)
  • web/ce/components/cycles/index.ts (1 hunks)
  • web/core/components/cycles/active-cycle/index.ts (0 hunks)
  • web/core/components/cycles/active-cycle/productivity.tsx (6 hunks)
  • web/core/components/cycles/active-cycle/use-cycles-details.ts (1 hunks)
  • web/core/components/cycles/analytics-sidebar/index.ts (1 hunks)
  • web/core/components/cycles/analytics-sidebar/issue-progress.tsx (11 hunks)
  • web/core/components/cycles/analytics-sidebar/progress-stats.tsx (2 hunks)
  • web/core/components/cycles/analytics-sidebar/root.tsx (2 hunks)
  • web/core/components/cycles/analytics-sidebar/sidebar-details.tsx (1 hunks)
  • web/core/components/cycles/analytics-sidebar/sidebar-header.tsx (1 hunks)
  • web/core/components/cycles/cycle-peek-overview.tsx (1 hunks)
  • web/core/components/cycles/list/cycle-list-item-action.tsx (5 hunks)
  • web/core/components/cycles/list/cycles-list-item.tsx (0 hunks)
  • web/core/components/cycles/list/root.tsx (2 hunks)
  • web/core/services/cycle.service.ts (1 hunks)
  • web/core/store/cycle.store.ts (12 hunks)
  • web/core/store/issue/cycle/issue.store.ts (1 hunks)
  • web/helpers/cycle.helper.ts (2 hunks)
  • web/helpers/date-time.helper.ts (1 hunks)
💤 Files not reviewed due to no reviewable changes (2)
  • web/core/components/cycles/active-cycle/index.ts
  • web/core/components/cycles/list/cycles-list-item.tsx
🧰 Additional context used
🪛 Biome
web/core/components/cycles/analytics-sidebar/issue-progress.tsx

[error] 182-182: 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)

web/core/components/cycles/analytics-sidebar/sidebar-details.tsx

[error] 42-44: 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)


[error] 45-47: 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)

web/core/components/cycles/analytics-sidebar/sidebar-header.tsx

[error] 159-159: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

🪛 GitHub Check: lint-web
web/core/components/cycles/analytics-sidebar/sidebar-details.tsx

[failure] 5-5:
lodash/isEmpty import should occur before import of mobx-react


[failure] 9-9:
@plane/types import should occur before import of @plane/ui

web/core/components/cycles/analytics-sidebar/sidebar-header.tsx

[failure] 6-6:
mobx-react import should occur before import of react-hook-form

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

[failure] 25-25:
@/helpers/router.helper import should occur before import of @/hooks/store


[failure] 26-26:
@/hooks/use-app-router import should occur before import of @/hooks/use-platform-os


[failure] 27-27:
next/navigation import should occur before import of react-hook-form

🔇 Additional comments (67)
web/ce/components/cycles/active-cycle/index.ts (2)

1-1: LGTM! This change facilitates better code organization and splitting.

This new index.ts file, which re-exports all entities from the root module, is a good practice for several reasons:

  1. It provides a clear entry point for the active-cycle module, making imports more consistent across the codebase.
  2. It facilitates easier code splitting and lazy loading of components, which can lead to improved performance.
  3. It enhances maintainability by centralizing exports, making it easier to manage as the number of exports grows.

This change aligns well with the PR objective of "progress chart code splitting".


1-1: Verify consistent usage of index files across the project.

To ensure this change is part of a broader, consistent approach to code organization:

  1. Check if similar index files exist in other directories.
  2. Verify that imports in other files are updated to use this new index file where applicable.

Run the following script to check for consistency:

This script will help identify if the new pattern is consistently applied and if there are any imports that might need updating.

web/core/components/cycles/analytics-sidebar/index.ts (1)

5-6: New exports align with code splitting objective.

The addition of exports for "sidebar-header" and "sidebar-details" modules aligns well with the PR objective of progress chart code splitting. This change enhances modularity and potentially improves maintainability.

packages/ui/src/icons/in-progress-icon.tsx (2)

1-3: LGTM: Imports are appropriate.

The imports are correct for a React component using TypeScript. Importing the ISvgIcons interface from a separate file is a good practice for maintaining type definitions.


1-17: Overall assessment: Well-implemented component with minor improvement opportunities.

The InProgressState component is well-structured and follows React and TypeScript best practices. It successfully creates a reusable "in progress" icon component. The use of SVG for the icon ensures scalability, and the component accepts customizable props for flexibility.

To further improve the component:

  1. Remove or utilize the unused color prop.
  2. Consider making the stroke color customizable for better reusability.

These minor adjustments will enhance the component's flexibility and adherence to best practices.

packages/ui/src/loader.tsx (3)

19-19: LGTM: Addition of className to ItemProps

The addition of the optional className property to the ItemProps interface enhances the flexibility of the Item component, allowing for custom styling. This change is consistent with the existing pattern in the Loader component and maintains backward compatibility.


22-23: LGTM: Implementation of className in Item component

The changes to the Item component correctly implement the new className prop. The use of the cn function ensures that the default class is always applied while allowing for additional custom classes. The default value of an empty string for className maintains backward compatibility. This implementation is consistent with how className is handled in the parent Loader component.


19-23: Summary: Improved flexibility of the Item component

These changes enhance the Item component by allowing custom CSS classes to be passed through the new className prop. This improvement aligns well with the PR objective of code splitting and increases the reusability of the component. The implementation is consistent with existing patterns in the codebase and maintains backward compatibility.

packages/ui/src/icons/done-icon.tsx (2)

1-3: LGTM: Imports are correct and necessary.

The import statements are appropriate for the component. React is imported for the JSX syntax, and the ISvgIcons interface is imported for type checking.


1-22: Overall assessment: Well-structured component with minor improvements needed.

The DoneState component is a good implementation of a "done" icon as an SVG in React. It's properly typed with the ISvgIcons interface and allows for customization of width, height, and className.

Summary of suggestions:

  1. Utilize the color prop to make the icon color dynamic.
  2. Use camelCase for SVG attributes to align with React conventions.

These changes will enhance the component's flexibility and maintainability.

web/core/components/cycles/cycle-peek-overview.tsx (2)

44-49: Styling adjustments for the sidebar

The changes to the sidebar's styling look good. Reducing the maximum width from 24rem to 21.5rem and adjusting the padding from px-6 to px-4 will result in a slightly more compact sidebar. This should improve the overall layout without significantly impacting the user experience.


Line range hint 1-54: Overall assessment: Changes look good with minor verification needed

The changes in this file are relatively minor and seem to improve both the layout and code simplicity. The styling adjustments for the sidebar should result in a more compact design, while the simplified prop passing for CycleDetailsSidebar reduces code complexity.

However, it's important to verify that the peekCycle value is always a string to ensure type safety with the new prop passing method. The verification script provided earlier will help confirm this.

If the verification passes, these changes can be approved. Great job on the code splitting and simplification!

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

1-4: LGTM: Imports are appropriate and concise.

The imports are well-organized and relevant to the component's functionality. Good job on using local imports for custom components like ProgressChart.

packages/ui/src/icons/planned-icon.tsx (1)

1-3: LGTM: Imports are correct and well-structured.

The necessary imports for React and the ISvgIcons interface are present and correctly implemented.

packages/ui/src/progress/circular-progress-indicator.tsx (1)

Line range hint 1-83: Overall, good improvements to component flexibility.

The changes to the CircularProgressIndicator component successfully introduce the ability to customize the stroke color, which enhances its reusability. The implementation is generally sound, with good use of default values to maintain backward compatibility.

Here's a summary of the suggested improvements:

  1. Add JSDoc comments for the new strokeColor prop.
  2. Remove the commented-out <defs> section and update related styles.
  3. Make the strokeColor prop more flexible by allowing both CSS class names and direct color values.

These changes will result in a cleaner, more robust, and more flexible component. Great work on improving the component's customizability!

web/core/components/cycles/list/root.tsx (3)

31-31: LGTM: Simplified prop passing for ActiveCycleRoot

The workspaceSlug and projectId props are now passed directly to ActiveCycleRoot without using toString(). This simplification is good, but we should ensure that the ActiveCycleRoot component can handle these prop types correctly.

To confirm that the ActiveCycleRoot component is prepared for this change, please run the following script:

#!/bin/bash
# Description: Verify the prop types of ActiveCycleRoot component

# Test: Check the prop types defined for ActiveCycleRoot
ast-grep --lang typescript --pattern $'interface $_Props {
  $$$
  workspaceSlug: $_
  projectId: $_
  $$$
}

export const ActiveCycleRoot: FC<$_Props> = ($_) => {
  $$$
}'

This script will help us verify the prop types defined for ActiveCycleRoot and ensure they match the new usage.


Line range hint 1-31: Summary: Minor changes as part of potential refactoring

The changes in this file are relatively minor but may be part of a larger refactoring effort:

  1. The import path for ActiveCycleRoot has been updated, suggesting a reorganization of the project structure.
  2. The prop passing for ActiveCycleRoot has been simplified, which might indicate changes in how prop types are handled.

While these changes don't affect the overall structure or logic of the CyclesList component, they could be part of broader changes across the project. It's important to ensure that these changes are consistent with other parts of the codebase and don't introduce any unintended side effects.

To get a better understanding of the scope of these changes, please run the following script:

#!/bin/bash
# Description: Check for similar changes across the project

# Test: Look for other files that might have been affected by similar changes
rg --type typescript --type tsx 'from\s+["\']@/plane-web/components/'

# Test: Check for other instances where toString() might have been removed from prop passing
rg --type typescript --type tsx '(?<!\.toString\(\))\s+(?:workspaceSlug|projectId)=\{[^}]+\}'

This will help us understand if these changes are isolated or part of a larger refactoring effort.


8-8: LGTM: Import path updated for ActiveCycleRoot

The import path for ActiveCycleRoot has been updated from "@/components/cycles" to "@/plane-web/components/cycles". This change likely reflects a project structure reorganization or a move towards more modular architecture.

To ensure consistency across the project, please run the following script to verify the usage of the new import path:

✅ Verification successful

To address the syntax error in the previous shell script, please use the corrected scripts below to verify the usage of the new import path for ActiveCycleRoot:


To resolve the issue with unrecognized file types, please use the updated scripts below to verify the usage of the new import path for ActiveCycleRoot:


To resolve the issues with unrecognized file types, please use the updated scripts below to verify the usage of the new import path for ActiveCycleRoot:


LGTM: Import path updated for ActiveCycleRoot

The import path for ActiveCycleRoot has been successfully updated from @/components/cycles to @/plane-web/components/cycles in web/core/components/cycles/list/root.tsx. No remaining imports from the old path were found in this file.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new import path for ActiveCycleRoot

# Test: Search for any remaining imports from the old path
rg --type typescript --type tsx 'from\s+["\']@/components/cycles["\']'

# Test: Confirm the usage of the new import path
rg --type typescript --type tsx 'from\s+["\']@/plane-web/components/cycles["\']'

Length of output: 230


Script:

#!/bin/bash
# Description: Verify the usage of the new import path for ActiveCycleRoot

# Test: Search for any remaining imports from the old path
rg --type typescript --type tsx "from\s+['\"]@/components/cycles['\"]"

# Test: Confirm the usage of the new import path
rg --type typescript --type tsx "from\s+['\"]@/plane-web/components/cycles['\"]"

Length of output: 233


Script:

#!/bin/bash
# Description: Verify the usage of the new import path for ActiveCycleRoot

# Test: Search for any remaining imports from the old path
rg --type ts --type tsx "from\s+['\"]@/components/cycles['\"]"

# Test: Confirm the usage of the new import path
rg --type ts --type tsx "from\s+['\"]@/plane-web/components/cycles['\"]"

Length of output: 203


Script:

#!/bin/bash
# Description: Verify the usage of the new import path for ActiveCycleRoot

# Test: Search for any remaining imports from the old path in .ts and .tsx files
rg -g '*.ts' -g '*.tsx' "from\s+['\"]@/components/cycles['\"]"

# Test: Confirm the usage of the new import path in .ts and .tsx files
rg -g '*.ts' -g '*.tsx' "from\s+['\"]@/plane-web/components/cycles['\"]"

Length of output: 3855

web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx (1)

73-73: LGTM! Verify UI appearance after sidebar size adjustment.

The sidebar width has been reduced from 24rem to 21.5rem, and the padding has been changed from px-6 to px-4. This change makes the sidebar more compact, which could improve space utilization.

Please verify that this change doesn't negatively impact the UI appearance or user experience, especially on different screen sizes.

packages/types/src/cycle/cycle.d.ts (3)

46-57: LGTM: Well-structured TCycleProgress type definition

The new TCycleProgress type is well-defined with clear and descriptive property names. It provides a comprehensive structure for tracking various aspects of cycle progress, which will be valuable for detailed cycle analysis and reporting.


132-132: LGTM: Clear TCycleEstimateType definition

The new TCycleEstimateType is well-defined and aligns with common agile estimation practices. It provides a clear way to distinguish between issue-based and point-based estimations in the cycle context.


133-133: LGTM: Enhanced TCyclePlotType with burnup option

The addition of "burnup" to TCyclePlotType is a valuable enhancement. This change allows for more comprehensive cycle progress visualization, supporting both burndown and burnup charts which are common in agile project management.

To ensure consistency, please verify if any documentation or related code needs to be updated to reflect this new option. You can use the following script to check for any occurrences of TCyclePlotType that might need updating:

web/core/components/cycles/active-cycle/use-cycles-details.ts (1)

13-13: LGTM! Verify impact on dependent code.

The change to allow cycleId to be undefined is backwards compatible and doesn't introduce immediate issues in this file. However, ensure that this change is reflected correctly in other parts of the codebase where IActiveCycleDetails or cycleId from this hook is used.

To verify the impact of this change, run the following script:

Also, consider updating any relevant documentation to reflect this change in the cycleId type.

web/core/components/cycles/active-cycle/productivity.tsx (8)

4-4: LGTM: Import statement updated correctly

The import statement has been updated to include TCycleEstimateType, which aligns with the component's new focus on estimate types instead of plot types.


22-22: LGTM: Chart options updated to reflect estimate types

The cycleBurnDownChartOptions array has been updated to use "issues" instead of "burndown", which is consistent with the component's new focus on estimate types.


29-29: LGTM: Hooks and derived values updated for estimate types

The component's hooks and derived values have been correctly updated to use estimate type functions (getEstimateTypeByCycleId and setEstimateType) instead of plot type functions. The default estimateType is appropriately set to "issues".

Also applies to: 33-33


35-37: LGTM: onChange function updated for estimate types

The onChange function has been correctly updated to handle estimate types instead of plot types. It now uses the setEstimateType function, which is consistent with the component's new focus.


46-46: LGTM: Chart distribution data logic updated

The chart distribution data logic has been correctly updated to use the estimate type. It now checks if the estimate type is "points" to determine which distribution data to use, which is consistent with the component's new focus on estimate types.


58-59: LGTM: CustomSelect component updated for estimate types

The CustomSelect component has been correctly updated to use estimateType instead of plotType. The value and label now reflect the new estimate type focus, which is consistent with the overall changes in the component.


Line range hint 88-93: LGTM: Rendering logic updated for estimate types

The rendering logic for pending points or issues has been correctly updated to use the new estimate type. It now conditionally renders either pending points or pending issues based on the estimateType, which is consistent with the component's new focus on estimate types.


Line range hint 1-134: Summary: Successful transition from plot types to estimate types

The changes in this file consistently implement a transition from plot types to estimate types in the ActiveCycleProductivity component. This refactoring includes updates to imports, variable names, function calls, and rendering logic. The changes are well-implemented and maintain the component's functionality while shifting its focus.

Key points:

  1. Import statements have been updated to include TCycleEstimateType.
  2. The cycleBurnDownChartOptions array now uses "issues" instead of "burndown".
  3. Hooks and derived values now use estimate type functions.
  4. The onChange function has been updated to handle estimate types.
  5. Chart distribution data logic now considers the estimate type.
  6. The CustomSelect component has been updated to use estimateType.
  7. Rendering logic for pending points or issues now uses the estimate type.

These changes align with the PR objective of "Chore: progress chart code splitting" and appear to be part of a larger refactoring effort. The implementation is consistent and maintains the component's functionality while improving its focus on estimate types.

🧰 Tools
🪛 Biome

[error] 40-40: 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)

web/core/components/cycles/analytics-sidebar/progress-stats.tsx (2)

222-225: LGTM: Addition of "States" entry to progressStats array

The addition of the "States" entry to the beginning of the progressStats array is consistent with the PR objective and aligns with the changes described in the AI-generated summary. This modification will allow for the display of state-based statistics in the progress chart.


Line range hint 1-368: Summary: Progress chart code splitting implementation looks good

The changes made to the progressStats array and the CycleProgressStats component successfully implement the progress chart code splitting as intended. The addition of the "States" entry and corresponding Tab.Panel allows for the display of state-based statistics in the progress chart.

The implementation is consistent and well-structured. A minor suggestion was made to improve consistency in prop passing, but overall, the changes are approved and ready for merging.

web/core/components/cycles/analytics-sidebar/root.tsx (2)

50-51: Ensure safe conversion of parameters when calling .toString()

As mentioned earlier, calling .toString() on potentially undefined workspaceSlug and projectId can lead to runtime errors. Use String() for safe conversion or ensure these parameters are defined.


61-62: Ensure safe conversion of parameters when calling .toString()

web/ce/components/cycles/active-cycle/root.tsx (1)

27-89: Component Implementation Looks Good

The ActiveCycleRoot component is well-structured, and the logic for displaying and managing the active cycle details is clear and effective. The use of hooks and state management appears appropriate, and props are correctly passed to child components.

web/helpers/cycle.helper.ts (1)

1-1: Imports are appropriate and necessary

The imported modules are used correctly within the code.

Also applies to: 5-5

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

6-6: Approve the addition of new icon imports

The import of Eye and Users icons from lucide-react is appropriate for the added functionality.


37-37: Approve addition of optional isActive prop

The inclusion of the optional isActive boolean prop enhances the component's conditional rendering capabilities.


46-46: Destructure isActive prop with a default value

Destructuring isActive from props with a default value of false is appropriate and ensures backward compatibility.


49-52: Approve addition of router hooks

Using useAppRouter, useSearchParams, and usePathname hooks effectively manages routing and query parameters.


195-205: Confirm correctness of openCycleOverview handler

The openCycleOverview function correctly toggles the cycle overview based on the peekCycle query parameter.


209-216: Conditional rendering of the "More details" button

The button is appropriately displayed based on the isMobile or isActive state, enhancing user accessibility.


254-254: Approve conditional rendering of ButtonAvatars

Rendering ButtonAvatars when createdByDetails exists and isActive is false is appropriate.


256-271: Approve conditional rendering of member avatars

The Tooltip and AvatarGroup components are correctly rendered based on the isActive state and the presence of assignee_ids.


276-277: Prevent default event behavior in favorite action

Adding e.preventDefault() and e.stopPropagation() ensures that clicking the favorite star does not trigger unintended navigation or parent event handlers.

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

181-181: ⚠️ Potential issue

Simplify conditional expression in defaultOpen prop

The ternary operator isCycleDateValid ? true : false is unnecessary since it directly evaluates to isCycleDateValid. You can simplify the code by assigning isCycleDateValid directly.

Apply this diff to simplify the expression:

-      <Disclosure defaultOpen={isCycleDateValid ? true : false}>
+      <Disclosure defaultOpen={isCycleDateValid}>

Likely invalid or redundant comment.

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

302-302: Confirm if 'minDate' should restrict selecting past dates

Setting minDate={new Date()} restricts users from selecting past dates. If cycles can have start dates in the past, consider adjusting or removing minDate.

web/core/store/cycle.store.ts (19)

14-15: Imports are correctly added

The types TCycleEstimateType and TCycleProgress are properly imported, which are essential for the new functionalities introduced.


18-18: Imported formatActiveCycle helper function

The formatActiveCycle function is correctly imported from cycle.helper, ensuring that any formatting related to active cycles can be utilized.


32-32: Added progressLoader property to interface

The progressLoader: boolean property is appropriately added to the ICycleStore interface to handle loading states for cycle progress operations.


37-37: Introduced estimatedType property to interface

The estimatedType: Record<string, TCycleEstimateType> property is properly added to manage estimate types for cycles.


51-51: Defined getActiveCycleProgress method in interface

The method getActiveCycleProgress is correctly declared in the ICycleStore interface, facilitating retrieval of active cycle progress details.


60-60: Added getEstimateTypeByCycleId method to interface

The getEstimateTypeByCycleId method is properly added, allowing retrieval of the estimate type for a specific cycle.


65-65: Included setEstimateType method in interface

The method setEstimateType is correctly included in the ICycleStore interface to update the estimate type of a cycle.


74-78: Declared fetchActiveCycleProgressPro method in interface

The fetchActiveCycleProgressPro method is added to the interface, preparing for enhanced progress fetching for pro users.


105-105: Initialized progressLoader property

The progressLoader is initialized to false, ensuring a default non-loading state.


108-108: Initialized estimatedType property

The estimatedType property is initialized as an empty object, ready to store estimate types keyed by cycle IDs.


124-124: Made progressLoader observable

The progressLoader property is correctly set as an observable reference, allowing reactive updates in the UI.


127-127: Made estimatedType observable

The estimatedType property is properly set as an observable, enabling reactivity when estimate types change.


142-142: Registered setEstimateType as an action

The setEstimateType method is correctly registered as an action, allowing state modifications within MobX's rules.


149-149: Registered fetchActiveCycleProgressPro as an action

The fetchActiveCycleProgressPro method is properly registered as an action to perform asynchronous operations.


280-292: Implemented getActiveCycleProgress method

The getActiveCycleProgress method is well implemented using computedFn, efficiently computing values based on the cycle ID.


409-410: Updated getPlotTypeByCycleId method

The method correctly returns the plot type for a given cycle ID, defaulting to "burndown" if not set.


411-421: Implemented getEstimateTypeByCycleId method

The getEstimateTypeByCycleId method accurately determines the estimate type based on project settings and cycle-specific configurations.


431-438: Implemented setEstimateType method

The setEstimateType method correctly updates the estimatedType map with the new estimate type for the given cycle ID.


530-539: Enhanced fetchActiveCycleProgress with loading state

The inclusion of progressLoader before and after the asynchronous call ensures proper loading state handling.

@@ -1,3 +1,6 @@
export * from "./root";
export * from "./issue-progress";
export * from "./progress-stats";
export * from "./root";
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 26, 2024

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove redundant export statement.

The export statement for the "root" module is duplicated. This redundancy should be removed to maintain clean and efficient code.

Apply this diff to remove the redundant export:

export * from "./root";
export * from "./issue-progress";
export * from "./progress-stats";
-export * from "./root";
export * from "./sidebar-header";
export * from "./sidebar-details";
📝 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
export * from "./root";
export * from "./root";
export * from "./issue-progress";
export * from "./progress-stats";
export * from "./sidebar-header";
export * from "./sidebar-details";

Copy link
Collaborator

Choose a reason for hiding this comment

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

cc: @gakshita

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Comment on lines +5 to +13
export const DoneState: React.FC<ISvgIcons> = ({ width = "10", height = "11", className, color }) => (
<svg
width={width}
height={height}
viewBox="0 0 10 11"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
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

Address unused 'color' prop and consider making SVG colors dynamic.

The component declaration looks good, but there's an issue with the 'color' prop:

  1. The 'color' prop is destructured but not used in the component. This could lead to confusion for users of the component.
  2. The SVG uses hardcoded colors, which limits its reusability.

Consider the following improvements:

  1. Remove the unused 'color' prop if it's not needed.
  2. If color customization is intended, use the 'color' prop to set the SVG colors dynamically.

Here's a suggested implementation:

- export const DoneState: React.FC<ISvgIcons> = ({ width = "10", height = "11", className, color }) => (
+ export const DoneState: React.FC<ISvgIcons> = ({ width = "10", height = "11", className, color = "#15A34A" }) => (
  <svg
    width={width}
    height={height}
    viewBox="0 0 10 11"
    fill="none"
    xmlns="http://www.w3.org/2000/svg"
    className={className}
  >
-   <circle cx="5" cy="5.5" r="4.4" stroke="#15A34A" stroke-width="1.2" />
+   <circle cx="5" cy="5.5" r="4.4" stroke={color} stroke-width="1.2" />
    <path
      fill-rule="evenodd"
      clip-rule="evenodd"
      d="M2.5 5.59375L3.82582 6.91957L4.26777 6.47763L2.94194 5.15181L2.5 5.59375ZM4.26777 7.36152L7.36136 4.26793L6.91942 3.82599L3.82583 6.91958L4.26777 7.36152Z"
-     fill="#15A34A"
+     fill={color}
    />
  </svg>
);

This change allows users to customize the icon color while maintaining a default value.

📝 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
export const DoneState: React.FC<ISvgIcons> = ({ width = "10", height = "11", className, color }) => (
<svg
width={width}
height={height}
viewBox="0 0 10 11"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
export const DoneState: React.FC<ISvgIcons> = ({ width = "10", height = "11", className, color = "#15A34A" }) => (
<svg
width={width}
height={height}
viewBox="0 0 10 11"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={className}
>
<circle cx="5" cy="5.5" r="4.4" stroke={color} stroke-width="1.2" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M2.5 5.59375L3.82582 6.91957L4.26777 6.47763L2.94194 5.15181L2.5 5.59375ZM4.26777 7.36152L7.36136 4.26793L6.91942 3.82599L3.82583 6.91958L4.26777 7.36152Z"
fill={color}
/>
</svg>
);

handleClose={handleClose}
isArchived={isArchived}
/>
<CycleDetailsSidebar handleClose={handleClose} isArchived={isArchived} cycleId={peekCycle} />
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Potential Type Issue with peekCycle in CycleDetailsSidebar

It appears that peekCycle can be null, but it's being passed directly to CycleDetailsSidebar as a prop without ensuring it's a string. This could introduce type-related issues.

  • Review the prop types for CycleDetailsSidebar to confirm that cycleId expects a string.
  • Ensure that peekCycle is always a string before passing it, possibly by adding type guards or default values.
🔗 Analysis chain

Simplified prop passing for CycleDetailsSidebar

The change in prop passing for cycleId looks good as it simplifies the code. However, we should verify that peekCycle is always a string to ensure this change doesn't introduce any type-related issues.

Let's verify the type of peekCycle and its usage:

This script will help us confirm that the change is safe and doesn't introduce any potential issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the type and usage of peekCycle

# Check the type of peekCycle
echo "Checking the type of peekCycle:"
ast-grep --lang typescript --pattern 'const peekCycle = searchParams.get("peekCycle")'

# Check if peekCycle is used with toString() elsewhere in the file
echo "Checking if peekCycle is used with toString() elsewhere:"
rg 'peekCycle.*toString\(\)' web/core/components/cycles/cycle-peek-overview.tsx

# Check if CycleDetailsSidebar expects a string for cycleId
echo "Checking CycleDetailsSidebar prop types:"
ast-grep --lang typescript --pattern 'type $Props = {
  $$$
  cycleId: $_
  $$$
}'

Length of output: 713


import { ISvgIcons } from "./type";

export const PlannedState: React.FC<ISvgIcons> = ({ width = "10", height = "11", className, color }) => (
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

Address unused color prop.

The color prop is destructured in the component parameters but not used in the SVG. This could lead to confusion for developers using this component.

Consider one of the following options:

  1. Remove the color prop if it's not needed.
  2. Implement color customization using the color prop as suggested in the previous comment.
  3. If the color prop is intended for future use, add a TODO comment explaining its purpose.

)}
style={{
boxShadow:
"0px 1px 4px 0px rgba(0, 0, 0, 0.06), 0px 2px 4px 0px rgba(16, 24, 40, 0.06), 0px 1px 8px -1px rgba(16, 24, 40, 0.06)",
}}
>
<CycleDetailsSidebar cycleId={cycleId.toString()} handleClose={toggleSidebar} />
<CycleDetailsSidebar handleClose={toggleSidebar} />
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 26, 2024

Choose a reason for hiding this comment

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

💡 Codebase verification

CycleDetailsSidebar still utilizes the cycleId prop.

The cycleId prop has been removed from the CycleDetailsSidebar component in web/app/[workspaceSlug]/(projects)/projects/(detail)/[projectId]/cycles/(detail)/[cycleId]/page.tsx. However, the search results indicate that cycleId is still being passed to CycleDetailsSidebar in other parts of the codebase, which may lead to inconsistencies or runtime errors.

  • Instances to review:
    • web/core/components/cycles/cycle-peek-overview.tsx
    • web/core/components/cycles/list/cycles-list-item-action.tsx
    • web/core/components/cycles/board/cycles-board-card.tsx

Please verify all usages of the CycleDetailsSidebar component to ensure that the removal of the cycleId prop does not negatively impact functionality.

🔗 Analysis chain

Verify CycleDetailsSidebar functionality after prop removal.

The cycleId prop has been removed from the CycleDetailsSidebar component. This simplification of the component's interface is good for maintainability.

Please ensure that the CycleDetailsSidebar component can still function correctly without the cycleId prop. Run the following script to check if cycleId is still being used within the CycleDetailsSidebar component:

If the script returns any results, it indicates that cycleId is still being used within the component, which may cause issues.


Please run the following script to verify if cycleId is still being used within the CycleDetailsSidebar component:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if cycleId is still being used within the CycleDetailsSidebar component.

# Test: Search for cycleId usage in CycleDetailsSidebar
ast-grep --lang typescript --pattern 'const CycleDetailsSidebar = ($_) => { $$$ cycleId $$$ }'

Length of output: 96


Script:

#!/bin/bash
# Description: Search for any occurrences of cycleId within the CycleDetailsSidebar component.

# Search for 'cycleId' usage in CycleDetailsSidebar
rg 'cycleId' $(fd 'CycleDetailsSidebar' --type f)

Length of output: 72381

Copy link
Collaborator

Choose a reason for hiding this comment

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

cc: @gakshita

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

import React, { FC, useEffect, useState } from "react";
import { Controller, useForm } from "react-hook-form";
import { ArchiveIcon, ArchiveRestoreIcon, ChevronRight, EllipsisIcon, LinkIcon, Trash2 } from "lucide-react";
import { observer } from "mobx-react";
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

Reorder imports to maintain proper sequencing

To adhere to the project's import organization standards, place the mobx-react import before the react-hook-form import.

Apply this diff to fix the import order:

 import React, { FC, useEffect, useState } from "react";
+import { observer } from "mobx-react";
 import { Controller, useForm } from "react-hook-form";
-import { observer } from "mobx-react";

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 GitHub Check: lint-web

[failure] 6-6:
mobx-react import should occur before import of react-hook-form

title: "Restore success",
message: "Your cycle can be found in project cycles.",
});
router.push(`/${workspaceSlug.toString()}/projects/${projectId.toString()}/archives/cycles`);
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

Redirect to the active cycles page after restoring

After restoring the cycle, the user is redirected to the archived cycles page. Since the cycle is now active, consider redirecting to the active cycles page to reflect the updated state and enhance user experience.

Adjust the router.push call to point to the active cycles:

- router.push(`/${workspaceSlug.toString()}/projects/${projectId.toString()}/archives/cycles`);
+ router.push(`/${workspaceSlug.toString()}/projects/${projectId.toString()}/cycles/${cycleDetails.id}`);

Committable suggestion was skipped due to low confidence.

});
}, [cycleDetails, reset]);

const dateChecker = async (payload: any) => {
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

Specify the type of 'payload' parameter instead of 'any'

Using any defeats the purpose of TypeScript's type safety. Define a specific type for the payload parameter in the dateChecker function to enhance code robustness.

Update the function signature with a defined interface:

+interface DateCheckerPayload {
+  start_date: string;
+  end_date: string;
+  cycle_id?: string;
+}

- const dateChecker = async (payload: any) => {
+ const dateChecker = async (payload: DateCheckerPayload) => {
📝 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 dateChecker = async (payload: any) => {
interface DateCheckerPayload {
start_date: string;
end_date: string;
cycle_id?: string;
}
const dateChecker = async (payload: DateCheckerPayload) => {

web/core/store/cycle.store.ts Show resolved Hide resolved
const { currentActiveEstimateId, areEstimateEnabledByProjectId, estimateById } = useProjectEstimates();

// derived values
const plotType: TCyclePlotType = (cycle && getPlotTypeByCycleId(cycle.id)) || "burndown";
const estimateType: TCycleEstimateType = (cycle && getEstimateTypeByCycleId(cycle.id)) || "issues";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will progressUnit be a better name?

Copy link
Collaborator Author

@gakshita gakshita Sep 30, 2024

Choose a reason for hiding this comment

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

Its a judgement call, to me estimateType looks better, not sure which one to go ahead with

Copy link
Collaborator

@SatishGandham SatishGandham left a comment

Choose a reason for hiding this comment

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

Please check the coderabbit suggestions and other comments

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

📥 Commits

Files that changed from the base of the PR and between b9e774b and 35ada40.

📒 Files selected for processing (4)
  • web/core/components/cycles/analytics-sidebar/index.ts (1 hunks)
  • web/core/components/cycles/analytics-sidebar/sidebar-details.tsx (1 hunks)
  • web/core/components/cycles/analytics-sidebar/sidebar-header.tsx (1 hunks)
  • web/core/components/cycles/list/cycle-list-item-action.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • web/core/components/cycles/analytics-sidebar/index.ts
  • web/core/components/cycles/analytics-sidebar/sidebar-header.tsx
  • web/core/components/cycles/list/cycle-list-item-action.tsx
🧰 Additional context used
🪛 Biome
web/core/components/cycles/analytics-sidebar/sidebar-details.tsx

[error] 42-44: 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)


[error] 45-47: 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 (5)
web/core/components/cycles/analytics-sidebar/sidebar-details.tsx (5)

1-18: LGTM: Imports and type definitions are well-organized.

The imports are properly structured, and the type definition for the component props is clear and concise. The previously mentioned import order issues have been resolved in this version.


20-28: LGTM: Component definition and hook usage are well-implemented.

The CycleSidebarDetails component is correctly defined as a functional component using MobX's observer. The hooks are used appropriately to fetch necessary data, and the initial calculations based on cycle status and estimates are logical and clear.


30-40: LGTM: Issue count and estimate point calculations are correct.

The logic for calculating issueCount and issueEstimatePointCount is complex but appears to handle all necessary cases correctly, including completed cycles and different progress snapshot scenarios.

Also applies to: 48-56


57-134: LGTM: Component rendering logic is well-implemented.

The rendering logic for the CycleSidebarDetails component is well-structured and uses appropriate UI components from @plane/ui. The conditional rendering for the description and estimate points is correctly implemented. The layout uses flexbox for responsive design, ensuring a good user experience across different screen sizes.


1-138: Overall implementation aligns well with PR objectives.

The CycleSidebarDetails component is well-implemented and aligns with the PR objective of implementing code splitting for the progress chart component. The component is modular, follows React best practices, and effectively encapsulates the logic for displaying cycle details, including user and issue information.

Key strengths of the implementation:

  1. Proper use of MobX for state management
  2. Effective use of hooks for data fetching
  3. Clear type definitions
  4. Responsive layout using flexbox
  5. Appropriate conditional rendering

The only suggested improvement is the simplification of the isEstimatePointValid calculation, as mentioned in a previous comment. Once that's addressed, the component will be in excellent shape.

🧰 Tools
🪛 Biome

[error] 42-44: 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)


[error] 45-47: 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 +41 to +47
const isEstimatePointValid = isEmpty(cycleDetails?.progress_snapshot || {})
? estimateType && estimateType?.type == EEstimateSystem.POINTS
? true
: false
: isEmpty(cycleDetails?.progress_snapshot?.estimate_distribution || {})
? false
: true;
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 the isEstimatePointValid calculation.

The current implementation uses nested ternary operators with boolean literals, which can be simplified for better readability and maintainability.

Consider refactoring the isEstimatePointValid calculation as follows:

const isEstimatePointValid = isEmpty(cycleDetails?.progress_snapshot || {})
  ? estimateType?.type === EEstimateSystem.POINTS
  : !isEmpty(cycleDetails?.progress_snapshot?.estimate_distribution || {});

This simplification removes the unnecessary boolean literals and makes the logic more straightforward.

🧰 Tools
🪛 Biome

[error] 42-44: 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)


[error] 45-47: 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)

@SatishGandham SatishGandham changed the title Chore: progress chart code splitting Chore: progress chart changes Oct 1, 2024
@pushya22 pushya22 merged commit 4940dc2 into preview Oct 1, 2024
14 of 15 checks passed
@pushya22 pushya22 deleted the chore-progress-chart branch October 1, 2024 13:29
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.

3 participants