From b0646aa8eb2133fdeb6a13457b29a7fec37dab49 Mon Sep 17 00:00:00 2001
From: Ella
Date: Fri, 7 Feb 2025 13:37:10 +0100
Subject: [PATCH] wip
---
.../wpcom-dashboard-widgets.php | 8 +--
.../wpcom-general-tasks-widget/index.js | 57 +------------------
2 files changed, 4 insertions(+), 61 deletions(-)
diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-dashboard-widgets/wpcom-dashboard-widgets.php b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-dashboard-widgets/wpcom-dashboard-widgets.php
index 8ecfd3129c27d..2232e00f4141e 100644
--- a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-dashboard-widgets/wpcom-dashboard-widgets.php
+++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-dashboard-widgets/wpcom-dashboard-widgets.php
@@ -33,6 +33,7 @@ function load_wpcom_dashboard_widgets() {
foreach ( $layout['secondary'] as $item ) {
if ( is_array( $item ) ) {
$tasks = $item;
+ break;
}
}
}
@@ -120,13 +121,6 @@ function enqueue_wpcom_dashboard_widgets( $args = array() ) {
'hasCustomDomain' => wpcom_site_has_feature( 'custom-domain' ),
'siteId' => get_current_blog_id(),
'tasks' => $args['tasks'],
- 'siteSuggestions' => Client::wpcom_json_api_request_as_blog(
- '/sites/' . get_current_blog_id() . '/home/layout',
- 'v2',
- array(),
- null,
- 'wpcom'
- ),
)
);
diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-dashboard-widgets/wpcom-general-tasks-widget/index.js b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-dashboard-widgets/wpcom-general-tasks-widget/index.js
index a71cb29254ab1..bc77e37fc4f3c 100644
--- a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-dashboard-widgets/wpcom-general-tasks-widget/index.js
+++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-dashboard-widgets/wpcom-general-tasks-widget/index.js
@@ -1,5 +1,4 @@
-import apiFetch from '@wordpress/api-fetch';
-import { useEffect, useState } from '@wordpress/element';
+import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import TaskDomainUpsell from './tasks/home-task-domain-upsell';
@@ -9,27 +8,8 @@ const taskMap = {
'home-task-domain-upsell': TaskDomainUpsell,
};
-export default ( { siteId } ) => {
- const [ response, setResponse ] = useState( [] );
+export default ( { tasks } ) => {
const [ index, setIndex ] = useState( 0 );
-
- useEffect( () => {
- const path = `/wpcom/v2/sites/${ siteId }/home/layout`;
- apiFetch( { path } ).then( setResponse );
- }, [ siteId ] );
-
- if ( ! Array.isArray( response?.secondary ) ) {
- return null;
- }
-
- // The secondary array countains strings that refer to cards, except for the
- // tasks which is an array.
- const tasks = response.secondary.find( item => Array.isArray( item ) );
-
- if ( ! tasks ) {
- return { __( 'No suggestions.', 'jetpack-mu-wpcom' ) }
;
- }
-
const task = tasks[ index ];
const TaskComponent = taskMap[ task ];
@@ -52,38 +32,7 @@ export default ( { siteId } ) => {
{ __( 'Next →', 'jetpack-mu-wpcom' ) }
- { TaskComponent ? (
-
- ) : (
- To do: { task }
- ) }
- { /* { createPortal(
-
-
-
- ,
- document.querySelector( '#wpcom_general_tasks_widget .wpcom_general_tasks_widget_title' )
- ) } */ }
+ { TaskComponent ? : [{ task }]
}
>
);
};