Skip to content

Commit 99ebbc8

Browse files
authored
Merge pull request #259 from AppQuality/develop
Add integration center reference into report dashboard
2 parents e146b30 + 54b1cb2 commit 99ebbc8

File tree

18 files changed

+223
-166
lines changed

18 files changed

+223
-166
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.4.0",
44
"private": true,
55
"dependencies": {
6-
"@appquality/unguess-design-system": "2.12.16",
6+
"@appquality/unguess-design-system": "2.12.17",
77
"@headwayapp/react-widget": "^0.0.4",
88
"@reduxjs/toolkit": "^1.8.0",
99
"@rtk-query/codegen-openapi": "^1.0.0-alpha.1",
@@ -42,8 +42,8 @@
4242
"recover": "yarn install --check-files",
4343
"eject": "react-scripts eject",
4444
"translate": "i18next-scanner",
45-
"generate-schema": ". ./.env; npx openapi-typescript $REACT_APP_API_URL/reference/ --output src/common/schema.ts ",
46-
"generate-api": ". ./.env; API_URL=$REACT_APP_API_URL/reference/ npx @rtk-query/codegen-openapi src/features/api/config.ts",
45+
"generate-schema": ". ./.env.local; npx openapi-typescript $REACT_APP_API_URL/reference/ --output src/common/schema.ts ",
46+
"generate-api": ". ./.env.local; API_URL=$REACT_APP_API_URL/reference/ npx @rtk-query/codegen-openapi src/features/api/config.ts",
4747
"generate-strapi": "npx @rtk-query/codegen-openapi src/features/backoffice/config.ts",
4848
"type:check": "tsc",
4949
"prettier": "prettier 'src/**/*.{js,jsx,ts,tsx,json,css,scss,md}'",

src/assets/emptyReports.svg

Lines changed: 42 additions & 42 deletions
Loading

src/features/api/api.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
22
import { stringify } from 'qs';
3-
import {
4-
GetWorkspacesByWidApiArg,
5-
GetWorkspacesByWidApiResponse,
6-
Template,
7-
} from '.';
3+
import { Template } from '.';
84

95
export const apiSlice = createApi({
106
reducerPath: 'api',
@@ -28,18 +24,9 @@ export const apiSlice = createApi({
2824
'Reports',
2925
'Templates',
3026
],
31-
endpoints: (build) => ({
32-
getWorkspacesByWid: build.query<
33-
GetWorkspacesByWidApiResponse,
34-
GetWorkspacesByWidApiArg
35-
>({
36-
query: (queryArg) => ({ url: `/workspaces/${queryArg.wid}` }),
37-
}),
38-
}),
27+
endpoints: () => ({}),
3928
});
4029

41-
export const { useLazyGetWorkspacesByWidQuery } = apiSlice;
42-
4330
export interface UseCaseTemplate extends Template {
4431
id?: number;
4532
}

src/features/api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ export type Workspace = {
416416
};
417417
coins?: number;
418418
};
419-
export type Output = 'bugs' | 'reports' | 'media';
419+
export type Output = 'bugs' | 'media';
420420
export type Campaign = {
421421
id: number;
422422
start_date: string;
@@ -450,6 +450,7 @@ export type Project = {
450450
id: number;
451451
name: string;
452452
campaigns_count: number;
453+
workspaceId: number;
453454
};
454455
export type Campaign2 = {
455456
id: number;

src/features/navigation/Navigation.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ export const Navigation = ({
219219
company: workspaceName,
220220
},
221221
});
222+
223+
// Navigate to home
224+
navigateTo('home');
222225
};
223226

224227
if (!activeWorkspace) return null;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import i18n from 'src/i18n';
2+
3+
export const getLocalizeIntegrationCenterRoute = (
4+
campaignId: number
5+
): string => {
6+
const currentLang = i18n.language || 'en';
7+
const localizedRoute =
8+
currentLang === 'en'
9+
? `${
10+
process.env.REACT_APP_CROWD_WP_URL ?? ''
11+
}/integration-center/${campaignId}`
12+
: `${
13+
process.env.REACT_APP_CROWD_WP_URL ?? ''
14+
}/it/integration-center/${campaignId}`;
15+
16+
return localizedRoute;
17+
};

src/locales/en/translation.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"__CAMPAIGN_PAGE_REPORTS_CARDS_UPDATED_ON_LABEL": "Last edit",
2020
"__CAMPAIGN_PAGE_REPORTS_CARDS_UPLOADED_ON_LABEL": "Uploaded on",
2121
"__CAMPAIGN_PAGE_REPORTS_DESCRIPTION": "Here you can find all files related to your campaign.",
22+
"__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_INTEGRATIONS_BUTTON": "Go to Integration Center",
23+
"__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_INTEGRATIONS_TEXT": "Do you want to start configuring the integration with your issue tracking software (e.g. Jira)?",
2224
"__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TEXT": "You’ll find attachments to your campaign once it’s over. You can always contact your CSM for questions and concerns.",
2325
"__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TITLE": "No content available yet",
2426
"__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_ARCHIVE": "Archive",

src/locales/it/translation.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
"__CAMPAIGN_PAGE_REPORTS_CARDS_UPDATED_ON_LABEL": "Ultima modifica:",
2020
"__CAMPAIGN_PAGE_REPORTS_CARDS_UPLOADED_ON_LABEL": "Caricato il",
2121
"__CAMPAIGN_PAGE_REPORTS_DESCRIPTION": "Qui puoi trovare tutti i materiali relativi alla tua campagna",
22+
"__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_INTEGRATIONS_BUTTON": "Vai all’Integration Center",
23+
"__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_INTEGRATIONS_TEXT": "Vuoi cominciare a configurare l’integrazione con il tuo sofware di issue tracking (es. Jira)?",
2224
"__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TEXT": "Qui troverai gli allegati della tua campagna, quando sarà finita. \nSei hai dubbi o domande, contatta il tuo CSM.",
2325
"__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TITLE": "Non ci sono ancora contenuti",
2426
"__CAMPAIGN_PAGE_REPORTS_FILE_TYPE_ARCHIVE": "Archivio",

src/pages/Campaign/ReportRow.tsx

Lines changed: 100 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import { ReactComponent as PresentationIcon } from 'src/assets/icons/file-icon-p
1818
import { ReactComponent as DownloadIcon } from 'src/assets/icons/download-stroke.svg';
1919
import { ReactComponent as OpenLinkIcon } from 'src/assets/icons/new-window-stroke.svg';
2020
import { ReactComponent as EmptyReportsImage } from 'src/assets/emptyReports.svg';
21-
import { Report } from 'src/features/api';
21+
import { Campaign, Report } from 'src/features/api';
2222
import { format } from 'date-fns';
2323
import { t } from 'i18next';
2424
import styled from 'styled-components';
25+
import { getLocalizeIntegrationCenterRoute } from 'src/hooks/useLocalizeIntegrationCenterUrl';
2526

2627
const CenteredContent = styled.div`
2728
display: flex;
@@ -84,81 +85,110 @@ const getFileTypeIcon = (type: string, url: string) => {
8485
}
8586
};
8687

87-
export const ReportRow = ({ reports }: { reports?: Report[] }) => (
88-
<Row>
89-
{reports && reports.length ? (
90-
reports.map((report) => (
91-
<Col xs={12} md={4} lg={3}>
92-
<SpecialCard>
93-
<SpecialCard.Meta
94-
justifyContent="start"
95-
style={{ fontSize: theme.fontSizes.sm }}
96-
>
97-
{report.update_date ? (
98-
<>
99-
{t('__CAMPAIGN_PAGE_REPORTS_CARDS_UPDATED_ON_LABEL')}{' '}
100-
{format(new Date(report.update_date), 'dd/MM/yyyy')}
101-
</>
102-
) : (
103-
<>
104-
{t('__CAMPAIGN_PAGE_REPORTS_CARDS_UPLOADED_ON_LABEL')}{' '}
105-
{format(new Date(report.creation_date ?? ''), 'dd/MM/yyyy')}
106-
</>
107-
)}
108-
</SpecialCard.Meta>
88+
export const ReportRow = ({
89+
reports,
90+
campaign,
91+
}: {
92+
reports?: Report[];
93+
campaign: Campaign;
94+
}) => {
95+
const { id: campaignId, family } = campaign;
96+
const { name: cpFamily } = family;
10997

110-
<SpecialCard.Thumb>
111-
{getFileTypeIcon(report.file_type?.type ?? '', report.url)}
112-
</SpecialCard.Thumb>
98+
return (
99+
<Row>
100+
{reports && reports.length ? (
101+
reports.map((report) => (
102+
<Col xs={12} md={4} lg={3}>
103+
<SpecialCard>
104+
<SpecialCard.Meta
105+
justifyContent="start"
106+
style={{ fontSize: theme.fontSizes.sm }}
107+
>
108+
{report.update_date ? (
109+
<>
110+
{t('__CAMPAIGN_PAGE_REPORTS_CARDS_UPDATED_ON_LABEL')}{' '}
111+
{format(new Date(report.update_date), 'dd/MM/yyyy')}
112+
</>
113+
) : (
114+
<>
115+
{t('__CAMPAIGN_PAGE_REPORTS_CARDS_UPLOADED_ON_LABEL')}{' '}
116+
{format(new Date(report.creation_date ?? ''), 'dd/MM/yyyy')}
117+
</>
118+
)}
119+
</SpecialCard.Meta>
120+
121+
<SpecialCard.Thumb>
122+
{getFileTypeIcon(report.file_type?.type ?? '', report.url)}
123+
</SpecialCard.Thumb>
113124

114-
<SpecialCard.Header>
115-
<SpecialCard.Header.Label>
116-
{getFileTypeName(report.file_type?.type ?? '', report.url)}
117-
</SpecialCard.Header.Label>
118-
<SpecialCard.Header.Title>
119-
{report.title}
120-
</SpecialCard.Header.Title>
121-
</SpecialCard.Header>
125+
<SpecialCard.Header>
126+
<SpecialCard.Header.Label>
127+
{getFileTypeName(report.file_type?.type ?? '', report.url)}
128+
</SpecialCard.Header.Label>
129+
<SpecialCard.Header.Title>
130+
{report.title}
131+
</SpecialCard.Header.Title>
132+
</SpecialCard.Header>
122133

123-
<SpecialCard.Footer direction="column" justifyContent="center">
134+
<SpecialCard.Footer direction="column" justifyContent="center">
135+
<Button
136+
isPill
137+
isStretched
138+
onClick={() => {
139+
// eslint-disable-next-line security/detect-non-literal-fs-filename
140+
window.open(report.url || '', '_blank');
141+
}}
142+
>
143+
<Button.StartIcon>
144+
{report.file_type?.type === 'link' ? (
145+
<OpenLinkIcon />
146+
) : (
147+
<DownloadIcon />
148+
)}
149+
</Button.StartIcon>
150+
{report.file_type?.type === 'link'
151+
? t('__CAMPAIGN_PAGE_REPORTS_CARDS_OPEN_LINK_LABEL')
152+
: t('__CAMPAIGN_PAGE_REPORTS_CARDS_DOWNLOAD_LABEL')}
153+
</Button>
154+
</SpecialCard.Footer>
155+
</SpecialCard>
156+
</Col>
157+
))
158+
) : (
159+
<CenteredContent>
160+
<EmptyReportsImage />
161+
<XL
162+
style={{
163+
fontWeight: theme.fontWeights.medium,
164+
marginTop: theme.space.xl,
165+
marginBottom: theme.space.sm,
166+
}}
167+
>
168+
{t('__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TITLE')}
169+
</XL>
170+
<Paragraph style={{ textAlign: 'center' }}>
171+
{t('__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TEXT')}
172+
</Paragraph>
173+
{cpFamily.toLocaleLowerCase() === 'functional' ? (
174+
<>
175+
<Paragraph style={{ textAlign: 'center' }}>
176+
{t('__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_INTEGRATIONS_TEXT')}
177+
</Paragraph>
124178
<Button
125179
isPill
126-
isStretched
127180
onClick={() => {
128-
// eslint-disable-next-line security/detect-non-literal-fs-filename
129-
window.open(report.url || '', '_blank');
181+
window.location.href =
182+
getLocalizeIntegrationCenterRoute(campaignId);
130183
}}
184+
style={{ marginTop: theme.space.md }}
131185
>
132-
<Button.StartIcon>
133-
{report.file_type?.type === 'link' ? (
134-
<OpenLinkIcon />
135-
) : (
136-
<DownloadIcon />
137-
)}
138-
</Button.StartIcon>
139-
{report.file_type?.type === 'link'
140-
? t('__CAMPAIGN_PAGE_REPORTS_CARDS_OPEN_LINK_LABEL')
141-
: t('__CAMPAIGN_PAGE_REPORTS_CARDS_DOWNLOAD_LABEL')}
186+
{t('__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_INTEGRATIONS_BUTTON')}
142187
</Button>
143-
</SpecialCard.Footer>
144-
</SpecialCard>
145-
</Col>
146-
))
147-
) : (
148-
<CenteredContent>
149-
<EmptyReportsImage />
150-
<XL
151-
style={{
152-
fontWeight: theme.fontWeights.medium,
153-
marginBottom: theme.space.sm,
154-
}}
155-
>
156-
{t('__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TITLE')}
157-
</XL>
158-
<Paragraph style={{ textAlign: 'center' }}>
159-
{t('__CAMPAIGN_PAGE_REPORTS_EMPTY_REPORTS_TEXT')}
160-
</Paragraph>
161-
</CenteredContent>
162-
)}
163-
</Row>
164-
);
188+
</>
189+
) : null}
190+
</CenteredContent>
191+
)}
192+
</Row>
193+
);
194+
};

0 commit comments

Comments
 (0)