Skip to content

Commit fceb676

Browse files
committed
🔨 refactor(translations): update insights count labels for observations and themes
🚀 feat(ActionBar): calculate and display unique themes count in action bar
1 parent 1df715b commit fceb676

File tree

3 files changed

+48
-15
lines changed

3 files changed

+48
-15
lines changed

‎src/locales/en/translation.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,10 @@
772772
"__INSIGHTS_PAGE_ACTION_BAR_BUTTON_CANCEL": "Cancel",
773773
"__INSIGHTS_PAGE_ACTION_BAR_BUTTON_CREATE_INSIGHT": "Create insight",
774774
"__INSIGHTS_PAGE_ACTION_BAR_BUTTON_EDIT_INSIGHT": "Update insight",
775-
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_LABEL_one": "Selected observation: <1>{{count}}</1>",
776-
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_LABEL_other": "Selected observations: <1>{{count}}</1>",
775+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_OBSERVATIONS_LABEL_one": "Selected observations: <1>{{observations}}</1>",
776+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_OBSERVATIONS_LABEL_other": "Selected observations: <1>{{observations}}</1>",
777+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_THEMES_LABEL_one": "Selected themes: <1>{{themes}}</1>",
778+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_THEMES_LABEL_other": "Selected themes: <1>{{themes}}</1>",
777779
"__INSIGHTS_PAGE_CLOSE_DRAWER_BUTTON": "Close",
778780
"__INSIGHTS_PAGE_COLLECTION_GROUP_BY_USECASE": "Group by Use Case",
779781
"__INSIGHTS_PAGE_COLLECTION_UNGROUP": "Show all",

‎src/locales/it/translation.json‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -799,9 +799,12 @@
799799
"__INSIGHTS_PAGE_ACTION_BAR_BUTTON_CANCEL": "Annulla",
800800
"__INSIGHTS_PAGE_ACTION_BAR_BUTTON_CREATE_INSIGHT": "",
801801
"__INSIGHTS_PAGE_ACTION_BAR_BUTTON_EDIT_INSIGHT": "",
802-
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_LABEL_one": "Osservazione selezionata: <1>{{count}}</1>",
803-
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_LABEL_many": "Osservazioni selezionate: <1>{{count}}</1>",
804-
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_LABEL_other": "Osservazioni selezionate: <1>{{count}}</1>",
802+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_OBSERVATIONS_LABEL_one": "Selected observations: <1>{{observations}}</1>",
803+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_OBSERVATIONS_LABEL_many": "Selected observations: <1>{{observations}}</1>",
804+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_OBSERVATIONS_LABEL_other": "Selected observations: <1>{{observations}}</1>",
805+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_THEMES_LABEL_one": "Selected themes: <1>{{themes}}</1>",
806+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_THEMES_LABEL_many": "Selected themes: <1>{{themes}}</1>",
807+
"__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_THEMES_LABEL_other": "Selected themes: <1>{{themes}}</1>",
805808
"__INSIGHTS_PAGE_CLOSE_DRAWER_BUTTON": "Close drawer",
806809
"__INSIGHTS_PAGE_COLLECTION_GROUP_BY_USECASE": "Organizza per Use Case",
807810
"__INSIGHTS_PAGE_COLLECTION_UNGROUP": "",

‎src/pages/Insights/ActionBar.tsx‎

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { useFormikContext } from 'formik';
22
import { Trans, useTranslation } from 'react-i18next';
3-
import { Button, MD, Span } from '@appquality/unguess-design-system';
3+
import { Button, MD, SM, Span } from '@appquality/unguess-design-system';
44
import { appTheme } from 'src/app/theme';
55
import styled from 'styled-components';
6+
import { VideoTag } from 'src/features/api';
7+
import { useMemo } from 'react';
68
import { InsightFormValues } from './FormProvider';
79
import { useInsightContext } from './InsightContext';
810

@@ -31,6 +33,21 @@ const ActionBar = () => {
3133
useFormikContext<InsightFormValues>();
3234
const { isDrawerOpen, setIsDrawerOpen } = useInsightContext();
3335

36+
const themesCount = useMemo(() => {
37+
const tags = values.observations.flatMap((obs) => obs.tags);
38+
const titles = tags.filter((tag) => tag.group.name === 'title');
39+
40+
// Get count of unique titles (tag.name)
41+
const uniqueTitles = titles.reduce((acc, tag) => {
42+
if (!acc.find((_t) => _t.tag.name === tag.tag.name)) {
43+
acc.push(tag);
44+
}
45+
return acc;
46+
}, [] as VideoTag[]);
47+
48+
return uniqueTitles.length;
49+
}, [values.observations]);
50+
3451
// Do not show action bar cta if in editing or creating mode
3552
const hideCta = (values.id > 0 || values.id === -1) && isDrawerOpen;
3653

@@ -39,15 +56,26 @@ const ActionBar = () => {
3956
return (
4057
<FloatingContainer>
4158
<Container>
42-
<MD style={{ marginRight: appTheme.space.md }}>
43-
<Trans
44-
count={values.observations.length}
45-
i18nKey="__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_LABEL"
46-
>
47-
Selected observations:
48-
<Span isBold>{{ count: values.observations.length }}</Span>
49-
</Trans>
50-
</MD>
59+
<div style={{ marginRight: appTheme.space.md }}>
60+
<MD>
61+
<Trans
62+
count={values.observations.length}
63+
i18nKey="__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_OBSERVATIONS_LABEL"
64+
>
65+
Selected observations:
66+
<Span isBold>{{ observations: values.observations.length }}</Span>
67+
</Trans>
68+
</MD>
69+
<SM style={{ marginTop: appTheme.space.xs }}>
70+
<Trans
71+
count={values.observations.length}
72+
i18nKey="__INSIGHTS_PAGE_ACTION_BAR_INSIGHTS_COUNT_THEMES_LABEL"
73+
>
74+
Selected themes:
75+
<Span isBold>{{ themes: themesCount }}</Span>
76+
</Trans>
77+
</SM>
78+
</div>
5179
{!hideCta && (
5280
<div style={{ marginLeft: appTheme.space.md }}>
5381
<Button

0 commit comments

Comments
 (0)