blob: 8f8eec11c7fac5bc98c5ad4517f939c5d8196a39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { LOADING, ERROR, SUCCESS, STATUS_FAILED } from '../../constants';
import { s__, n__ } from '~/locale';
export const groupedSummaryText = (state) => {
if (state.isLoading) {
return s__('Reports|Accessibility scanning results are being parsed');
}
if (state.hasError) {
return s__('Reports|Accessibility scanning failed loading results');
}
const numberOfResults = state.report?.summary?.errored || 0;
if (numberOfResults === 0) {
return s__('Reports|Accessibility scanning detected no issues for the source branch only');
}
return n__(
'Reports|Accessibility scanning detected %d issue for the source branch only',
'Reports|Accessibility scanning detected %d issues for the source branch only',
numberOfResults,
);
};
export const summaryStatus = (state) => {
if (state.isLoading) {
return LOADING;
}
if (state.hasError || state.status === STATUS_FAILED) {
return ERROR;
}
return SUCCESS;
};
export const shouldRenderIssuesList = (state) =>
Object.values(state.report).some((x) => Array.isArray(x) && x.length > 0);
// We could just map state, but we're going to iterate in the future
// to add notes and warnings to these issue lists, so I'm going to
// keep these as getters
export const unresolvedIssues = (state) => state.report.existing_errors;
export const resolvedIssues = (state) => state.report.resolved_errors;
export const newIssues = (state) => state.report.new_errors;
|