Skip to content

Commit

Permalink
Add launchpad checklist for sites created in the hosting flow. (#33698)
Browse files Browse the repository at this point in the history
* add hosting flow home checklist tasks

* add function to mark plugin installed

* add changelog

* mark theme selected

* mark ssh checklist complete when ssh user is added

* correct task name

* use action to determine ssh setup

* use a8c ssh added hook

* show checklist for only newer sites

* add site montioring checklist

* fix plugin callback function

* add filter to enable hosting checklist

* do not show site title task as title is set in onboarding flow

* prevent theme checklist item from being completed with initial site creation.

* fix type

* fix version

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6673888245
  • Loading branch information
vykes-mac authored and matticbot committed Oct 28, 2023
1 parent 1651703 commit b14ff59
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 10 deletions.
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/automattic/jetpack-mu-wpcom/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

This is an alpha version! The changes listed here are not final.

### Added
- Add launchpad checklist for host-site intent

### Fixed
- Disable fullscreen launchpad when completing the site_launched task

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,44 @@ function wpcom_launchpad_get_task_definitions() {
return '/earn/payments-plans/' . $data['site_slug_encoded'];
},
),

// Hosting flow tasks
'site_theme_selected' => array(
'get_title' => function () {
return __( 'Choose a theme', 'jetpack-mu-wpcom' );
},
'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed',
'get_calypso_path' => function ( $task, $default, $data ) {
return '/themes/' . $data['site_slug_encoded'];
},
),
'install_custom_plugin' => array(
'get_title' => function () {
return __( 'Install a custom plugin', 'jetpack-mu-wpcom' );
},
'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed',
'get_calypso_path' => function ( $task, $default, $data ) {
return '/plugins/' . $data['site_slug_encoded'];
},
),
'setup_ssh' => array(
'get_title' => function () {
return __( 'Set up ssh', 'jetpack-mu-wpcom' );
},
'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed',
'get_calypso_path' => function ( $task, $default, $data ) {
return '/hosting-config/' . $data['site_slug_encoded'] . '#sftp-credentials';
},
),
'site_monitoring_page' => array(
'get_title' => function () {
return __( 'View site metrics', 'jetpack-mu-wpcom' );
},
'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed',
'get_calypso_path' => function ( $task, $default, $data ) {
return '/site-monitoring/' . $data['site_slug_encoded'];
},
),
);

$extended_task_definitions = apply_filters( 'wpcom_launchpad_extended_task_definitions', array() );
Expand Down Expand Up @@ -1829,3 +1867,31 @@ function wpcom_trigger_email_campaign() {
);
}
add_action( 'update_option_launchpad_checklist_tasks_statuses', 'wpcom_trigger_email_campaign', 10, 3 );

/**
* Mark task complete when plugin is installed.
*/
function wpcom_launchpad_mark_plugin_installed_complete() {
if ( wpcom_launchpad_is_task_option_completed( array( 'id' => 'install_custom_plugin' ) ) ) {
return;
}
wpcom_mark_launchpad_task_complete( 'install_custom_plugin' );
}
add_action( 'jetpack_plugin_installed', 'wpcom_launchpad_mark_plugin_installed_complete', 10 );

/**
* Mark task complete when theme is selected.
*
* @param array $new_theme The new theme object.
* @param array $old_theme The old theme object.
*/
function wpcom_launchpad_mark_theme_selected_complete( $new_theme, $old_theme ) {
// This hook runs when site just gets setup, lets prevent checklist item from being complete
// when the theme is the same.
$is_same_theme = $new_theme['name'] === $old_theme['name'];
if ( wpcom_launchpad_is_task_option_completed( array( 'id' => 'site_theme_selected' ) ) || $is_same_theme ) {
return;
}
wpcom_mark_launchpad_task_complete( 'site_theme_selected' );
}
add_action( 'jetpack_sync_current_theme_support', 'wpcom_launchpad_mark_theme_selected_complete', 10, 2 );
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ function wpcom_launchpad_get_task_list_definitions() {
),
'is_enabled_callback' => '__return_true',
),
'host-site' => array(
'title' => 'Hosting Flow',
'task_ids' => array(
'site_theme_selected',
'install_custom_plugin',
'setup_ssh',
'verify_email',
'site_monitoring_page',
'site_launched',
),
'is_enabled_callback' => 'wpcom_launchpad_is_hosting_flow_enabled',
),
);

$extended_task_list_definitions = apply_filters( 'wpcom_launchpad_extended_task_list_definitions', array() );
Expand Down Expand Up @@ -886,6 +898,15 @@ function wpcom_launchpad_is_keep_building_enabled() {
return false;
}

/**
* Checks if the hosting flow task list is enabled.
*
* @return bool True if the task list is enabled, false otherwise.
*/
function wpcom_launchpad_is_hosting_flow_enabled() {
return apply_filters( 'is_launchpad_intent_hosting_enabled', false );
}

/**
* Checks if the Blog flow task list is enabled.
*
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"packages": [
{
"name": "automattic/jetpack-mu-wpcom",
"version": "4.16.0-alpha.1698418407",
"version_normalized": "4.16.0.0-alpha1698418407",
"version": "4.16.0-alpha.1698456072",
"version_normalized": "4.16.0.0-alpha1698456072",
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-mu-wpcom",
"reference": "9eda45c06b7bab7c0f29aa05cdcfc89fff0212a9"
"reference": "16bfb3a9b73953eaf5f35de276fd0b04f934490d"
},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.11",
Expand Down
6 changes: 3 additions & 3 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
),
'versions' => array(
'automattic/jetpack-mu-wpcom' => array(
'pretty_version' => '4.16.0-alpha.1698418407',
'version' => '4.16.0.0-alpha1698418407',
'reference' => '9eda45c06b7bab7c0f29aa05cdcfc89fff0212a9',
'pretty_version' => '4.16.0-alpha.1698456072',
'version' => '4.16.0.0-alpha1698456072',
'reference' => '16bfb3a9b73953eaf5f35de276fd0b04f934490d',
'type' => 'jetpack-library',
'install_path' => __DIR__ . '/../automattic/jetpack-mu-wpcom',
'aliases' => array(),
Expand Down

0 comments on commit b14ff59

Please sign in to comment.