-
Notifications
You must be signed in to change notification settings - Fork 800
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
Protect: React Query #39036
Merged
Merged
Protect: React Query #39036
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
projects/plugins/protect/changelog/add-protect-tanstack-query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: added | ||
Comment: Added react query, no user-facing impact. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ | |
namespace Automattic\Jetpack\Protect; | ||
|
||
use Automattic\Jetpack\Connection\Rest_Authentication as Connection_Rest_Authentication; | ||
use Automattic\Jetpack\IP\Utils as IP_Utils; | ||
use Automattic\Jetpack\Protect_Status\REST_Controller as Protect_Status_REST_Controller; | ||
use Automattic\Jetpack\Waf\Waf_Runner; | ||
use Automattic\Jetpack\Waf\Waf_Stats; | ||
use Jetpack_Protect; | ||
use WP_Error; | ||
use WP_REST_Request; | ||
|
@@ -239,7 +241,7 @@ public static function api_ignore_threat( $request ) { | |
$threat_ignored = Threats::ignore_threat( $request['threat_id'] ); | ||
|
||
if ( ! $threat_ignored ) { | ||
return new WP_REST_Response( 'An error occured while attempting to ignore the threat.', 500 ); | ||
return new WP_REST_Response( 'An error occurred while attempting to ignore the threat.', 500 ); | ||
} | ||
|
||
return new WP_REST_Response( 'Threat ignored.' ); | ||
|
@@ -260,7 +262,7 @@ public static function api_unignore_threat( $request ) { | |
$threat_ignored = Threats::unignore_threat( $request['threat_id'] ); | ||
|
||
if ( ! $threat_ignored ) { | ||
return new WP_REST_Response( 'An error occured while attempting to unignore the threat.', 500 ); | ||
return new WP_REST_Response( 'An error occurred while attempting to unignore the threat.', 500 ); | ||
} | ||
|
||
return new WP_REST_Response( 'Threat unignored.' ); | ||
|
@@ -281,7 +283,7 @@ public static function api_fix_threats( $request ) { | |
$threats_fixed = Threats::fix_threats( $request['threat_ids'] ); | ||
|
||
if ( ! $threats_fixed ) { | ||
return new WP_REST_Response( 'An error occured while attempting to fix the threat.', 500 ); | ||
return new WP_REST_Response( 'An error occurred while attempting to fix the threat.', 500 ); | ||
} | ||
|
||
return new WP_REST_Response( $threats_fixed ); | ||
|
@@ -302,7 +304,7 @@ public static function api_fix_threats_status( $request ) { | |
$threats_fixed = Threats::fix_threats_status( $request['threat_ids'] ); | ||
|
||
if ( ! $threats_fixed ) { | ||
return new WP_REST_Response( 'An error occured while attempting to get the fixer status of the threats.', 500 ); | ||
return new WP_REST_Response( 'An error occurred while attempting to get the fixer status of the threats.', 500 ); | ||
} | ||
|
||
return new WP_REST_Response( $threats_fixed ); | ||
|
@@ -317,7 +319,7 @@ public static function api_check_credentials() { | |
$credential_array = Credentials::get_credential_array(); | ||
|
||
if ( ! isset( $credential_array ) ) { | ||
return new WP_REST_Response( 'An error occured while attempting to fetch the credentials array', 500 ); | ||
return new WP_REST_Response( 'An error occurred while attempting to fetch the credentials array', 500 ); | ||
} | ||
|
||
return new WP_REST_Response( $credential_array ); | ||
|
@@ -332,7 +334,7 @@ public static function api_scan() { | |
$scan_enqueued = Threats::scan(); | ||
|
||
if ( ! $scan_enqueued ) { | ||
return new WP_REST_Response( 'An error occured while attempting to enqueue the scan.', 500 ); | ||
return new WP_REST_Response( 'An error occurred while attempting to enqueue the scan.', 500 ); | ||
} | ||
|
||
return new WP_REST_Response( 'Scan enqueued.' ); | ||
|
@@ -349,7 +351,7 @@ public static function api_toggle_waf() { | |
if ( ! $disabled ) { | ||
return new WP_Error( | ||
'waf_disable_failed', | ||
__( 'An error occured disabling the firewall.', 'jetpack-protect' ), | ||
__( 'An error occurred disabling the firewall.', 'jetpack-protect' ), | ||
array( 'status' => 500 ) | ||
); | ||
} | ||
|
@@ -361,7 +363,7 @@ public static function api_toggle_waf() { | |
if ( ! $enabled ) { | ||
return new WP_Error( | ||
'waf_enable_failed', | ||
__( 'An error occured enabling the firewall.', 'jetpack-protect' ), | ||
__( 'An error occurred enabling the firewall.', 'jetpack-protect' ), | ||
array( 'status' => 500 ) | ||
); | ||
} | ||
|
@@ -380,10 +382,15 @@ public static function api_get_waf() { | |
|
||
return new WP_REST_Response( | ||
array( | ||
'is_seen' => Jetpack_Protect::get_waf_seen_status(), | ||
'is_enabled' => Waf_Runner::is_enabled(), | ||
'config' => Waf_Runner::get_config(), | ||
'stats' => Jetpack_Protect::get_waf_stats(), | ||
'wafSupported' => Waf_Runner::is_supported_environment(), | ||
'currentIp' => IP_Utils::get_ip(), | ||
'isSeen' => Jetpack_Protect::get_waf_seen_status(), | ||
'upgradeIsSeen' => Jetpack_Protect::get_waf_upgrade_seen_status(), | ||
'displayUpgradeBadge' => Jetpack_Protect::get_waf_upgrade_badge_display_status(), | ||
'isEnabled' => Waf_Runner::is_enabled(), | ||
'config' => Waf_Runner::get_config(), | ||
'stats' => Jetpack_Protect::get_waf_stats(), | ||
'globalStats' => Waf_Stats::get_global_stats(), | ||
Comment on lines
+385
to
+393
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensuring the "waf" API endpoint returns the same data as the initial state "waf" property. |
||
) | ||
); | ||
} | ||
|
@@ -449,7 +456,7 @@ public static function api_complete_onboarding_steps( $request ) { | |
$completed = Onboarding::complete_steps( $request['step_ids'] ); | ||
|
||
if ( ! $completed ) { | ||
return new WP_REST_Response( 'An error occured completing the onboarding step(s).', 500 ); | ||
return new WP_REST_Response( 'An error occurred completing the onboarding step(s).', 500 ); | ||
} | ||
|
||
return new WP_REST_Response( 'Onboarding step(s) completed.' ); | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Adding credentials to the initial state allows us to access them immediately without an async request in the front end.