Skip to content

Commit

Permalink
chore: cycle sidebar refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
anmolsinghbhatia committed Oct 7, 2024
1 parent 19dab1f commit 55fd8ae
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 6 deletions.
11 changes: 8 additions & 3 deletions web/core/components/cycles/analytics-sidebar/issue-progress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import { EIssueFilterType, EIssuesStoreType } from "@/constants/issue";
import { getDate } from "@/helpers/date-time.helper";
// hooks
import { useIssues, useCycle, useProjectEstimates } from "@/hooks/store";
// plane web constants
import { SidebarBaseChart } from "@/plane-web/components/cycles/analytics-sidebar";
import { EEstimateSystem } from "@/plane-web/constants/estimates";
import SidebarChart from "./sidebar-chart";

type TCycleAnalyticsProgress = {
workspaceSlug: string;
Expand Down Expand Up @@ -218,9 +217,15 @@ export const CycleAnalyticsProgress: FC<TCycleAnalyticsProgress> = observer((pro
</CustomSelect.Option>
))}
</CustomSelect>
<div className="flex items-center justify-center gap-2">
<div className="flex items-center gap-1 text-xs">
<span className="text-custom-text-300">Done</span>
<span className="font-semibold text-custom-text-400">{progressHeaderPercentage}%</span>
</div>
</div>
</div>
<div className="py-4">
<SidebarBaseChart
<SidebarChart
chartDistributionData={chartDistributionData}
cycleStartDate={cycleStartDate}
cycleEndDate={cycleEndDate}
Expand Down
58 changes: 58 additions & 0 deletions web/core/components/cycles/analytics-sidebar/sidebar-chart.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Fragment } from "react";
import { TCycleDistribution, TCycleEstimateDistribution } from "@plane/types";
import { Loader } from "@plane/ui";
import ProgressChart from "@/components/core/sidebar/progress-chart";

type ProgressChartProps = {
chartDistributionData: TCycleEstimateDistribution | TCycleDistribution | undefined;
cycleStartDate: Date | undefined;
cycleEndDate: Date | undefined;
totalEstimatePoints: number;
totalIssues: number;
plotType: string;
};
const SidebarChart = (props: ProgressChartProps) => {
const { chartDistributionData, cycleStartDate, cycleEndDate, totalEstimatePoints, totalIssues, plotType } = props;
const completionChartDistributionData = chartDistributionData?.completion_chart || undefined;

return (
<div>
<div className="relative flex items-center gap-2">
<div className="flex items-center justify-center gap-1 text-xs">
<span className="h-2.5 w-2.5 rounded-full bg-[#A9BBD0]" />
<span>Ideal</span>
</div>
<div className="flex items-center justify-center gap-1 text-xs">
<span className="h-2.5 w-2.5 rounded-full bg-[#4C8FFF]" />
<span>Current</span>
</div>
</div>
{cycleStartDate && cycleEndDate && completionChartDistributionData ? (
<Fragment>
{plotType === "points" ? (
<ProgressChart
distribution={completionChartDistributionData}
startDate={cycleStartDate}
endDate={cycleEndDate}
totalIssues={totalEstimatePoints}
plotTitle={"points"}
/>
) : (
<ProgressChart
distribution={completionChartDistributionData}
startDate={cycleStartDate}
endDate={cycleEndDate}
totalIssues={totalIssues}
plotTitle={"issues"}
/>
)}
</Fragment>
) : (
<Loader className="w-full h-[160px] mt-4">
<Loader.Item width="100%" height="100%" />
</Loader>
)}
</div>
);
};
export default SidebarChart;
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import React, { FC } from "react";
import isEmpty from "lodash/isEmpty";
import { observer } from "mobx-react";
import { LayersIcon, SquareUser, Users } from "lucide-react";
// ui
// types
import { ICycle } from "@plane/types";
// ui
import { Avatar, AvatarGroup, TextArea } from "@plane/ui";
// types
// hooks
import { useMember, useProjectEstimates } from "@/hooks/store";
// plane web
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export const CycleSidebarHeader: FC<Props> = observer((props) => {
end_date: renderFormattedPayloadDate(endDate),
};

if (cycleDetails?.start_date && cycleDetails.end_date)
if (cycleDetails && cycleDetails.start_date && cycleDetails.end_date)
isDateValid = await dateChecker({
...payload,
cycle_id: cycleDetails.id,
Expand Down

0 comments on commit 55fd8ae

Please sign in to comment.