-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
912e11c
commit 7c62dd4
Showing
20 changed files
with
420 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { Link, nullable } from '@taskany/bricks'; | ||
|
||
import { Badge } from './Badge'; | ||
import { NextLink } from './NextLink'; | ||
import { StateDot } from './StateDot'; | ||
|
||
interface GoalBadgeProps { | ||
title: string; | ||
href?: string; | ||
state?: { | ||
title?: string; | ||
hue?: number; | ||
} | null; | ||
children?: React.ReactNode; | ||
className?: string; | ||
onClick?: () => void; | ||
} | ||
|
||
export const GoalBadge: React.FC<GoalBadgeProps> = ({ href, title, state, children, className, onClick }) => { | ||
return ( | ||
<Badge | ||
className={className} | ||
icon={<StateDot title={state?.title} hue={state?.hue} />} | ||
text={nullable( | ||
href, | ||
() => ( | ||
<Link as={NextLink} href={href} inline onClick={onClick}> | ||
{title} | ||
</Link> | ||
), | ||
title, | ||
)} | ||
action={children} | ||
/> | ||
); | ||
}; |
4 changes: 2 additions & 2 deletions
4
...dencyList/GoalDependencyList.i18n/en.json → ...oalDependency/GoalDependency.i18n/en.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"blocks": "This goal blocked by", | ||
"dependsOn": "This goal depends on", | ||
"relatesTo": "This goal relates to", | ||
"Delete": "" | ||
"relatedTo": "This goal relates to", | ||
"Kind": "" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"blocks": "Блокирует", | ||
"dependsOn": "Зависит от", | ||
"relatedTo": "Связана с", | ||
"Kind": "Вид зависимости" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import { FC, useCallback, useMemo, useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { AutoCompleteRadioGroup, CheckboxInput, nullable } from '@taskany/bricks'; | ||
import { Goal } from '@prisma/client'; | ||
|
||
import { trpc } from '../../utils/trpcClient'; | ||
import { ToggleGoalDependency, dependencyKind } from '../../schema/goal'; | ||
import { FilterBase } from '../FilterBase/FilterBase'; | ||
import { FilterAutoCompleteInput } from '../FilterAutoCompleteInput/FilterAutoCompleteInput'; | ||
import { CustomCell, GoalListItemCompact } from '../GoalListItemCompact'; | ||
import { Title } from '../Table'; | ||
import { UserGroup } from '../UserGroup'; | ||
|
||
import { tr } from './GoalDependency.i18n'; | ||
|
||
const StyledCheckboxInput = styled(CheckboxInput)` | ||
margin: 0; | ||
`; | ||
|
||
const StyledGoalListItemCompact = styled(GoalListItemCompact)` | ||
cursor: pointer; | ||
`; | ||
|
||
interface GoalDependencyProps { | ||
id: string; | ||
items: { kind: dependencyKind; goals: Goal[] }[]; | ||
onSubmit: (values: ToggleGoalDependency) => void; | ||
} | ||
|
||
const getId = (item: { id: string }) => item.id; | ||
|
||
export const GoalDependency: FC<GoalDependencyProps> = ({ id, items = [], onSubmit }) => { | ||
const [goalQuery, setGoalQuery] = useState(''); | ||
const [kind, setKind] = useState(dependencyKind.dependsOn); | ||
|
||
const selectedGoals = useMemo(() => { | ||
return items.flatMap(({ goals }) => goals); | ||
}, [items]); | ||
|
||
const { data: goals = [] } = trpc.goal.suggestions.useQuery( | ||
{ | ||
input: goalQuery, | ||
limit: 5, | ||
}, | ||
{ | ||
staleTime: 0, | ||
cacheTime: 0, | ||
}, | ||
); | ||
|
||
const radios = useMemo(() => { | ||
return [ | ||
{ | ||
title: tr('dependsOn'), | ||
value: dependencyKind.dependsOn, | ||
}, | ||
{ | ||
title: tr('blocks'), | ||
value: dependencyKind.blocks, | ||
}, | ||
{ | ||
title: tr('relatedTo'), | ||
value: dependencyKind.relatedTo, | ||
}, | ||
]; | ||
}, []); | ||
|
||
const handleClick = useCallback( | ||
(values: { id: string; onClick: () => void }) => () => { | ||
const data = { | ||
id, | ||
kind, | ||
relation: { id: values.id }, | ||
}; | ||
|
||
values.onClick(); | ||
onSubmit(data); | ||
}, | ||
[id, kind, onSubmit], | ||
); | ||
|
||
return ( | ||
<FilterBase | ||
mode="multiple" | ||
viewMode="split" | ||
items={goals} | ||
keyGetter={getId} | ||
value={selectedGoals} | ||
renderItem={({ item, checked, onItemClick }) => { | ||
return nullable(!checked, () => ( | ||
<StyledGoalListItemCompact | ||
icon | ||
rawIcon={<StyledCheckboxInput checked={checked} value={getId(item)} />} | ||
item={item} | ||
onClick={handleClick({ | ||
id: getId(item), | ||
onClick: onItemClick, | ||
})} | ||
columns={[ | ||
{ | ||
name: 'title', | ||
renderColumn: (values) => ( | ||
<CustomCell col={6}> | ||
<Title size="s" weight="bold"> | ||
{values.title} | ||
</Title> | ||
</CustomCell> | ||
), | ||
}, | ||
{ | ||
name: 'state', | ||
columnProps: { | ||
min: true, | ||
forIcon: true, | ||
}, | ||
}, | ||
{ | ||
name: 'projectId', | ||
columnProps: { | ||
col: 1, | ||
}, | ||
}, | ||
{ | ||
name: 'issuers', | ||
renderColumn: (values) => ( | ||
<CustomCell align="start" width={45}> | ||
<UserGroup users={values.issuers} size={18} /> | ||
</CustomCell> | ||
), | ||
}, | ||
]} | ||
/> | ||
)); | ||
}} | ||
> | ||
<FilterAutoCompleteInput onChange={setGoalQuery} /> | ||
<AutoCompleteRadioGroup | ||
title={tr('Kind')} | ||
items={radios} | ||
name="Kind" | ||
onChange={({ value }) => setKind(value as dependencyKind)} | ||
value={kind} | ||
/> | ||
</FilterBase> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import React, { useCallback } from 'react'; | ||
import { Goal } from '@prisma/client'; | ||
import { IconXCircleSolid } from '@taskany/icons'; | ||
import styled from 'styled-components'; | ||
|
||
import { ToggleGoalDependency, dependencyKind } from '../schema/goal'; | ||
import { GoalDependencyItem } from '../../trpc/inferredTypes'; | ||
import { routes } from '../hooks/router'; | ||
|
||
import { GoalBadge } from './GoalBadge'; | ||
|
||
const StyledGoalBadge = styled(GoalBadge)` | ||
margin-left: 5px; // 24 / 2 - 7 center of UserPic and center of PlusIcon | ||
`; | ||
|
||
interface GoalDependency extends Goal, GoalDependencyItem {} | ||
interface GoalDependencyListByKindProps { | ||
id: string; | ||
kind: dependencyKind; | ||
goals: GoalDependency[]; | ||
onClick?: (item: GoalDependency) => void; | ||
onRemove?: (values: ToggleGoalDependency) => void; | ||
} | ||
|
||
export const GoalDependencyListByKind = ({ | ||
id, | ||
kind, | ||
goals = [], | ||
onClick, | ||
onRemove, | ||
}: GoalDependencyListByKindProps) => { | ||
const onClickHandler = useCallback( | ||
(goal: GoalDependency) => (e?: React.MouseEvent) => { | ||
if (onClick) { | ||
e?.preventDefault(); | ||
onClick(goal); | ||
} | ||
}, | ||
[onClick], | ||
); | ||
|
||
return goals.map((item) => ( | ||
<StyledGoalBadge | ||
key={item.id} | ||
title={item.title} | ||
state={item?.state} | ||
href={routes.goal(item._shortId)} | ||
onClick={onClickHandler(item)} | ||
> | ||
<IconXCircleSolid | ||
size="xs" | ||
onClick={onRemove ? () => onRemove({ id, kind, relation: { id: item.id } }) : undefined} | ||
/> | ||
</StyledGoalBadge> | ||
)); | ||
}; |
6 changes: 0 additions & 6 deletions
6
src/components/GoalDependencyList/GoalDependencyList.i18n/ru.json
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.