Skip to content

Commit 7ed5929

Browse files
authored
Merge pull request #299 from AppQuality/incoming-bugs-duplicated
feat(incoming-bugs-duplicated): add duplicated tab
2 parents fea2af6 + 9ec7e17 commit 7ed5929

File tree

10 files changed

+200
-11
lines changed

10 files changed

+200
-11
lines changed

src/common/schema.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,17 @@ export interface components {
578578
*/
579579
kind: 'bugsByDevice';
580580
};
581+
/**
582+
* WidgetBugsByDuplicates
583+
* @description Returns the most 10 reported bugs ordered by numberd of duplicates
584+
*/
585+
WidgetBugsByDuplicates: {
586+
data: (components['schemas']['Bug'] & {
587+
duplicates: number;
588+
})[];
589+
/** @enum {string} */
590+
kind: 'bugsByDuplicates';
591+
};
581592
/**
582593
* WidgetCampaignProgress
583594
* @description Used to show an overview about a specific campaign.
@@ -653,9 +664,9 @@ export interface components {
653664
wslug:
654665
| 'bugs-by-usecase'
655666
| 'bugs-by-device'
656-
| 'bugs-by-type'
657667
| 'cp-progress'
658-
| 'unique-bugs';
668+
| 'unique-bugs'
669+
| 'bugs-by-duplicates';
659670
};
660671
requestBodies: {
661672
Credentials: {
@@ -893,7 +904,8 @@ export interface operations {
893904
| components['schemas']['WidgetBugsByUseCase']
894905
| components['schemas']['WidgetBugsByDevice']
895906
| components['schemas']['WidgetCampaignProgress']
896-
| components['schemas']['WidgetCampaignUniqueBugs'];
907+
| components['schemas']['WidgetCampaignUniqueBugs']
908+
| components['schemas']['WidgetBugsByDuplicates'];
897909
};
898910
};
899911
400: components['responses']['Error'];

src/features/api/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,17 +296,18 @@ export type GetCampaignsByCidWidgetsApiResponse =
296296
| WidgetBugsByUseCase
297297
| WidgetBugsByDevice
298298
| WidgetCampaignProgress
299-
| WidgetCampaignUniqueBugs;
299+
| WidgetCampaignUniqueBugs
300+
| WidgetBugsByDuplicates;
300301
export type GetCampaignsByCidWidgetsApiArg = {
301302
/** Campaign id */
302303
cid: number;
303304
/** Campaign widget slug */
304305
s:
305306
| 'bugs-by-usecase'
306307
| 'bugs-by-device'
307-
| 'bugs-by-type'
308308
| 'cp-progress'
309-
| 'unique-bugs';
309+
| 'unique-bugs'
310+
| 'bugs-by-duplicates';
310311
/** should update bug trend after request resolves? */
311312
updateTrend?: boolean;
312313
};
@@ -706,6 +707,12 @@ export type WidgetCampaignUniqueBugs = {
706707
};
707708
kind: 'campaignUniqueBugs';
708709
};
710+
export type WidgetBugsByDuplicates = {
711+
data: (Bug & {
712+
duplicates: number;
713+
})[];
714+
kind: 'bugsByDuplicates';
715+
};
709716
export type Project = {
710717
id: number;
711718
name: string;

src/hooks/useLocalizeDashboardUrl.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,16 @@ export function getLocalizeDashboardRoute(props: CampaignActionProps): string {
3838

3939
return getLocalizedUXDashboardUrl(campaignId, currentLang);
4040
}
41+
42+
export const getLocalizedBugUrl = (
43+
aCampaignId: number,
44+
aBugId: number,
45+
aLanguage: string
46+
): string =>
47+
aLanguage === 'en'
48+
? `${
49+
process.env.REACT_APP_CROWD_WP_URL ?? ''
50+
}/functional-customer-dashboard/?cid=${aCampaignId}&bug_id=${aBugId}`
51+
: `${
52+
process.env.REACT_APP_CROWD_WP_URL ?? ''
53+
}/it/dashboard-campagne-funzionali/?cid=${aCampaignId}&bug_id=${aBugId}`;

src/locales/en/translation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"__BUG_SEVERITY_LOW": "low",
2323
"__BUG_SEVERITY_MEDIUM": "medium",
2424
"__CAMPAIGN_CARD_EMPTY_TITLE_LABEL": "Untitled",
25+
"__CAMPAIGN_DUPLICATED_BUGS_TITLE": "Most submitted",
2526
"__CAMPAIGN_PAGE_BUTTON_DETAIL_BUG": "Go to bug detail",
2627
"__CAMPAIGN_PAGE_BUTTON_DETAIL_MEDIA": "Go to media detail",
2728
"__CAMPAIGN_PAGE_DEVICE_AND_BUG_TYPES_SECTION_TITLE": "Devices and bug types",
@@ -83,6 +84,7 @@
8384
"__CAMPAIGN_PAGE_WIDGET_UNIQUE_BUGS_TREND_LABEL_other": "unique bugs",
8485
"__CAMPAIGN_PAGE_WIDGET_UNIQUE_BUGS_WAFFLE_TOOLTIP_TOTAL": "Total bugs: <1>{{value}}</1>",
8586
"__CAMPAIGN_PAGE_WIDGET_UNIQUE_BUGS_WAFFLE_TOOLTIP_UNIQUE": "<0>{{value}}</0> unique bugs - <2>{{percent}}</2>%",
87+
"__CAMPAIGN_UNREAD_BUGS_TITLE": "Unread",
8688
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_COUNT_LABEL_one": "bugs {{severity}}",
8789
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_COUNT_LABEL_other": "bugs {{severity}}",
8890
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_DESCRIPTION_HEADER": "Reported by testers:",
@@ -91,6 +93,8 @@
9193
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_TOOLTIP": "Discover the impact of the unique bugs on your product. These indications keep in mind both the context and the conditions where testers have tracked the bug and help you understand the bug severity.",
9294
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_TOTAL_LABEL_one": "out of {{total}}",
9395
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_TOTAL_LABEL_other": "out of {{total}}",
96+
"__CAMPAIGN_WIDGET_INCOMING_BUGS_MOST_SUBMITTED_DESCRIPTION": "Le issue che si sono verificate più volte",
97+
"__CAMPAIGN_WIDGET_INCOMING_BUGS_MOST_SUBMITTED_DUPLICATES_LABEL": "Duplicates",
9498
"__CAMPAIGNS_TABLE_COLUMN_CAMPAIGN_TYPE": "Campaign Type",
9599
"__CAMPAIGNS_TABLE_COLUMN_NAME": "Name",
96100
"__CAMPAIGNS_TABLE_COLUMN_START_DATE": "Start Date",

src/locales/it/translation.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"__BUG_SEVERITY_LOW": "low",
2525
"__BUG_SEVERITY_MEDIUM": "medium",
2626
"__CAMPAIGN_CARD_EMPTY_TITLE_LABEL": "Senza Titolo",
27+
"__CAMPAIGN_DUPLICATED_BUGS_TITLE": "Most submitted",
2728
"__CAMPAIGN_PAGE_BUTTON_DETAIL_BUG": "Vai al dettaglio bug",
2829
"__CAMPAIGN_PAGE_BUTTON_DETAIL_MEDIA": "Vai al dettaglio media",
2930
"__CAMPAIGN_PAGE_DEVICE_AND_BUG_TYPES_SECTION_TITLE": "Dispositivi e tipologie bug",
@@ -87,6 +88,7 @@
8788
"__CAMPAIGN_PAGE_WIDGET_UNIQUE_BUGS_TREND_LABEL_other": "bug unici",
8889
"__CAMPAIGN_PAGE_WIDGET_UNIQUE_BUGS_WAFFLE_TOOLTIP_TOTAL": "Total bugs: <1>{{value}}</1>",
8990
"__CAMPAIGN_PAGE_WIDGET_UNIQUE_BUGS_WAFFLE_TOOLTIP_UNIQUE": "<0>{{value}}</0> bug unici - <2>{{percent}}</2>%",
91+
"__CAMPAIGN_UNREAD_BUGS_TITLE": "Unread",
9092
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_COUNT_LABEL_one": "bugs {{severity}}",
9193
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_COUNT_LABEL_many": "bugs {{severity}}",
9294
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_COUNT_LABEL_other": "bugs {{severity}}",
@@ -97,6 +99,8 @@
9799
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_TOTAL_LABEL_one": "out of {{total}}",
98100
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_TOTAL_LABEL_many": "out of {{total}}",
99101
"__CAMPAIGN_WIDGET_BUGDISTRIBUTION_TOTAL_LABEL_other": "out of {{total}}",
102+
"__CAMPAIGN_WIDGET_INCOMING_BUGS_MOST_SUBMITTED_DESCRIPTION": "Le issue che si sono verificate più volte",
103+
"__CAMPAIGN_WIDGET_INCOMING_BUGS_MOST_SUBMITTED_DUPLICATES_LABEL": "Duplicati",
100104
"__CAMPAIGNS_TABLE_COLUMN_CAMPAIGN_TYPE": "Tipo Campagna",
101105
"__CAMPAIGNS_TABLE_COLUMN_NAME": "Nome",
102106
"__CAMPAIGNS_TABLE_COLUMN_START_DATE": "Data Inizio",

src/pages/Campaign/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ const Campaign = () => {
126126
<UniqueBugs4UseCase contentHeight={contentHeight} />
127127
</Col>
128128
<Col xs={12} md={6}>
129-
<IncomingBugs />
129+
<IncomingBugs campaignId={campaign.id ?? 0} />
130130
</Col>
131131
<Col xs={12}>
132132
<SectionTitle
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import styled from 'styled-components';
2+
import { useTranslation } from 'react-i18next';
3+
import { getLocalizedBugUrl } from 'src/hooks/useLocalizeDashboardUrl';
4+
import i18n from 'src/i18n';
5+
import { WidgetBugsByDuplicates } from 'src/features/api';
6+
import { BugCard } from '../BugCard';
7+
8+
const BugCardWrapper = styled.div`
9+
margin-bottom: ${({ theme }) => theme.space.base * 4}px;
10+
`;
11+
12+
const BugCards = ({ bugs }: { bugs: WidgetBugsByDuplicates['data'] }) => {
13+
const { t } = useTranslation();
14+
15+
return (
16+
<>
17+
{bugs.map((bug) => {
18+
const bugUrl = getLocalizedBugUrl(
19+
bug.campaign_id,
20+
bug.id,
21+
i18n.language
22+
);
23+
24+
console.log('bug', bug);
25+
26+
return (
27+
<BugCardWrapper>
28+
<BugCard
29+
key={bug.id}
30+
severity={bug.severity.name.toLocaleLowerCase() as Severities}
31+
>
32+
{(severity) => (
33+
<>
34+
<BugCard.TopTitle>ID {bug.id}</BugCard.TopTitle>
35+
<BugCard.Title url={bugUrl}>
36+
{bug.title.compact}
37+
</BugCard.Title>
38+
<BugCard.Description>
39+
{bug.application_section.title}
40+
</BugCard.Description>
41+
<BugCard.Footer>
42+
{bug.title.context &&
43+
bug.title.context.length > 0 &&
44+
bug.title.context.map((context) => (
45+
<BugCard.Pill>{context}</BugCard.Pill>
46+
))}
47+
<BugCard.Pill>
48+
{t(
49+
'__CAMPAIGN_WIDGET_INCOMING_BUGS_MOST_SUBMITTED_DUPLICATES_LABEL'
50+
)}
51+
: {bug.duplicates}
52+
</BugCard.Pill>
53+
<BugCard.Separator />
54+
<BugCard.Pill>{bug.type.name}</BugCard.Pill>
55+
<BugCard.Pill severity={severity}>{severity}</BugCard.Pill>
56+
</BugCard.Footer>
57+
</>
58+
)}
59+
</BugCard>
60+
</BugCardWrapper>
61+
);
62+
})}
63+
</>
64+
);
65+
};
66+
67+
export { BugCards, BugCardWrapper };
Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1-
const DuplicateBugs = () => <>Duplicates</>;
1+
import { Skeleton, SM } from '@appquality/unguess-design-system';
2+
import { useTranslation } from 'react-i18next';
3+
import { WidgetBugsByDuplicates } from 'src/features/api';
4+
import styled from 'styled-components';
5+
import { BugCards, BugCardWrapper } from './BugCards';
6+
7+
const BugsWrapper = styled.div`
8+
margin-top: ${({ theme }) => theme.space.md};
9+
`;
10+
11+
const DuplicateBugs = ({
12+
data,
13+
}: {
14+
data: {
15+
bugs: WidgetBugsByDuplicates['data'];
16+
isLoading: boolean;
17+
isFetching: boolean;
18+
isError: boolean;
19+
};
20+
}) => {
21+
const { t } = useTranslation();
22+
const { bugs, isLoading, isFetching, isError } = data;
23+
24+
return (
25+
<>
26+
<SM>{t('__CAMPAIGN_WIDGET_INCOMING_BUGS_MOST_SUBMITTED_DESCRIPTION')}</SM>
27+
<BugsWrapper>
28+
{isLoading || isFetching || isError ? (
29+
<>
30+
<BugCardWrapper>
31+
<Skeleton height="120px" style={{ borderRadius: 0 }} />
32+
</BugCardWrapper>
33+
<BugCardWrapper>
34+
<Skeleton height="120px" style={{ borderRadius: 0 }} />
35+
</BugCardWrapper>
36+
<BugCardWrapper>
37+
<Skeleton height="120px" style={{ borderRadius: 0 }} />
38+
</BugCardWrapper>
39+
<BugCardWrapper>
40+
<Skeleton height="120px" style={{ borderRadius: 0 }} />
41+
</BugCardWrapper>
42+
</>
43+
) : (
44+
<BugCards bugs={bugs} />
45+
)}
46+
</BugsWrapper>
47+
</>
48+
);
49+
};
250

351
export { DuplicateBugs };

src/pages/Campaign/widgets/incomingBugs/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { useTranslation } from 'react-i18next';
33
import { UnreadBugs } from './UnreadBugs';
44
import { DuplicateBugs } from './DuplicateBugs';
55
import { BasicWidget } from '../widgetCards/BasicWidget';
6+
import { useBugsByDuplicates } from './useBugsByDuplicates';
67

7-
const IncomingBugs = () => {
8-
const thereAreDuplicates = true;
8+
const IncomingBugs = ({ campaignId }: { campaignId: number }) => {
99
const { t } = useTranslation();
10+
const duplicatesResponse = useBugsByDuplicates(campaignId);
11+
const thereAreDuplicates = duplicatesResponse.bugs?.length > 0;
1012

1113
return (
1214
<BasicWidget>
@@ -24,7 +26,7 @@ const IncomingBugs = () => {
2426
</Tabs.Tab>
2527
</Tabs.List>
2628
<Tabs.Panel item="duplicate">
27-
<DuplicateBugs />
29+
<DuplicateBugs data={duplicatesResponse} />
2830
</Tabs.Panel>
2931
<Tabs.Panel item="unread">
3032
<UnreadBugs />
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {
2+
useGetCampaignsByCidWidgetsQuery,
3+
WidgetBugsByDuplicates,
4+
} from 'src/features/api';
5+
6+
const useBugsByDuplicates = (campaignId: number) => {
7+
const { data, isLoading, isFetching, isError } =
8+
useGetCampaignsByCidWidgetsQuery({
9+
cid: campaignId,
10+
s: 'bugs-by-duplicates',
11+
});
12+
13+
const { data: results, kind } = data || {};
14+
15+
if (results && kind === 'bugsByDuplicates') {
16+
return {
17+
bugs: results as WidgetBugsByDuplicates['data'],
18+
isLoading,
19+
isFetching,
20+
isError,
21+
};
22+
}
23+
24+
return {
25+
bugs: [],
26+
isLoading,
27+
isFetching,
28+
isError,
29+
};
30+
};
31+
32+
export { useBugsByDuplicates };

0 commit comments

Comments
 (0)