Skip to content

Commit 561f33c

Browse files
committed
NCL-9058 Unify common Del Analysis and Brew Push operation label mappers and attributes
1 parent fa7433c commit 561f33c

8 files changed

+168
-173
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { BuildPushOperation } from 'pnc-api-types-ts';
2+
3+
import { TEntityAttributes } from 'common/entityAttributes';
4+
import { operationEntityAttributes } from 'common/operationEntityAttributes';
5+
6+
interface IExtendedBuildPushOperation extends BuildPushOperation {
7+
'user.username': string;
8+
buildId: string;
9+
}
10+
11+
export const buildPushOperationEntityAttributes = {
12+
...operationEntityAttributes,
13+
buildId: {
14+
id: 'buildId',
15+
title: 'Build ID',
16+
},
17+
} as const satisfies TEntityAttributes<IExtendedBuildPushOperation>;

src/common/deliverableAnalysisOperationEntityAttributes.ts

Lines changed: 3 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,17 @@
11
import { DeliverableAnalyzerOperation } from 'pnc-api-types-ts';
22

33
import { TEntityAttributes } from 'common/entityAttributes';
4-
5-
const resultValues: DeliverableAnalyzerOperation['result'][] = [
6-
'SUCCESSFUL',
7-
'FAILED',
8-
'REJECTED',
9-
'CANCELLED',
10-
'TIMEOUT',
11-
'SYSTEM_ERROR',
12-
];
13-
14-
const progressStatusValues: DeliverableAnalyzerOperation['progressStatus'][] = ['NEW', 'PENDING', 'IN_PROGRESS', 'FINISHED'];
4+
import { operationEntityAttributes } from 'common/operationEntityAttributes';
155

166
interface IExtendedDeliverableAnalyzerOperation extends DeliverableAnalyzerOperation {
177
'user.username': string;
8+
'productMilestone.version': string;
189
deliverablesUrls: string;
1910
runAsScratchAnalysis: boolean;
20-
'productMilestone.version': string;
2111
}
2212

2313
export const deliverableAnalysisOperationEntityAttributes = {
24-
id: {
25-
id: 'id',
26-
title: 'ID',
27-
},
28-
submitTime: {
29-
id: 'submitTime',
30-
title: 'Submit Time',
31-
sort: {
32-
group: 'times',
33-
},
34-
},
35-
startTime: {
36-
id: 'startTime',
37-
title: 'Start Time',
38-
sort: {
39-
group: 'times',
40-
},
41-
},
42-
endTime: {
43-
id: 'endTime',
44-
title: 'End Time',
45-
sort: {
46-
group: 'times',
47-
},
48-
},
49-
progressStatus: {
50-
id: 'progressStatus',
51-
title: 'Progress Status',
52-
values: progressStatusValues,
53-
filter: {
54-
operator: '==',
55-
},
56-
},
57-
result: {
58-
id: 'result',
59-
title: 'Result',
60-
values: resultValues,
61-
filter: {
62-
operator: '==',
63-
},
64-
},
14+
...operationEntityAttributes,
6515
'productMilestone.version': {
6616
id: 'productMilestone.version',
6717
title: 'Milestone Version',
@@ -70,18 +20,6 @@ export const deliverableAnalysisOperationEntityAttributes = {
7020
},
7121
sort: {},
7222
},
73-
'user.username': {
74-
id: 'user.username',
75-
title: 'User',
76-
filter: {
77-
operator: '=like=',
78-
},
79-
sort: {},
80-
},
81-
parameters: {
82-
id: 'parameters',
83-
title: 'Parameters',
84-
},
8523
deliverablesUrls: {
8624
id: 'deliverablesUrls',
8725
title: 'Deliverables URLs',
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { DeliverableAnalyzerOperation } from 'pnc-api-types-ts';
2+
3+
import { TEntityAttributes } from 'common/entityAttributes';
4+
5+
// this supertype is not coming from pnc-api-types-ts
6+
// but these props are same for all Operations
7+
export interface Operation {
8+
id: DeliverableAnalyzerOperation['id'];
9+
parameters?: DeliverableAnalyzerOperation['parameters'];
10+
progressStatus?: DeliverableAnalyzerOperation['progressStatus'];
11+
result?: DeliverableAnalyzerOperation['result'];
12+
submitTime?: DeliverableAnalyzerOperation['submitTime'];
13+
startTime?: DeliverableAnalyzerOperation['startTime'];
14+
endTime?: DeliverableAnalyzerOperation['endTime'];
15+
user?: DeliverableAnalyzerOperation['user'];
16+
}
17+
18+
const operationResultValues: Operation['result'][] = ['SUCCESSFUL', 'FAILED', 'REJECTED', 'CANCELLED', 'TIMEOUT', 'SYSTEM_ERROR'];
19+
20+
const operationProgressStatusValues: Operation['progressStatus'][] = ['NEW', 'PENDING', 'IN_PROGRESS', 'FINISHED'];
21+
22+
interface IExtendedOperation extends Operation {
23+
'user.username': string;
24+
}
25+
26+
export const operationEntityAttributes = {
27+
id: {
28+
id: 'id',
29+
title: 'ID',
30+
},
31+
submitTime: {
32+
id: 'submitTime',
33+
title: 'Submit Time',
34+
sort: {
35+
group: 'times',
36+
},
37+
},
38+
startTime: {
39+
id: 'startTime',
40+
title: 'Start Time',
41+
sort: {
42+
group: 'times',
43+
},
44+
},
45+
endTime: {
46+
id: 'endTime',
47+
title: 'End Time',
48+
sort: {
49+
group: 'times',
50+
},
51+
},
52+
progressStatus: {
53+
id: 'progressStatus',
54+
title: 'Progress Status',
55+
values: operationProgressStatusValues,
56+
filter: {
57+
operator: '==',
58+
},
59+
},
60+
result: {
61+
id: 'result',
62+
title: 'Result',
63+
values: operationResultValues,
64+
filter: {
65+
operator: '==',
66+
},
67+
},
68+
'user.username': {
69+
id: 'user.username',
70+
title: 'User',
71+
filter: {
72+
operator: '=like=',
73+
},
74+
sort: {},
75+
},
76+
parameters: {
77+
id: 'parameters',
78+
title: 'Parameters',
79+
},
80+
} as const satisfies TEntityAttributes<IExtendedOperation>;

src/components/BuildPushStatusLabelMapper/BuildPushStatusLabelMapper.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/components/LabelMapper/DeliverableAnalysisProgressStatusLabelMapper.tsx

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/components/LabelMapper/DeliverableAnalysisResultLabelMapper.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Operation } from 'common/operationEntityAttributes';
2+
3+
import { ILabelMapper, LabelMapper } from 'components/LabelMapper/LabelMapper';
4+
5+
const OPERATION_PROGRESS_STATUSES: ILabelMapper<Operation['progressStatus']> = {
6+
NEW: {
7+
text: 'NEW',
8+
color: 'grey',
9+
},
10+
PENDING: {
11+
text: 'PENDING',
12+
color: 'grey',
13+
},
14+
IN_PROGRESS: {
15+
text: 'IN PROGRESS',
16+
color: 'blue',
17+
},
18+
FINISHED: {
19+
text: 'FINISHED',
20+
color: 'green',
21+
},
22+
};
23+
24+
interface IOperationProgressStatusLabelMapperProps {
25+
progressStatus: Exclude<Operation['progressStatus'], undefined>;
26+
}
27+
28+
export const OperationProgressStatusLabelMapper = ({ progressStatus }: IOperationProgressStatusLabelMapperProps) => (
29+
<LabelMapper mapperItem={OPERATION_PROGRESS_STATUSES[progressStatus]} />
30+
);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Operation } from 'common/operationEntityAttributes';
2+
3+
import { ILabelMapper, LabelMapper } from 'components/LabelMapper/LabelMapper';
4+
5+
const OPERATION_RESULTS: ILabelMapper<Operation['result']> = {
6+
SUCCESSFUL: {
7+
text: 'SUCCESSFUL',
8+
color: 'green',
9+
},
10+
FAILED: {
11+
text: 'FAILED',
12+
color: 'orange',
13+
},
14+
REJECTED: {
15+
text: 'REJECTED',
16+
color: 'orange',
17+
},
18+
CANCELLED: {
19+
text: 'CANCELLED',
20+
color: 'grey',
21+
},
22+
TIMEOUT: {
23+
text: 'TIMEOUT',
24+
color: 'grey',
25+
},
26+
SYSTEM_ERROR: {
27+
text: 'SYSTEM_ERROR',
28+
color: 'red',
29+
},
30+
};
31+
32+
interface IOperationResultLabelMapperProps {
33+
result: Exclude<Operation['result'], undefined>;
34+
}
35+
36+
export const OperationResultLabelMapper = ({ result }: IOperationResultLabelMapperProps) => (
37+
<LabelMapper mapperItem={OPERATION_RESULTS[result]} />
38+
);

0 commit comments

Comments
 (0)