-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protect: Update use fixers query error prop handling (#39498)
* Update FixerStatus type to account for potential error props * changelog * Handle error responses * Only handle top level errors in useFixersQuery, threat level errors are handled in the completion block * Add clarifying comment * Improve fixer types * Fix prop handling * Update useFixers hook for compatibility with type updates * Remove optional chaining where applicable, update logic to rely on TS types * Update types * Fix type error --------- Co-authored-by: Nate Weller <[email protected]>
- Loading branch information
1 parent
738e909
commit fdcd55e
Showing
5 changed files
with
102 additions
and
38 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/plugins/protect/changelog/update-protect-use-fixers-response-error-prop-handling
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,4 @@ | ||
Significance: patch | ||
Type: changed | ||
|
||
Adds handling for FixerStatus error props |
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
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 |
---|---|---|
@@ -1,13 +1,40 @@ | ||
export type FixerStatus = 'not_started' | 'in_progress' | 'fixed' | 'not_fixed'; | ||
|
||
export type FixersStatus = { | ||
ok: boolean; | ||
threats: { | ||
[ key: number ]: ThreatFixStatus; | ||
}; | ||
/** | ||
* Threat Fix Status | ||
* | ||
* Individual fixer status for a threat. | ||
*/ | ||
export type ThreatFixStatusError = { | ||
error: string; | ||
}; | ||
|
||
export type ThreatFixStatus = { | ||
export type ThreatFixStatusSuccess = { | ||
status: FixerStatus; | ||
last_updated: string; | ||
}; | ||
|
||
export type ThreatFixStatus = ThreatFixStatusError | ThreatFixStatusSuccess; | ||
|
||
/** | ||
* Fixers Status | ||
* | ||
* Overall status of all fixers. | ||
*/ | ||
type FixersStatusBase = { | ||
ok: boolean; // Discriminator for overall success | ||
}; | ||
|
||
export type FixersStatusError = FixersStatusBase & { | ||
ok: false; | ||
error: string; | ||
}; | ||
|
||
export type FixersStatusSuccess = FixersStatusBase & { | ||
ok: true; | ||
threats: { | ||
[ key: number ]: ThreatFixStatus; | ||
}; | ||
}; | ||
|
||
export type FixersStatus = FixersStatusSuccess | FixersStatusError; |