1- import { Skeleton } from '@appquality/unguess-design-system' ;
1+ import { Button , Skeleton } from '@appquality/unguess-design-system' ;
22import styled from 'styled-components' ;
33import { SeverityTag } from 'src/common/components/tag/SeverityTag' ;
44import { CampaignStatus , StatusTag } from 'src/common/components/tag/StatusTag' ;
55import { Pipe } from 'src/common/components/Pipe' ;
6+ import { ReactComponent as ArrowDowloadIcon } from 'src/assets/icons/download-stroke.svg' ;
7+ import { ReactComponent as GearIcon } from 'src/assets/icons/gear.svg' ;
8+ import { useTranslation } from 'react-i18next' ;
9+ import { getLocalizeIntegrationCenterRoute } from 'src/hooks/useLocalizeIntegrationCenterUrl' ;
10+ import WPAPI from 'src/common/wpapi' ;
11+ import useWindowSize from 'src/hooks/useWindowSize' ;
12+ import { theme as globalTheme } from 'src/app/theme' ;
613import { UniqueBugsCounter } from './UniqueBugsCounter' ;
7- import { DotsMenu } from './DotsMenu' ;
814import { useCampaign } from './useCampaign' ;
915
1016const SeveritiesWrapper = styled . div `
1117 display: flex;
1218 align-items: center;
1319 justify-content: flex-start;
1420 flex-wrap: wrap;
15-
16- @media (max-width: ${ ( { theme } ) => theme . breakpoints . lg } ) {
17- > div {
18- margin-right: ${ ( { theme } ) => theme . space . xxs } ;
19- margin-bottom: ${ ( { theme } ) => theme . space . xxs } ;
20- }
21- }
2221` ;
2322
24- const StyledCounter = styled ( UniqueBugsCounter ) `` ;
25-
26- const StyledStatus = styled ( StatusTag ) `` ;
23+ const ToolsWrapper = styled . div `
24+ display: flex;
25+ align-items: center;
26+ justify-content: flex-start;
27+ flex-wrap: wrap;
28+ ` ;
2729
28- const StyledMenu = styled ( DotsMenu ) `
30+ const Container = styled . div `
2931 display: flex;
30- margin-left: ${ ( { theme } ) => theme . space . md } ;
32+ align-items: center;
33+ justify-content: space-between;
34+ flex-wrap: wrap;
35+ width: 100%;
3136` ;
3237
33- const ToolsWrapper = styled . div `
38+ const ButtonsWrapper = styled . div `
3439 display: flex;
3540 align-items: center;
3641 justify-content: flex-start;
3742 flex-wrap: wrap;
38- margin-left: auto;
39-
40- @media (max-width: ${ ( { theme } ) => theme . breakpoints . xxl } ) {
41- flex-wrap: nowrap;
42- order: 0;
43- }
44-
45- @media (max-width: ${ ( { theme } ) => theme . breakpoints . xl } ) {
46- order: 1;
47- width: 100%;
48- margin-top: ${ ( { theme } ) => theme . space . md } ;
49- margin-left: 0;
50- }
51-
52- @media (max-width: ${ ( { theme } ) => theme . breakpoints . lg } ) {
53- flex-direction: column;
54- align-items: flex-start;
55-
56- ${ Pipe } {
57- display: none;
58- }
59-
60- ${ StyledCounter } {
61- margin-bottom: ${ ( { theme } ) => theme . space . sm } ;
62- }
63-
64- ${ SeveritiesWrapper } {
65- margin-bottom: ${ ( { theme } ) => theme . space . xxs } ;
66- }
67-
68- ${ StyledStatus } {
69- margin-bottom: ${ ( { theme } ) => theme . space . xs } ;
70- }
71- }
7243` ;
7344
7445export const Tools = ( {
@@ -78,15 +49,20 @@ export const Tools = ({
7849 campaignId : number ;
7950 customerTitle : string ;
8051} ) => {
52+ const { width } = useWindowSize ( ) ;
53+ const breakpoint = parseInt ( globalTheme . breakpoints . lg , 10 ) ;
54+ const hide = width < breakpoint ;
55+ const { t } = useTranslation ( ) ;
56+ const integrationCenterUrl = getLocalizeIntegrationCenterRoute ( campaignId ) ;
8157 const { isLoading, status, severities } = useCampaign ( campaignId ) ;
8258
8359 if ( isLoading || ! status || ! severities )
8460 return < Skeleton width = "200px" height = "20px" /> ;
8561
8662 return (
87- < >
63+ < Container >
8864 < ToolsWrapper >
89- < StyledCounter campaignId = { campaignId } />
65+ { ! hide && < UniqueBugsCounter campaignId = { campaignId } /> }
9066 < SeveritiesWrapper >
9167 { Object . keys ( severities ) . map ( ( severity ) => (
9268 < SeverityTag
@@ -96,11 +72,37 @@ export const Tools = ({
9672 size = "large"
9773 />
9874 ) ) }
75+ { ! hide && < Pipe /> }
76+ < StatusTag status = { status . name as CampaignStatus } />
9977 </ SeveritiesWrapper >
100- < Pipe />
101- < StyledStatus status = { status . name as CampaignStatus } />
10278 </ ToolsWrapper >
103- < StyledMenu campaignId = { campaignId } customerTitle = { customerTitle } />
104- </ >
79+ < ButtonsWrapper >
80+ < Button
81+ isBasic
82+ onClick = { ( ) =>
83+ WPAPI . getReport ( {
84+ campaignId,
85+ title : customerTitle ,
86+ } )
87+ }
88+ >
89+ < Button . StartIcon >
90+ < ArrowDowloadIcon />
91+ </ Button . StartIcon >
92+ { t ( '__PAGE_HEADER_BUGS_DOTS_MENU_ITEM_REPORT' ) }
93+ </ Button >
94+ < Button
95+ isBasic
96+ onClick = { ( ) => {
97+ window . location . href = integrationCenterUrl ;
98+ } }
99+ >
100+ < Button . StartIcon >
101+ < GearIcon />
102+ </ Button . StartIcon >
103+ { t ( '__PAGE_HEADER_BUGS_DOTS_MENU_ITEM_INT_CENTER' ) }
104+ </ Button >
105+ </ ButtonsWrapper >
106+ </ Container >
105107 ) ;
106108} ;
0 commit comments