Skip to content

Commit 6555495

Browse files
authored
fix: add back color dots next to the translation state filters (#3324)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added visual indicators for translation states in the translation filter. Icons are shown for specific states and colored dots for others to provide quick status cues. * Filter items updated to display the new state indicator alongside existing controls and adjusted layout to accommodate it. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent bd8a6ab commit 6555495

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

webapp/src/views/projects/translations/TranslationFilters/FilterItem.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { CompactMenuItem } from 'tg.component/ListComponents';
1313

1414
const StyledMenuItem = styled(CompactMenuItem)`
1515
display: grid;
16-
grid-template-columns: auto 1fr auto;
16+
grid-template-columns: auto 1fr auto auto;
1717
align-items: center;
1818
padding-left: 4px !important;
1919
& .hidden {
@@ -50,10 +50,19 @@ type Props = MenuItemProps & {
5050
excluded?: boolean;
5151
onExclude?: () => void;
5252
exclusive?: boolean;
53+
indicator?: React.ReactNode;
5354
};
5455

5556
export const FilterItem = React.forwardRef(function FilterItem(
56-
{ label, excluded, selected, onExclude, exclusive, ...other }: Props,
57+
{
58+
label,
59+
excluded,
60+
selected,
61+
onExclude,
62+
exclusive,
63+
indicator,
64+
...other
65+
}: Props,
5766
ref
5867
) {
5968
const { t } = useTranslate();
@@ -96,6 +105,7 @@ export const FilterItem = React.forwardRef(function FilterItem(
96105
: t('translation_filter_item_exclude')}
97106
</ButtonToggle>
98107
)}
108+
{indicator}
99109
</StyledMenuItem>
100110
);
101111
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { styled } from '@mui/material';
2+
import { Flag02 } from '@untitled-ui/icons-react';
3+
import { TRANSLATION_STATES } from 'tg.constants/translationStates';
4+
import { Mt } from 'tg.component/CustomIcons';
5+
import { TranslationStateType } from './tools';
6+
7+
const StyledDot = styled('div')`
8+
margin-left: 12px;
9+
margin-right: 4px;
10+
width: 8px;
11+
height: 8px;
12+
border-radius: 4px;
13+
`;
14+
15+
const StyledIcon = styled('div')`
16+
margin-left: 8px;
17+
display: flex;
18+
align-items: center;
19+
font-size: 16px;
20+
width: 16px;
21+
height: 16px;
22+
color: ${({ theme }) => theme.palette.tokens.icon.secondary};
23+
`;
24+
25+
type Props = {
26+
state: TranslationStateType;
27+
};
28+
29+
export const StateIndicator = ({ state }: Props) => {
30+
if (state === 'AUTO_TRANSLATED' || state === 'OUTDATED') {
31+
return (
32+
<StyledIcon>
33+
{state === 'AUTO_TRANSLATED' && <Mt />}
34+
{state === 'OUTDATED' && <Flag02 />}
35+
</StyledIcon>
36+
);
37+
}
38+
39+
const color = TRANSLATION_STATES[state].color;
40+
return <StyledDot style={{ background: color }} />;
41+
};

webapp/src/views/projects/translations/TranslationFilters/SubfilterTranslations.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { CompactListSubheader } from 'tg.component/ListComponents';
1010
import { FiltersInternal, FilterActions, TranslationStateType } from './tools';
1111
import { FilterItem } from './FilterItem';
1212
import { LanguageModel } from './tools';
13+
import { StateIndicator } from './StateIndicator';
1314

1415
type Props = {
1516
projectId: number;
@@ -94,6 +95,7 @@ export const SubfilterTranslations = ({
9495
value.filterTranslationState?.includes(state)
9596
)}
9697
onClick={() => toggleFilterState(state)}
98+
indicator={<StateIndicator state={state} />}
9799
/>
98100
);
99101
})}

0 commit comments

Comments
 (0)