Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

valterlorran
Copy link
Contributor

@valterlorran valterlorran commented Oct 6, 2023

Fixes #

Proposed changes:

  • For my 20% time, I decided to test an idea we discussed in one of our calls with @daledupreez & @nuriapenya. The idea is to have a body with a description of the task and some other components like buttons, links, images, videos, etc.
  • I added a fundamental data structure that allows us to render components on the front end. For now, I only made available a Text and Link component.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

Testing instructions:

  • Apply this PR to your sandbox:
bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/launchpad-task-body
  • Edit your 0-sandbox.php file and add the following code:
function wpcom_launchpad_domain_customize_actions_filter( $actions, $task_id ) {
	if ( $task_id !== 'domain_customize' ) {
		return $actions;
	}
	return array(
		wpcom_launchpad_task_action_link(
			__( 'Learn more about', 'jetpack-mu-wpcom' ),
			'https://wordpress.com/support/domains/customize-your-domain/'
		),
		wpcom_launchpad_task_action_link(
			__( 'Help', 'jetpack-mu-wpcom' ),
			'https://wordpress.com/support/domains/customize-your-domain/'
		),
	);
}
add_filter( 'wpcom_launchpad_customize_task_actions', 'wpcom_launchpad_domain_customize_actions_filter', 10, 2 );

function wpcom_launchpad_domain_customize_content_filter( $content, $task_id ) {
	if ( $task_id !== 'domain_customize' ) {
		return $content;
	}
	return __( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque in tellus id eros scelerisque eleifend eget quis dui. Aenean eget sem non ex pulvinar commodo. Aliquam vel justo id ex rutrum faucibus id eu mi.', 'jetpack-mu-wpcom' );
}
add_filter( 'wpcom_launchpad_customize_task_content', 'wpcom_launchpad_domain_customize_content_filter', 10, 2 );
  • Navigate to the developer console: https://developer.wordpress.com/docs/api/console/
  • Make a GET request to WP REST API -> wpcom/v2 -> /sites/:siteSlug/launchpad?_locale=user&checklist_slug=intent-build
  • Ensure you can see the extended_content property under the "Customize your domain" task.

Screen Shot 2023-10-30 at 11 19 05

@valterlorran valterlorran requested a review from a team October 6, 2023 11:01
@valterlorran valterlorran self-assigned this Oct 6, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2023

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the add/launchpad-task-body branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack-mu-wpcom-plugin add/launchpad-task-body
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2023

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

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.
Then, add the "[Status] Needs Team Review" label and ask someone from your team review the code. Once reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Mu Wpcom plugin:

  • Next scheduled release: December 5, 2023.
  • Scheduled code freeze: November 27, 2023.

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@valterlorran valterlorran marked this pull request as ready for review October 6, 2023 13:25
@sixhours
Copy link
Contributor

This is working as described! Looks like it needs to be rebased. :)

Screenshot 2023-10-10 at 3 44 16 PM

@valterlorran valterlorran force-pushed the add/launchpad-task-body branch from 2926e77 to 3c6409f Compare October 19, 2023 17:29
@github-actions github-actions bot added the [Plugin] mu wpcom jetpack-mu-wpcom plugin label Oct 19, 2023
@valterlorran valterlorran requested review from sixhours and a team October 19, 2023 17:47
Copy link
Contributor

@daledupreez daledupreez left a 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.

@valterlorran valterlorran force-pushed the add/launchpad-task-body branch from 10edac1 to 4a9ea95 Compare October 31, 2023 17:28
Comment on lines 464 to 482
$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;
Copy link
Contributor

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:

Suggested change
$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;

Copy link
Contributor

This PR has been marked as stale. This happened because:

  • It has been inactive for the past 3 months.
  • It hasn’t been labeled `[Pri] BLOCKER`, `[Pri] High`, etc.

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.

@sixhours
Copy link
Contributor

These are out of date, going to close for now. We can rework this if we decide to try it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants