PluginProbe
ElasticPress / 5.0.2
ElasticPress v5.0.2
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
elasticpress / assets / js / status-report / components / reports.js

reports.js in ElasticPress 5.0.2, at assets/js/status-report/components/reports.js

81 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies.
3 */
4 import { Button, Flex, FlexItem } from '@wordpress/components';
5 import { useCopyToClipboard } from '@wordpress/compose';
6 import { WPElement } from '@wordpress/element';
7 import { __ } from '@wordpress/i18n';
8
9 /**
10 * Internal dependencies.
11 */
12 import Report from './reports/report';
13 import { useSettingsScreen } from '../../settings-screen';
14
15 /**
16 * Styles.
17 */
18 import '../style.css';
19
20 /**
21 * Reports component.
22 *
23 * @param {object} props Component props.
24 * @param {string} props.plainTextReport Plain text report.
25 * @param {object} props.reports Status reports.
26 * @returns {WPElement} Reports component.
27 */
28 export default ({ plainTextReport, reports }) => {
29 const { createNotice } = useSettingsScreen();
30
31 const downloadUrl = `data:text/plain;charset=utf-8,${encodeURIComponent(plainTextReport)}`;
32
33 /**
34 * Copy to clipboard button ref.
35 *
36 * @type {object}
37 */
38 const ref = useCopyToClipboard(plainTextReport, () => {
39 createNotice('info', __('Copied status report to clipboard.', 'elasticpress'));
40 });
41
42 return (
43 <>
44 <p>
45 {__(
46 'This screen provides a list of information related to ElasticPress and synced content that can be helpful during troubleshooting. This list can also be copy/pasted and shared as needed.',
47 'elasticpress',
48 )}
49 </p>
50 <p>
51 <Flex justify="start">
52 <FlexItem>
53 <Button
54 download="elasticpress-report.txt"
55 href={downloadUrl}
56 variant="primary"
57 >
58 {__('Download status report', 'elasticpress')}
59 </Button>
60 </FlexItem>
61 <FlexItem>
62 <Button ref={ref} variant="secondary">
63 {__('Copy status report to clipboard', 'elasticpress')}
64 </Button>
65 </FlexItem>
66 </Flex>
67 </p>
68 {Object.entries(reports).map(([key, { actions, groups, messages, title }]) => (
69 <Report
70 actions={actions}
71 groups={groups}
72 id={key}
73 key={key}
74 messages={messages}
75 title={title}
76 />
77 ))}
78 </>
79 );
80 };
81