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

Support partial goal progress in criteria #2895

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/components/GoalBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ComponentProps } from 'react';
import { nullable } from '@taskany/bricks';
import { Badge } from '@taskany/bricks/harmony';
import { Badge, CircleProgressBar } from '@taskany/bricks/harmony';

import { NextLink } from './NextLink';
import { StateDot } from './StateDot/StateDot';
Expand All @@ -12,16 +12,30 @@ interface GoalBadgeProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'co
strike?: boolean;
children?: React.ReactNode;
className?: string;
progress?: number | null;
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
}

export const GoalBadge: React.FC<GoalBadgeProps> = ({ href, title, children, className, onClick, state, ...attrs }) => {
export const GoalBadge: React.FC<GoalBadgeProps> = ({
href,
title,
children,
className,
onClick,
state,
progress,
...attrs
}) => {
return (
<Badge
className={className}
iconLeft={nullable(state, (s) => (
<StateDot view="stroke" state={s} size="l" />
))}
iconLeft={nullable(
progress,
(value) => (
<CircleProgressBar value={value} size="xs" />
),
nullable(state, (s) => <StateDot view="stroke" state={s} size="l" />),
)}
iconRight={children}
text={nullable(
href,
Expand Down
17 changes: 17 additions & 0 deletions src/components/GoalCriteria/GoalCriteria.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

.GoalCriteriaTable {
margin-top: var(--gap-sm);
margin-bottom: var(--gap-s);
}

.GoalCriteriaItemTitle {
Expand Down Expand Up @@ -87,4 +88,20 @@
.GoalCriteriaIsolate::after {
content: none;
display: none;
}

.GoalCriteriaProgress {
position: absolute;
bottom: -10px;
left: 0;
width: 100%;
z-index: 0;
}

.GoalCriteriaTitleCell {
position: relative;
}

.GoalCriteriaTable {
gap: var(--gap-sm);
}
8 changes: 6 additions & 2 deletions src/components/GoalCriteria/GoalCriteria.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ interface GoalCriteriaProps extends CriteriaProps {
state?: State | null;
project?: string;
owner?: ActivityByIdReturnType;
progress?: number | null;
};
}

Expand All @@ -83,6 +84,7 @@ export function mapCriteria<
projectId: string | null;
owner: ActivityByIdReturnType | null;
state: State | null;
completedCriteriaWeight?: number | null;
},
>(criteria: T, connectedGoal: G | null): UnionCriteria {
if (connectedGoal) {
Expand All @@ -94,6 +96,7 @@ export function mapCriteria<
shortId: connectedGoal._shortId,
project: connectedGoal.projectId ?? undefined,
owner: connectedGoal.owner ?? undefined,
progress: connectedGoal.completedCriteriaWeight ?? null,
},
title: connectedGoal.title,
isDone: criteria.isDone,
Expand Down Expand Up @@ -160,12 +163,13 @@ const GoalCriteria = ({ title, goal, weight, isDone }: Omit<GoalCriteriaProps, '

return (
<>
<TableCell width={200}>
<TableCell className={classes.GoalCriteriaTitleCell} width={200}>
<GoalBadge
title={title}
state={goal.state ?? undefined}
href={routes.goal(goal.shortId)}
onClick={handleGoalCriteriaClick}
progress={goal.progress}
strike={isDone}
/>
</TableCell>
Expand Down Expand Up @@ -417,7 +421,7 @@ export const CriteriaList: React.FC<CriteriaListProps> = ({
}) => {
const validityData = useCriteriaValidityData(list);
return (
<Table className={className}>
<Table className={classNames(classes.GoalCriteriaTable, className)}>
{list.map((criteria) => (
<Criteria
goalId={goalId}
Expand Down
2 changes: 1 addition & 1 deletion src/components/GoalTableList/GoalTableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export const GoalTableList = <T extends GoalTableListItem>({
content: goal.achievedCriteriaWeight != null && goal.id != null && (
<GoalCriteriaPreview achievedWeight={goal.achievedCriteriaWeight} goalId={goal.id} />
),
width: 24,
width: 32,
},
],
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/IssueStats/IssueStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const IssueStats: React.FC<IssueStatsProps> = ({
{achivedCriteriaWeight != null && (
<Separator>
<div className={s.IssueComponentContainer}>
<CircleProgressBar value={achivedCriteriaWeight} size="l" />
<CircleProgressBar value={achivedCriteriaWeight} size="m" />
</div>
</Separator>
)}
Expand Down
Loading
Loading