-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protect: Update fixer UI to handle long running fixers (#39301)
* Protect: React Query changelog changelog * Add fixerStatus to initial state * changelog * Fix in_progress fixer state * Fix tests * Fix fixThreats apiFetch call * Do not camelize fixerStatus in useFixersQuery initialData * Protect: React Query changelog changelog * Use fixableThreats prop from scan status * Protect: React Query changelog changelog * Protect: React Query * Fix merge errors * Ensure fixer status polling occurs when in_progress fixers exist * Protect: React Query * Invalidate scan status query on fixer status query success * Protect: React Query * Provide useFixersQuery threatIds default value * Protect: React Query * Reorder * Account for fixerStatus being false in useFixers hook * Protect: React Query * Temporarily disable optimistically setting fixer status * Protect: React Query * Simplify QUERY_FIXERS_KEY, and update setQueryData return formatting * Fixes and improvements * Protect: React Query * Update fixerInProgress logic * Conflict corrections * Fix fixInProgressThreatIds logic * Fix fixable_threat_ids type * Update property name * Fix useFixersQuery cachedData check logic * Protect: React Query * Protect: React Query * Protect: React Query * Handle fixer status optimistically * Add removed comment * Remove file * Fix types * Fix docblocks * Revert unintended changes * Protect: React Query * changelog * Handle long running fixers * Improve setting fixer status optimistically * Handle possible API returns * Handle statuses for nonexistent fixers * Filter fixable threats list for fix all threats modal * Fixes and improvements to existing code * Disable threat actions when fixer is stale * Changelog entry * Revert fixers mutation update * Improve use fixers query error handling * Update notice message * Readd removed comment * Fix naming * Update initial state default * Update initial state default * Ensure FixerStatus type matches response structure * Fix typo * Fix logic - fixer cannot be active and stale * Improvements * Improve useFixersQuery * Add comments * Apply dummy arg to avoid bad minification issues * Use clsx for conditional class names * Use memoized value for fixableList * Remove memoization of date * Remove memoization of initial query data from window * Centralize fixer logic and attempt to simplify the hook implementation * Fix syntax errors * Move stale fixer check to top of renderFixerStatus logic --------- Co-authored-by: Nate Weller <[email protected]>
- Loading branch information
1 parent
469ba8e
commit cec62c8
Showing
13 changed files
with
323 additions
and
185 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/plugins/protect/changelog/update-protect-fixer-ui-to-handle-long-running-fixers
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: minor | ||
Type: added | ||
|
||
Adds handling for long running fixers |
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
51 changes: 51 additions & 0 deletions
51
projects/plugins/protect/src/js/components/icon-tooltip/index.jsx
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,51 @@ | ||
import { Text } from '@automattic/jetpack-components'; | ||
import { Icon, Popover } from '@wordpress/components'; | ||
import React, { useCallback, useState } from 'react'; | ||
import styles from './styles.module.scss'; | ||
|
||
const IconTooltip = ( { icon, iconClassName, iconSize, popoverPosition = 'top', text } ) => { | ||
const [ showPopover, setShowPopover ] = useState( false ); | ||
const [ timeoutId, setTimeoutId ] = useState( null ); | ||
|
||
const handleEnter = useCallback( () => { | ||
// Clear any existing timeout if user hovers back quickly | ||
if ( timeoutId ) { | ||
clearTimeout( timeoutId ); | ||
setTimeoutId( null ); | ||
} | ||
setShowPopover( true ); | ||
}, [ timeoutId ] ); | ||
|
||
const handleOut = useCallback( () => { | ||
// Set a timeout to delay the hiding of the popover | ||
const id = setTimeout( () => { | ||
setShowPopover( false ); | ||
setTimeoutId( null ); // Clear the timeout ID after the popover is hidden | ||
}, 100 ); | ||
|
||
setTimeoutId( id ); | ||
}, [] ); | ||
|
||
return ( | ||
<div | ||
className={ styles[ 'icon-popover' ] } | ||
onMouseLeave={ handleOut } | ||
onMouseEnter={ handleEnter } | ||
onClick={ handleEnter } | ||
onFocus={ handleEnter } | ||
onBlur={ handleOut } | ||
role="presentation" | ||
> | ||
<Icon className={ iconClassName } icon={ icon } size={ iconSize } /> | ||
{ showPopover && ( | ||
<Popover noArrow={ false } offset={ 5 } inline={ true } position={ popoverPosition }> | ||
<Text className={ styles[ 'popover-text' ] } variant={ 'body-small' }> | ||
{ text } | ||
</Text> | ||
</Popover> | ||
) } | ||
</div> | ||
); | ||
}; | ||
|
||
export default IconTooltip; |
11 changes: 11 additions & 0 deletions
11
projects/plugins/protect/src/js/components/icon-tooltip/styles.module.scss
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,11 @@ | ||
.icon-popover { | ||
display: flex; | ||
margin-left: calc( var( --spacing-base ) / 2 ); // 4px | ||
fill: var( --jp-gray-20 ); | ||
} | ||
|
||
.popover-text { | ||
width: 250px; | ||
padding: calc( var( --spacing-base ) * 2 ); // 16px | ||
cursor: default; | ||
} |
Oops, something went wrong.