diff --git a/projects/js-packages/components/components/threats-data-views/index.tsx b/projects/js-packages/components/components/threats-data-views/index.tsx index 3bb690cb42f6f..dbba9e3219313 100644 --- a/projects/js-packages/components/components/threats-data-views/index.tsx +++ b/projects/js-packages/components/components/threats-data-views/index.tsx @@ -124,9 +124,9 @@ export default function ThreatsDataViews( { isThreatEligibleForFix?: ( threat: Threat ) => boolean; isThreatEligibleForIgnore?: ( threat: Threat ) => boolean; isThreatEligibleForUnignore?: ( threat: Threat ) => boolean; - onFixThreats?: ActionButton< Threat >[ 'callback' ]; - onIgnoreThreats?: ActionButton< Threat >[ 'callback' ]; - onUnignoreThreats?: ActionButton< Threat >[ 'callback' ]; + onFixThreats?: ActionButton< string | number >[ 'callback' ]; + onIgnoreThreats?: ActionButton< string | number >[ 'callback' ]; + onUnignoreThreats?: ActionButton< string | number >[ 'callback' ]; } ): JSX.Element { const baseView = { sort: { @@ -486,13 +486,21 @@ export default function ThreatsDataViews( { id: 'fix', label: __( 'Auto-fix', 'jetpack' ), supportsBulk: true, - callback: items => onFixThreats( items.map( item => item.id ) ), + callback: items => + onFixThreats( + items.map( item => item.id ), + null // TODO: is context: { registry: any, onActionPerformed?: ... } prop necessary? + ), isEligible( item ) { + // TODO: Account for this here, or in isThreatEligibleForFix? + if ( item.fixer?.status !== 'not_started' ) { + return false; + } + if ( ! onFixThreats ) { return false; } if ( isThreatEligibleForFix ) { - // TODO: Should not be able to bulk select or individually select threats with in_progress/errored fixers return isThreatEligibleForFix( item ); } return !! item.fixable; @@ -504,8 +512,17 @@ export default function ThreatsDataViews( { result.push( { id: 'ignore', label: __( 'Ignore', 'jetpack' ), - callback: items => onIgnoreThreats( items.map( item => item.id ) ), + callback: items => + onIgnoreThreats( + items.map( item => item.id ), + null // TODO: is context: { registry: any, onActionPerformed?: ... } prop necessary? + ), isEligible( item ) { + // TODO: Account for this here, or in isThreatEligibleForIgnore? + if ( item.fixer?.status !== 'not_started' ) { + return false; + } + if ( ! onIgnoreThreats ) { return false; } @@ -521,7 +538,11 @@ export default function ThreatsDataViews( { result.push( { id: 'un-ignore', label: __( 'Unignore', 'jetpack' ), - callback: items => onUnignoreThreats( items.map( item => item.id ) ), + callback: items => + onUnignoreThreats( + items.map( item => item.id ), + null // TODO: is context: { registry: any, onActionPerformed?: ... } prop necessary? + ), isEligible( item ) { if ( ! onUnignoreThreats ) { return false; diff --git a/projects/js-packages/components/components/threats-data-views/stories/index.stories.tsx b/projects/js-packages/components/components/threats-data-views/stories/index.stories.tsx index 9ba8dbdebaf6e..84d9e35e00424 100644 --- a/projects/js-packages/components/components/threats-data-views/stories/index.stories.tsx +++ b/projects/js-packages/components/components/threats-data-views/stories/index.stories.tsx @@ -120,7 +120,7 @@ Default.args = { file: '/var/www/html/wp-admin/index.php', extensionStatus: '', }, - fixer: null, + fixer: { status: 'not_started' }, filename: '/var/www/html/wp-admin/index.php', diff: "--- /tmp/wordpress/6.6.2/wordpress/wp-admin/index.php\t2024-10-07 20:40:04.887546480 +0000\n+++ /var/www/html/wp-admin/index.php\t2024-10-07 20:39:58.775512965 +0000\n@@ -210,3 +210,4 @@\n wp_print_community_events_templates();\n \n require_once ABSPATH . 'wp-admin/admin-footer.php';\n+if ( true === false ) exit();\n\\ No newline at end of file\n", },