-
Notifications
You must be signed in to change notification settings - Fork 801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Launchpad: Adds the body prop to the tasks #33489
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. Mu Wpcom plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
projects/packages/jetpack-mu-wpcom/src/features/launchpad/class-launchpad-task-lists.php
Outdated
Show resolved
Hide resolved
2926e77
to
3c6409f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some comments based on inspection and thinking about the data model we want.
projects/packages/jetpack-mu-wpcom/src/features/launchpad/class-launchpad-task-lists.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php
Outdated
Show resolved
Hide resolved
a8d8358
to
10edac1
Compare
10edac1
to
4a9ea95
Compare
projects/packages/jetpack-mu-wpcom/src/features/launchpad/class-launchpad-task-lists.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/src/features/launchpad/class-launchpad-task-lists.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/src/features/launchpad/class-launchpad-task-lists.php
Outdated
Show resolved
Hide resolved
projects/packages/jetpack-mu-wpcom/src/features/launchpad/launchpad-task-definitions.php
Show resolved
Hide resolved
$extended_content_context = array(); | ||
|
||
foreach ( $task['extended_content'] as $context => $extended_content ) { | ||
$loaded_extended_context = array(); | ||
|
||
$actions = $this->load_value_from_callback( $extended_content, 'actions', null, $task['id'] ); | ||
if ( $actions ) { | ||
$loaded_extended_context['actions'] = $actions; | ||
} | ||
|
||
$content = $this->load_value_from_callback( $extended_content, 'content', null, $task['id'] ); | ||
if ( $actions ) { | ||
$loaded_extended_context['content'] = $content; | ||
} | ||
|
||
$extended_content_context[ $context ] = $loaded_extended_context; | ||
} | ||
|
||
return $extended_content_context; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The structure of the loop here doesn't quite match the data structure for the returned data, and it feels like we're still unnecessarily splitting up the action and content from each other. It also feels like $this->load_value_from_callback()
isn't ideal for this more complex pattern. I would much rather we tackled this via one callback, along with a loop structure more like the following:
$extended_content_context = array(); | |
foreach ( $task['extended_content'] as $context => $extended_content ) { | |
$loaded_extended_context = array(); | |
$actions = $this->load_value_from_callback( $extended_content, 'actions', null, $task['id'] ); | |
if ( $actions ) { | |
$loaded_extended_context['actions'] = $actions; | |
} | |
$content = $this->load_value_from_callback( $extended_content, 'content', null, $task['id'] ); | |
if ( $actions ) { | |
$loaded_extended_context['content'] = $content; | |
} | |
$extended_content_context[ $context ] = $loaded_extended_context; | |
} | |
return $extended_content_context; | |
$extended_content = array(); | |
foreach ( $task['extended_content'] as $context_index => $extended_content_data ) { | |
$content_by_context = array(); | |
if ( isset( $extended_content_callback ) && is_callable( $extended_content_callback ) ) { | |
$extended_content_for_context = call_user_func( $extended_content_callback, $task['id'] ); | |
if ( | |
is_array( $extended_content_for_context ) | |
&& isset( $extended_content_for_context['contexts'] ) | |
&& is_array( $extended_content_for_context['contexts'] ) | |
// require either actions or content - we might want both, or only require content | |
&& ( isset( $extended_content_for_context['actions'] ) || isset( $extended_content_for_context['content'] ) ) | |
) { | |
$current_contexts = $extended_content_for_context['contexts']; | |
$current_content_updated = false; | |
$current_context_data = array( | |
'actions' => array(), | |
'content' => array(), | |
); | |
if ( isset( $extended_content_for_context['actions'] ) && is_array( $extended_content_for_context['actions'] ) && array() !== $extended_content_for_context['actions'] ) { | |
$current_context_data['actions'] = $extended_content_for_context['actions']; | |
$current_content_updated = true; | |
} | |
if ( isset( $extended_content_for_context['content'] ) && is_array( $extended_content_for_context['content'] ) && array() !== $extended_content_for_context['content'] ) { | |
$current_context_data['content'] = $extended_content_for_context['content']; | |
$current_content_updated = true; | |
} | |
if ( $current_content_updated ) { | |
foreach ( $current_contexts as $current_context ) { | |
$extended_content[ $current_context ] = $current_context_data; | |
} | |
} | |
} | |
} | |
} | |
return $extended_content_context; |
This PR has been marked as stale. This happened because:
If this PR is still useful, please do a [trunk merge or rebase](https://github.com/Automattic/jetpack/blob/trunk/docs/git-workflow.md#keeping-your-branch-up-to-date) and otherwise make sure it's up to date and has clear testing instructions. You may also want to ping possible reviewers in case they've forgotten about it. Please close this PR if you think it's not valid anymore — if you do, please add a brief explanation. If the PR is not updated (or at least commented on) in another month, it will be automatically closed. |
These are out of date, going to close for now. We can rework this if we decide to try it again. |
Fixes #
Proposed changes:
Other information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/launchpad-task-body
0-sandbox.php
file and add the following code:GET
request toWP REST API -> wpcom/v2 -> /sites/:siteSlug/launchpad?_locale=user&checklist_slug=intent-build
extended_content
property under the "Customize your domain" task.