PluginProbe
ElasticPress / 4.5.0
ElasticPress v4.5.0
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 / report.js

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

83 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, Notice, Panel, PanelBody, PanelHeader } from '@wordpress/components';
5 import { safeHTML } from '@wordpress/dom';
6 import { RawHTML, WPElement } from '@wordpress/element';
7 import { decodeEntities } from '@wordpress/html-entities';
8
9 /**
10 * Internal dependencies.
11 */
12 import Value from './report/value';
13
14 /**
15 * Report components.
16 *
17 * @param {object} props Component props.
18 * @param {Array} props.actions Report actions.
19 * @param {object} props.groups Report groups.
20 * @param {string} props.id Report ID.
21 * @param {string} props.messages Report messages.
22 * @param {string} props.title Report title.
23 * @returns {WPElement} Report component.
24 */
25 export default ({ actions, groups, id, messages, title }) => {
26 if (groups.length < 1) {
27 return null;
28 }
29
30 return (
31 <Panel id={title}>
32 <PanelHeader>
33 <h2 id={id}>{title}</h2>
34 {actions.map(({ href, label }) => (
35 <Button
36 href={decodeEntities(href)}
37 isDestructive
38 isSecondary
39 isSmall
40 key={href}
41 >
42 {label}
43 </Button>
44 ))}
45 </PanelHeader>
46 {messages.map(({ message, type }) => (
47 <Notice status={type} isDismissible={false}>
48 <RawHTML>{safeHTML(message)}</RawHTML>
49 </Notice>
50 ))}
51 {groups.map(({ fields, title }) => (
52 <PanelBody key={title} title={decodeEntities(title)} initialOpen={false}>
53 <table
54 cellPadding="0"
55 cellSpacing="0"
56 className="wp-list-table widefat striped"
57 >
58 <colgroup>
59 <col />
60 <col />
61 </colgroup>
62 <tbody>
63 {Object.entries(fields).map(
64 ([key, { description = '', label, value }]) => (
65 <tr key={key}>
66 <td>
67 {label}
68 {description ? <small>{description}</small> : null}
69 </td>
70 <td>
71 <Value value={value} />
72 </td>
73 </tr>
74 ),
75 )}
76 </tbody>
77 </table>
78 </PanelBody>
79 ))}
80 </Panel>
81 );
82 };
83