diff --git a/assets/js/status-report/components/reports.js b/assets/js/status-report/components/reports.js index 73662027de..b80b807712 100644 --- a/assets/js/status-report/components/reports.js +++ b/assets/js/status-report/components/reports.js @@ -65,16 +65,19 @@ export default ({ plainTextReport, reports }) => {

- {Object.entries(reports).map(([key, { actions, groups, messages, title }]) => ( - - ))} + {Object.entries(reports).map( + ([key, { actions, groups, messages, title, is_ajax_report }]) => ( + + ), + )} ); }; diff --git a/assets/js/status-report/components/reports/report.js b/assets/js/status-report/components/reports/report.js index e33a572102..66e14d2096 100644 --- a/assets/js/status-report/components/reports/report.js +++ b/assets/js/status-report/components/reports/report.js @@ -20,13 +20,52 @@ import Value from './report/value'; * @param {string} props.id Report ID. * @param {string} props.messages Report messages. * @param {string} props.title Report title. + * @param {boolean} props.is_ajax_report Whether the report is loaded via AJAX. + * * @returns {WPElement} Report component. */ -export default ({ actions, groups, id, messages, title }) => { +export default ({ actions, groups, id, messages, title, is_ajax_report }) => { if (groups.length < 1) { return null; } + const loadAjax = () => { + console.log('test panel opened'); + }; + + if (is_ajax_report) { + return ( + + +

{title}

+ {actions.map(({ href, label }) => ( + + ))} +
+ {messages.map(({ message, type }) => ( + + {safeHTML(message)} + + ))} + {groups.map(({ fields, title }) => ( + + ))} +
+ ); + } return ( diff --git a/includes/classes/Screen/StatusReport.php b/includes/classes/Screen/StatusReport.php index bac313801e..e5d86cbb44 100644 --- a/includes/classes/Screen/StatusReport.php +++ b/includes/classes/Screen/StatusReport.php @@ -151,6 +151,7 @@ function ( $report ) { 'groups' => $report->get_groups(), 'messages' => $report->get_messages(), 'title' => $report->get_title(), + 'is_ajax_report' => $report->is_ajax_report(), ]; }, $reports diff --git a/includes/classes/StatusReport/IndexableContent.php b/includes/classes/StatusReport/IndexableContent.php index 2c4ecc9dd3..5e4d02ed22 100644 --- a/includes/classes/StatusReport/IndexableContent.php +++ b/includes/classes/StatusReport/IndexableContent.php @@ -191,4 +191,13 @@ protected function get_post_meta_fields(): array { return $fields; } + + /** + * Return whether the report is loaded via AJAX. + * + * @return bool + */ + public function is_ajax_report(): bool { + return true; + } } diff --git a/includes/classes/StatusReport/Indices.php b/includes/classes/StatusReport/Indices.php index 9f09a3afbc..689d36f85b 100644 --- a/includes/classes/StatusReport/Indices.php +++ b/includes/classes/StatusReport/Indices.php @@ -102,13 +102,4 @@ function ( $fields, $label ) use ( $index ) { return $groups; } - - /** - * Return whether the report is loaded via AJAX. - * - * @return bool - */ - public function is_ajax_report(): bool { - return true; - } }