From 14fa1a4cdc7b9c4665b58fe6a8f296ae5fdc08b7 Mon Sep 17 00:00:00 2001 From: CodeyGuyDylan Date: Fri, 3 Nov 2023 20:09:44 +0000 Subject: [PATCH] Update/vaultpress backup card purchased state (#33927) * Add undo button and activity log * changelog * Update lockfiles * changelog * Fix type declaration * Check backup capabilities * Update projects/packages/my-jetpack/_inc/components/product-cards-section/backup-card/index.jsx Co-authored-by: Bryan Elliott * Fix undo url * Update project version --------- Co-authored-by: Bryan Elliott Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6749603662 --- CHANGELOG.md | 8 +++++++ composer.json | 2 +- src/class-manager.php | 14 +++++++++++ src/class-package-version.php | 2 +- tests/php/test_Manager_unit.php | 42 +++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 263cacd..d6739eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.59.0-alpha] - unreleased + +This is an alpha version! The changes listed here are not final. + +### Added +- Add a method to check if Jetpack is ready for uninstall cleanup. + ## [1.58.3] - 2023-11-03 ### Fixed - Make sure scheme history option is an array. [#33905] @@ -900,6 +907,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Separate the connection library into its own package. +[1.59.0-alpha]: https://github.com/Automattic/jetpack-connection/compare/v1.58.3...v1.59.0-alpha [1.58.3]: https://github.com/Automattic/jetpack-connection/compare/v1.58.2...v1.58.3 [1.58.2]: https://github.com/Automattic/jetpack-connection/compare/v1.58.1...v1.58.2 [1.58.1]: https://github.com/Automattic/jetpack-connection/compare/v1.58.0...v1.58.1 diff --git a/composer.json b/composer.json index 7511e5a..d410051 100644 --- a/composer.json +++ b/composer.json @@ -56,7 +56,7 @@ "link-template": "https://github.com/Automattic/jetpack-connection/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "1.58.x-dev" + "dev-trunk": "1.59.x-dev" } }, "config": { diff --git a/src/class-manager.php b/src/class-manager.php index 88622e7..745e9fa 100644 --- a/src/class-manager.php +++ b/src/class-manager.php @@ -2558,4 +2558,18 @@ public static function get_site_id() { } return (int) $site_id; } + + /** + * Check if Jetpack is ready for uninstall cleanup. + * + * @param string $current_plugin_slug The current plugin's slug. + * + * @return bool + */ + public static function is_ready_for_cleanup( $current_plugin_slug ) { + $active_plugins = get_option( Plugin_Storage::ACTIVE_PLUGINS_OPTION_NAME ); + + return empty( $active_plugins ) || ! is_array( $active_plugins ) + || ( count( $active_plugins ) === 1 && array_key_exists( $current_plugin_slug, $active_plugins ) ); + } } diff --git a/src/class-package-version.php b/src/class-package-version.php index b5b96ac..c22b71a 100644 --- a/src/class-package-version.php +++ b/src/class-package-version.php @@ -12,7 +12,7 @@ */ class Package_Version { - const PACKAGE_VERSION = '1.58.3'; + const PACKAGE_VERSION = '1.59.0-alpha'; const PACKAGE_SLUG = 'connection'; diff --git a/tests/php/test_Manager_unit.php b/tests/php/test_Manager_unit.php index a672aac..8c3d6f7 100644 --- a/tests/php/test_Manager_unit.php +++ b/tests/php/test_Manager_unit.php @@ -643,4 +643,46 @@ public function test_disconnect_site_will_remove_tracked_package_versions() { public function filter_api_constant( $value, $name ) { return constant( __NAMESPACE__ . "\Utils::DEFAULT_$name" ); } + + /** + * Test the `is_ready_for_cleanup()` method with the negative result (has other connected plugins). + * + * @return void + */ + public function test_is_ready_for_cleanup_no() { + $option_filter = function () { + return array( + 'jetpack-backup' => array( + 'name' => 'Jetpack Backup', + ), + ); + }; + + add_filter( 'pre_option_jetpack_connection_active_plugins', $option_filter ); + $is_ready = Manager::is_ready_for_cleanup( 'jetpack' ); + remove_filter( 'pre_option_jetpack_connection_active_plugins', $option_filter ); + + $this->assertFalse( $is_ready ); + } + + /** + * Test the `is_ready_for_cleanup()` method with the positive result (no other connected plugins). + * + * @return void + */ + public function test_is_ready_for_cleanup_yes() { + $option_filter = function () { + return array( + 'jetpack' => array( + 'name' => 'Jetpack', + ), + ); + }; + + add_filter( 'pre_option_jetpack_connection_active_plugins', $option_filter ); + $is_ready = Manager::is_ready_for_cleanup( 'jetpack' ); + remove_filter( 'pre_option_jetpack_connection_active_plugins', $option_filter ); + + $this->assertTrue( $is_ready ); + } }