@elementor/editor-audits 4.4.0-1114 → 4.4.0-1116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +327 -781
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +301 -755
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/audit-panel.tsx +3 -1
- package/src/components/pages/overview-page.tsx +24 -29
- package/src/components/report-shell.tsx +10 -91
- package/src/components/severity-summary-cards.tsx +52 -0
- package/src/components/violation-row.tsx +3 -3
- package/src/utils/audit-status-summary.ts +0 -57
- package/src/components/audit-statuses-section.tsx +0 -65
- package/src/components/count-summary-circle.tsx +0 -66
- package/src/components/pages/all-audits-page.tsx +0 -84
- package/src/components/pages/issues-page.tsx +0 -65
- package/src/components/score-bar.tsx +0 -56
- package/src/components/score-circle.tsx +0 -60
- package/src/components/severity-filter-chips.tsx +0 -57
- package/src/utils/score-thresholds.ts +0 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-audits",
|
|
3
|
-
"version": "4.4.0-
|
|
3
|
+
"version": "4.4.0-1116",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "Elementor Team",
|
|
6
6
|
"homepage": "https://elementor.com/",
|
|
@@ -39,21 +39,21 @@
|
|
|
39
39
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@elementor/editor": "4.4.0-
|
|
43
|
-
"@elementor/editor-mcp": "4.4.0-
|
|
44
|
-
"@elementor/editor-app-bar": "4.4.0-
|
|
45
|
-
"@elementor/editor-elements": "4.4.0-
|
|
46
|
-
"@elementor/editor-floating-panels": "4.4.0-
|
|
47
|
-
"@elementor/editor-notifications": "4.4.0-
|
|
48
|
-
"@elementor/editor-props": "4.4.0-
|
|
49
|
-
"@elementor/editor-styles": "4.4.0-
|
|
50
|
-
"@elementor/editor-v1-adapters": "4.4.0-
|
|
51
|
-
"@elementor/events": "4.4.0-
|
|
52
|
-
"@elementor/http-client": "4.4.0-
|
|
42
|
+
"@elementor/editor": "4.4.0-1116",
|
|
43
|
+
"@elementor/editor-mcp": "4.4.0-1116",
|
|
44
|
+
"@elementor/editor-app-bar": "4.4.0-1116",
|
|
45
|
+
"@elementor/editor-elements": "4.4.0-1116",
|
|
46
|
+
"@elementor/editor-floating-panels": "4.4.0-1116",
|
|
47
|
+
"@elementor/editor-notifications": "4.4.0-1116",
|
|
48
|
+
"@elementor/editor-props": "4.4.0-1116",
|
|
49
|
+
"@elementor/editor-styles": "4.4.0-1116",
|
|
50
|
+
"@elementor/editor-v1-adapters": "4.4.0-1116",
|
|
51
|
+
"@elementor/events": "4.4.0-1116",
|
|
52
|
+
"@elementor/http-client": "4.4.0-1116",
|
|
53
53
|
"@elementor/icons": "~1.77.0",
|
|
54
|
-
"@elementor/locations": "4.4.0-
|
|
55
|
-
"@elementor/session": "4.4.0-
|
|
56
|
-
"@elementor/store": "4.4.0-
|
|
54
|
+
"@elementor/locations": "4.4.0-1116",
|
|
55
|
+
"@elementor/session": "4.4.0-1116",
|
|
56
|
+
"@elementor/store": "4.4.0-1116",
|
|
57
57
|
"@elementor/ui": "1.37.5"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { getHostDocumentId } from '@elementor/editor-elements';
|
|
3
3
|
import { FloatingPanelBody, FloatingPanelFooter, FloatingPanelHeader } from '@elementor/editor-floating-panels';
|
|
4
|
+
import { ReloadIcon } from '@elementor/icons';
|
|
4
5
|
import { Box, Button, Typography } from '@elementor/ui';
|
|
5
6
|
import { __ } from '@wordpress/i18n';
|
|
6
7
|
|
|
@@ -51,10 +52,11 @@ export default function AuditPanel() {
|
|
|
51
52
|
<Button
|
|
52
53
|
variant="contained"
|
|
53
54
|
size="small"
|
|
55
|
+
startIcon={ lastScanLabel ? <ReloadIcon fontSize="small" /> : undefined }
|
|
54
56
|
onClick={ onRun }
|
|
55
57
|
disabled={ status === 'loading' || hostDocumentId === 0 }
|
|
56
58
|
>
|
|
57
|
-
{ lastScanLabel ? __( '
|
|
59
|
+
{ lastScanLabel ? __( 'Rescan', 'elementor' ) : __( 'Run page audit', 'elementor' ) }
|
|
58
60
|
</Button>
|
|
59
61
|
</FloatingPanelFooter>
|
|
60
62
|
</>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { Box,
|
|
2
|
+
import { Box, Typography } from '@elementor/ui';
|
|
3
3
|
import { __ } from '@wordpress/i18n';
|
|
4
4
|
|
|
5
5
|
import { ALL_CATEGORIES, CATEGORY_LABELS } from '../../constants';
|
|
6
6
|
import { type AuditCategory, type PageAuditReport } from '../../types';
|
|
7
7
|
import { getPopulatedCategories } from '../../utils/audit-status-summary';
|
|
8
|
-
import {
|
|
8
|
+
import { countSeverities } from '../../utils/severity-counts';
|
|
9
|
+
import IssuesCategoryRow from '../issues-category-row';
|
|
9
10
|
import Promotions from '../promotions';
|
|
10
|
-
import
|
|
11
|
-
import ScoreCircle from '../score-circle';
|
|
11
|
+
import SeveritySummaryCards from '../severity-summary-cards';
|
|
12
12
|
|
|
13
13
|
type Props = {
|
|
14
14
|
onCategoryClick: ( category: AuditCategory ) => void;
|
|
@@ -17,35 +17,30 @@ type Props = {
|
|
|
17
17
|
|
|
18
18
|
export default function OverviewPage( { onCategoryClick, report }: Props ) {
|
|
19
19
|
const populatedCategories = getPopulatedCategories( report.categories, ALL_CATEGORIES );
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
const categoryRows = populatedCategories
|
|
22
|
+
.map( ( category ) => ( { category, counts: countSeverities( report, category ) } ) )
|
|
23
|
+
.filter( ( { counts } ) => Object.values( counts ).some( ( count ) => count > 0 ) );
|
|
21
24
|
|
|
22
25
|
return (
|
|
23
|
-
<Box
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
<Box display="flex" flexDirection="column" gap={ 3 } p={ 2 }>
|
|
27
|
+
<SeveritySummaryCards report={ report } />
|
|
28
|
+
<Box display="flex" flexDirection="column" gap={ 1 }>
|
|
29
|
+
<Typography variant="subtitle1" component="h2">
|
|
30
|
+
{ __( 'All issues', 'elementor' ) }
|
|
31
|
+
</Typography>
|
|
32
|
+
<Box display="flex" flexDirection="column" gap={ 1 }>
|
|
33
|
+
{ categoryRows.map( ( { category, counts } ) => (
|
|
34
|
+
<IssuesCategoryRow
|
|
35
|
+
key={ category }
|
|
36
|
+
category={ category }
|
|
37
|
+
label={ CATEGORY_LABELS[ category ] }
|
|
38
|
+
counts={ counts }
|
|
39
|
+
onClick={ () => onCategoryClick( category ) }
|
|
40
|
+
/>
|
|
41
|
+
) ) }
|
|
37
42
|
</Box>
|
|
38
43
|
</Box>
|
|
39
|
-
<Box sx={ { display: 'flex', flexDirection: 'column', gap: 2 } }>
|
|
40
|
-
{ populatedCategories.map( ( category ) => (
|
|
41
|
-
<ScoreBar
|
|
42
|
-
key={ category }
|
|
43
|
-
label={ CATEGORY_LABELS[ category ] }
|
|
44
|
-
score={ report.categories[ category ].score }
|
|
45
|
-
onClick={ () => onCategoryClick( category ) }
|
|
46
|
-
/>
|
|
47
|
-
) ) }
|
|
48
|
-
</Box>
|
|
49
44
|
<Promotions report={ report } />
|
|
50
45
|
</Box>
|
|
51
46
|
);
|
|
@@ -1,114 +1,33 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import { Box
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { Box } from '@elementor/ui';
|
|
5
4
|
|
|
6
5
|
import { type AuditCategory, type PageAuditReport } from '../types';
|
|
7
|
-
import { type AuditStatusGroup } from '../utils/audit-status-summary';
|
|
8
|
-
import AllAuditsPage from './pages/all-audits-page';
|
|
9
6
|
import CategoryPage from './pages/category-page';
|
|
10
|
-
import IssuesPage from './pages/issues-page';
|
|
11
7
|
import OverviewPage from './pages/overview-page';
|
|
12
8
|
|
|
13
|
-
type
|
|
14
|
-
|
|
15
|
-
type ActivePage =
|
|
16
|
-
| 'overview'
|
|
17
|
-
| 'issues'
|
|
18
|
-
| { backTo: TabId; category: AuditCategory }
|
|
19
|
-
| { backTo: TabId; expand?: AuditStatusGroup; page: 'all-audits' };
|
|
9
|
+
type ActivePage = 'overview' | { category: AuditCategory };
|
|
20
10
|
|
|
21
11
|
type Props = {
|
|
22
12
|
report: PageAuditReport;
|
|
23
13
|
};
|
|
24
14
|
|
|
25
|
-
function
|
|
26
|
-
if ( page === 'overview' ) {
|
|
27
|
-
return 'overview';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if ( page === 'issues' ) {
|
|
31
|
-
return 'issues';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return page.backTo;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function isAllAuditsPage( page: ActivePage ): page is { backTo: TabId; expand?: AuditStatusGroup; page: 'all-audits' } {
|
|
38
|
-
return typeof page === 'object' && 'page' in page && page.page === 'all-audits';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function isCategoryPage( page: ActivePage ): page is { backTo: TabId; category: AuditCategory } {
|
|
15
|
+
function isCategoryPage( page: ActivePage ): page is { category: AuditCategory } {
|
|
42
16
|
return typeof page === 'object' && 'category' in page;
|
|
43
17
|
}
|
|
44
18
|
|
|
45
19
|
export default function ReportShell( { report }: Props ) {
|
|
46
20
|
const [ activePage, setActivePage ] = useState< ActivePage >( 'overview' );
|
|
47
21
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const handleTabChange = ( _: React.SyntheticEvent, value: TabId ) => {
|
|
51
|
-
setActivePage( value );
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const openCategory = ( category: AuditCategory, backTo: TabId ) => {
|
|
55
|
-
setActivePage( { category, backTo } );
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const openAllAudits = ( expand?: AuditStatusGroup, backTo: TabId = 'issues' ) => {
|
|
59
|
-
setActivePage( { page: 'all-audits', expand, backTo } );
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const backFromSubPage = () => {
|
|
63
|
-
if ( isAllAuditsPage( activePage ) || isCategoryPage( activePage ) ) {
|
|
64
|
-
setActivePage( activePage.backTo );
|
|
65
|
-
}
|
|
66
|
-
};
|
|
22
|
+
const openCategory = ( category: AuditCategory ) => setActivePage( { category } );
|
|
23
|
+
const backToOverview = () => setActivePage( 'overview' );
|
|
67
24
|
|
|
68
25
|
return (
|
|
69
|
-
<Box sx={ {
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
onChange={ handleTabChange }
|
|
75
|
-
textColor="secondary"
|
|
76
|
-
indicatorColor="secondary"
|
|
77
|
-
size="small"
|
|
78
|
-
centered={ true }
|
|
79
|
-
variant="fullWidth"
|
|
80
|
-
>
|
|
81
|
-
<Tab value="overview" label={ __( 'Overview', 'elementor' ) } />
|
|
82
|
-
<Tab value="issues" label={ __( 'Issues', 'elementor' ) } />
|
|
83
|
-
</Tabs>
|
|
84
|
-
<Divider />
|
|
85
|
-
</Box>
|
|
86
|
-
<Box sx={ { flex: 1, minHeight: 0, overflowY: 'auto' } }>
|
|
87
|
-
{ activePage === 'overview' && (
|
|
88
|
-
<OverviewPage
|
|
89
|
-
report={ report }
|
|
90
|
-
onCategoryClick={ ( category ) => openCategory( category, 'overview' ) }
|
|
91
|
-
/>
|
|
92
|
-
) }
|
|
93
|
-
{ activePage === 'issues' && (
|
|
94
|
-
<IssuesPage
|
|
95
|
-
report={ report }
|
|
96
|
-
onCategoryClick={ ( category ) => openCategory( category, 'issues' ) }
|
|
97
|
-
onAllAuditsClick={ () => openAllAudits() }
|
|
98
|
-
onStatusClick={ ( status ) => openAllAudits( status ) }
|
|
99
|
-
/>
|
|
100
|
-
) }
|
|
101
|
-
{ isAllAuditsPage( activePage ) && (
|
|
102
|
-
<AllAuditsPage
|
|
103
|
-
report={ report }
|
|
104
|
-
initialExpandedStatus={ activePage.expand }
|
|
105
|
-
onBack={ backFromSubPage }
|
|
106
|
-
/>
|
|
107
|
-
) }
|
|
108
|
-
{ isCategoryPage( activePage ) && (
|
|
109
|
-
<CategoryPage category={ activePage.category } report={ report } onBack={ backFromSubPage } />
|
|
110
|
-
) }
|
|
111
|
-
</Box>
|
|
26
|
+
<Box sx={ { flex: 1, minHeight: 0, overflowY: 'auto' } }>
|
|
27
|
+
{ activePage === 'overview' && <OverviewPage report={ report } onCategoryClick={ openCategory } /> }
|
|
28
|
+
{ isCategoryPage( activePage ) && (
|
|
29
|
+
<CategoryPage category={ activePage.category } report={ report } onBack={ backToOverview } />
|
|
30
|
+
) }
|
|
112
31
|
</Box>
|
|
113
32
|
);
|
|
114
33
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Box, Typography } from '@elementor/ui';
|
|
3
|
+
|
|
4
|
+
import { type AuditSeverity, type PageAuditReport } from '../types';
|
|
5
|
+
import { ALL_SEVERITIES, countSeverities, severityPluralLabel } from '../utils/severity-counts';
|
|
6
|
+
import SeverityIcon from './severity-icons';
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
report: PageAuditReport;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default function SeveritySummaryCards( { report }: Props ) {
|
|
13
|
+
const counts = countSeverities( report );
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Box display="flex" gap={ 1.5 }>
|
|
17
|
+
{ ALL_SEVERITIES.map( ( severity ) => (
|
|
18
|
+
<SeverityCard key={ severity } severity={ severity } count={ counts[ severity ] } />
|
|
19
|
+
) ) }
|
|
20
|
+
</Box>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type SeverityCardProps = {
|
|
25
|
+
severity: AuditSeverity;
|
|
26
|
+
count: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function SeverityCard( { severity, count }: SeverityCardProps ) {
|
|
30
|
+
return (
|
|
31
|
+
<Box
|
|
32
|
+
display="flex"
|
|
33
|
+
flex={ 1 }
|
|
34
|
+
flexDirection="column"
|
|
35
|
+
gap={ 1 }
|
|
36
|
+
bgcolor="grey.50"
|
|
37
|
+
borderRadius={ 1.5 }
|
|
38
|
+
px={ 1.5 }
|
|
39
|
+
py={ 1 }
|
|
40
|
+
>
|
|
41
|
+
<SeverityIcon severity={ severity } />
|
|
42
|
+
<Box display="flex" flexDirection="column">
|
|
43
|
+
<Typography variant="h5" fontWeight={ 700 } component="span">
|
|
44
|
+
{ count }
|
|
45
|
+
</Typography>
|
|
46
|
+
<Typography variant="caption" color="text.secondary">
|
|
47
|
+
{ severityPluralLabel( severity ) }
|
|
48
|
+
</Typography>
|
|
49
|
+
</Box>
|
|
50
|
+
</Box>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -59,7 +59,7 @@ function GuidanceAction( { violation }: { violation: AuditViolation } ) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
return (
|
|
62
|
-
<Box
|
|
62
|
+
<Box display="flex" alignItems="center" gap={ 1 } mt={ 1 }>
|
|
63
63
|
<ViolationCtaButton
|
|
64
64
|
ctaLabel={ violation.ctaLabel as string }
|
|
65
65
|
externalUrl={ violation.externalUrl as string }
|
|
@@ -122,7 +122,7 @@ export default function ViolationRow( { audit, expanded, onToggleExpand, skipRea
|
|
|
122
122
|
</IconButton>
|
|
123
123
|
</Box>
|
|
124
124
|
<Collapse in={ expanded }>
|
|
125
|
-
<Box
|
|
125
|
+
<Box paddingBlock={ 1 }>
|
|
126
126
|
<Tooltip title={ audit.fixHint } placement="top">
|
|
127
127
|
<Alert
|
|
128
128
|
severity="secondary"
|
|
@@ -136,9 +136,9 @@ export default function ViolationRow( { audit, expanded, onToggleExpand, skipRea
|
|
|
136
136
|
<Typography variant="caption" component="p" color="text.secondary">
|
|
137
137
|
{ audit.description }
|
|
138
138
|
</Typography>
|
|
139
|
+
{ primaryViolation && <GuidanceAction violation={ primaryViolation } /> }
|
|
139
140
|
</Alert>
|
|
140
141
|
</Tooltip>
|
|
141
|
-
{ primaryViolation && <GuidanceAction violation={ primaryViolation } /> }
|
|
142
142
|
</Box>
|
|
143
143
|
{ violations && violations.length > 0 && (
|
|
144
144
|
<Box role="list" sx={ { paddingBlockEnd: 1 } }>
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import { type ChipProps } from '@elementor/ui';
|
|
2
|
-
import { __ } from '@wordpress/i18n';
|
|
3
|
-
|
|
4
1
|
import { type AuditCategory, type AuditResult, type AuditRun, type PageAuditReport } from '../types';
|
|
5
2
|
import { isScoredAudit } from './is-scored-audit';
|
|
6
3
|
import { sortFailedAuditResults } from './sort-failed-audits';
|
|
7
4
|
|
|
8
|
-
export type AuditStatusGroup = 'fail' | 'pass' | 'skipped';
|
|
9
|
-
|
|
10
5
|
export type PartitionedAuditResults = {
|
|
11
6
|
failed: Array< AuditRun & { result: Extract< AuditResult, { status: 'fail' } > } >;
|
|
12
7
|
passed: Array< AuditRun & { result: Extract< AuditResult, { status: 'pass' } > } >;
|
|
@@ -61,58 +56,6 @@ export function partitionAuditResults(
|
|
|
61
56
|
};
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
export function auditStatusDisplayCounts( report: PageAuditReport ): Record< AuditStatusGroup, number > {
|
|
65
|
-
let pass = 0;
|
|
66
|
-
let skipped = 0;
|
|
67
|
-
let totalViolations = 0;
|
|
68
|
-
|
|
69
|
-
for ( const { audit, result } of report.auditResults ) {
|
|
70
|
-
if ( ! isScoredAudit( audit ) ) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
switch ( result.status ) {
|
|
75
|
-
case 'fail':
|
|
76
|
-
totalViolations += result.violations.length;
|
|
77
|
-
break;
|
|
78
|
-
case 'pass':
|
|
79
|
-
pass++;
|
|
80
|
-
break;
|
|
81
|
-
case 'skipped':
|
|
82
|
-
skipped++;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
fail: totalViolations,
|
|
89
|
-
pass,
|
|
90
|
-
skipped,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function auditStatusColor( status: AuditStatusGroup ): ChipProps[ 'color' ] {
|
|
95
|
-
switch ( status ) {
|
|
96
|
-
case 'fail':
|
|
97
|
-
return 'error';
|
|
98
|
-
case 'pass':
|
|
99
|
-
return 'success';
|
|
100
|
-
case 'skipped':
|
|
101
|
-
return 'default';
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function auditStatusLabel( status: AuditStatusGroup ): string {
|
|
106
|
-
switch ( status ) {
|
|
107
|
-
case 'fail':
|
|
108
|
-
return __( 'Failed audits', 'elementor' );
|
|
109
|
-
case 'pass':
|
|
110
|
-
return __( 'Passed audits', 'elementor' );
|
|
111
|
-
case 'skipped':
|
|
112
|
-
return __( 'Skipped audits', 'elementor' );
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
59
|
export function getPopulatedCategories(
|
|
117
60
|
categoryTotals: PageAuditReport[ 'categories' ],
|
|
118
61
|
categories: readonly AuditCategory[]
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Box, Divider, Typography } from '@elementor/ui';
|
|
3
|
-
import { __, sprintf } from '@wordpress/i18n';
|
|
4
|
-
|
|
5
|
-
import { type PageAuditReport } from '../types';
|
|
6
|
-
import {
|
|
7
|
-
auditStatusColor,
|
|
8
|
-
auditStatusDisplayCounts,
|
|
9
|
-
type AuditStatusGroup,
|
|
10
|
-
auditStatusLabel,
|
|
11
|
-
} from '../utils/audit-status-summary';
|
|
12
|
-
import CountSummaryCircle from './count-summary-circle';
|
|
13
|
-
|
|
14
|
-
type Props = {
|
|
15
|
-
report: PageAuditReport;
|
|
16
|
-
onStatusClick: ( status: AuditStatusGroup ) => void;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const STATUS_ARIA_LABELS: Record< AuditStatusGroup, ( count: number ) => string > = {
|
|
20
|
-
pass: ( count ) =>
|
|
21
|
-
sprintf(
|
|
22
|
-
/* translators: %d: number of passed audits. */
|
|
23
|
-
__( '%d passed audits, view all', 'elementor' ),
|
|
24
|
-
count
|
|
25
|
-
),
|
|
26
|
-
fail: ( count ) =>
|
|
27
|
-
sprintf(
|
|
28
|
-
/* translators: %d: number of failed audit violations. */
|
|
29
|
-
__( '%d failed audits, view all', 'elementor' ),
|
|
30
|
-
count
|
|
31
|
-
),
|
|
32
|
-
skipped: ( count ) =>
|
|
33
|
-
sprintf(
|
|
34
|
-
/* translators: %d: number of skipped audits. */
|
|
35
|
-
__( '%d skipped audits, view all', 'elementor' ),
|
|
36
|
-
count
|
|
37
|
-
),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const STATUS_GROUPS = [ 'fail', 'pass', 'skipped' ] as const;
|
|
41
|
-
|
|
42
|
-
export default function AuditStatusesSection( { report, onStatusClick }: Props ) {
|
|
43
|
-
const statusCounts = auditStatusDisplayCounts( report );
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<Typography variant="subtitle1" fontWeight="bold">
|
|
48
|
-
{ __( 'Audit statuses', 'elementor' ) }
|
|
49
|
-
</Typography>
|
|
50
|
-
<Box sx={ { display: 'flex', justifyContent: 'space-around', gap: 2 } }>
|
|
51
|
-
{ STATUS_GROUPS.map( ( status ) => (
|
|
52
|
-
<CountSummaryCircle
|
|
53
|
-
key={ status }
|
|
54
|
-
ariaLabel={ STATUS_ARIA_LABELS[ status ]( statusCounts[ status ] ) }
|
|
55
|
-
color={ auditStatusColor( status ) }
|
|
56
|
-
count={ statusCounts[ status ] }
|
|
57
|
-
label={ auditStatusLabel( status ) }
|
|
58
|
-
onClick={ () => onStatusClick( status ) }
|
|
59
|
-
/>
|
|
60
|
-
) ) }
|
|
61
|
-
</Box>
|
|
62
|
-
<Divider />
|
|
63
|
-
</>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Box, Chip, type ChipProps, type Theme, Typography } from '@elementor/ui';
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
ariaLabel: string;
|
|
6
|
-
color: ChipProps[ 'color' ];
|
|
7
|
-
count: number;
|
|
8
|
-
label: string;
|
|
9
|
-
onClick: () => void;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const COUNT_SUMMARY_CIRCLE_SIZE = 64;
|
|
13
|
-
const COUNT_SUMMARY_BORDER_WIDTH = 4;
|
|
14
|
-
|
|
15
|
-
function chipBorderColor( theme: Theme, color: ChipProps[ 'color' ] ): string {
|
|
16
|
-
if ( color === 'default' || ! color ) {
|
|
17
|
-
return theme.palette.text.secondary;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return theme.palette[ color ].main;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default function CountSummaryCircle( { ariaLabel, color, count, label, onClick }: Props ) {
|
|
24
|
-
return (
|
|
25
|
-
<Box
|
|
26
|
-
aria-label={ ariaLabel }
|
|
27
|
-
component="button"
|
|
28
|
-
onClick={ onClick }
|
|
29
|
-
type="button"
|
|
30
|
-
sx={ {
|
|
31
|
-
alignItems: 'center',
|
|
32
|
-
background: 'none',
|
|
33
|
-
border: 'none',
|
|
34
|
-
cursor: 'pointer',
|
|
35
|
-
display: 'flex',
|
|
36
|
-
flex: 1,
|
|
37
|
-
flexDirection: 'column',
|
|
38
|
-
gap: 0.5,
|
|
39
|
-
padding: 0,
|
|
40
|
-
} }
|
|
41
|
-
>
|
|
42
|
-
<Chip
|
|
43
|
-
color={ color }
|
|
44
|
-
label={ count }
|
|
45
|
-
size="small"
|
|
46
|
-
variant="standard"
|
|
47
|
-
sx={ ( theme: Theme ) => ( {
|
|
48
|
-
border: `${ COUNT_SUMMARY_BORDER_WIDTH }px solid ${ chipBorderColor( theme, color ) }`,
|
|
49
|
-
borderRadius: '50%',
|
|
50
|
-
height: COUNT_SUMMARY_CIRCLE_SIZE,
|
|
51
|
-
maxWidth: COUNT_SUMMARY_CIRCLE_SIZE,
|
|
52
|
-
width: COUNT_SUMMARY_CIRCLE_SIZE,
|
|
53
|
-
'& .MuiChip-label': {
|
|
54
|
-
fontSize: theme.typography.body2.fontSize,
|
|
55
|
-
fontWeight: 700,
|
|
56
|
-
lineHeight: 1,
|
|
57
|
-
padding: 0,
|
|
58
|
-
},
|
|
59
|
-
} ) }
|
|
60
|
-
/>
|
|
61
|
-
<Typography color="text.secondary" sx={ { textAlign: 'center' } } variant="caption">
|
|
62
|
-
{ label }
|
|
63
|
-
</Typography>
|
|
64
|
-
</Box>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { Box } from '@elementor/ui';
|
|
3
|
-
import { __ } from '@wordpress/i18n';
|
|
4
|
-
|
|
5
|
-
import { useSingleExpandedCard } from '../../hooks/use-single-expanded-card';
|
|
6
|
-
import { type PageAuditReport } from '../../types';
|
|
7
|
-
import {
|
|
8
|
-
auditStatusColor,
|
|
9
|
-
type AuditStatusGroup,
|
|
10
|
-
auditStatusLabel,
|
|
11
|
-
partitionAuditResults,
|
|
12
|
-
} from '../../utils/audit-status-summary';
|
|
13
|
-
import StatusSection from '../status-section';
|
|
14
|
-
import SubpageHeader from '../subpage-header';
|
|
15
|
-
import ViolationRow from '../violation-row';
|
|
16
|
-
|
|
17
|
-
type Props = {
|
|
18
|
-
initialExpandedStatus?: AuditStatusGroup;
|
|
19
|
-
onBack: () => void;
|
|
20
|
-
report: PageAuditReport;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default function AllAuditsPage( { initialExpandedStatus, onBack, report }: Props ) {
|
|
24
|
-
const { failed, passed, skipped, totalViolations } = partitionAuditResults( report );
|
|
25
|
-
const expandFail = ! initialExpandedStatus || initialExpandedStatus === 'fail';
|
|
26
|
-
const expandPass = initialExpandedStatus === 'pass';
|
|
27
|
-
const expandSkipped = initialExpandedStatus === 'skipped';
|
|
28
|
-
const { expandedId, toggle } = useSingleExpandedCard();
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Box key={ initialExpandedStatus ?? 'default' }>
|
|
32
|
-
<SubpageHeader title={ __( 'All audits', 'elementor' ) } onBack={ onBack } />
|
|
33
|
-
<Box sx={ { p: 1 } }>
|
|
34
|
-
<StatusSection
|
|
35
|
-
label={ auditStatusLabel( 'fail' ) }
|
|
36
|
-
count={ totalViolations }
|
|
37
|
-
color={ auditStatusColor( 'fail' ) }
|
|
38
|
-
defaultExpanded={ expandFail }
|
|
39
|
-
>
|
|
40
|
-
{ failed.map( ( r ) => (
|
|
41
|
-
<ViolationRow
|
|
42
|
-
key={ r.audit.id }
|
|
43
|
-
audit={ r.audit }
|
|
44
|
-
violations={ r.result.violations }
|
|
45
|
-
expanded={ expandedId === r.audit.id }
|
|
46
|
-
onToggleExpand={ () => toggle( r.audit.id ) }
|
|
47
|
-
/>
|
|
48
|
-
) ) }
|
|
49
|
-
</StatusSection>
|
|
50
|
-
<StatusSection
|
|
51
|
-
label={ auditStatusLabel( 'pass' ) }
|
|
52
|
-
count={ passed.length }
|
|
53
|
-
color={ auditStatusColor( 'pass' ) }
|
|
54
|
-
defaultExpanded={ expandPass }
|
|
55
|
-
>
|
|
56
|
-
{ passed.map( ( r ) => (
|
|
57
|
-
<ViolationRow
|
|
58
|
-
key={ r.audit.id }
|
|
59
|
-
audit={ r.audit }
|
|
60
|
-
expanded={ expandedId === r.audit.id }
|
|
61
|
-
onToggleExpand={ () => toggle( r.audit.id ) }
|
|
62
|
-
/>
|
|
63
|
-
) ) }
|
|
64
|
-
</StatusSection>
|
|
65
|
-
<StatusSection
|
|
66
|
-
label={ auditStatusLabel( 'skipped' ) }
|
|
67
|
-
count={ skipped.length }
|
|
68
|
-
color={ auditStatusColor( 'skipped' ) }
|
|
69
|
-
defaultExpanded={ expandSkipped }
|
|
70
|
-
>
|
|
71
|
-
{ skipped.map( ( r ) => (
|
|
72
|
-
<ViolationRow
|
|
73
|
-
key={ r.audit.id }
|
|
74
|
-
audit={ r.audit }
|
|
75
|
-
skipReason={ r.result.reason }
|
|
76
|
-
expanded={ expandedId === r.audit.id }
|
|
77
|
-
onToggleExpand={ () => toggle( r.audit.id ) }
|
|
78
|
-
/>
|
|
79
|
-
) ) }
|
|
80
|
-
</StatusSection>
|
|
81
|
-
</Box>
|
|
82
|
-
</Box>
|
|
83
|
-
);
|
|
84
|
-
}
|