Skip to content

Commit 010b2c1

Browse files
committed
Remove unneeded filter handling
1 parent 8bd4c21 commit 010b2c1

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

projects/js-packages/components/components/threats-data-views/index.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import { dateI18n } from '@wordpress/date';
1515
import { __ } from '@wordpress/i18n';
1616
import { Icon } from '@wordpress/icons';
17-
import { useCallback, useMemo, useState, useEffect } from 'react';
17+
import { useCallback, useMemo, useState } from 'react';
1818
import Badge from '../badge';
1919
import ThreatFixerButton from '../threat-fixer-button';
2020
import ThreatSeverityBadge from '../threat-severity-badge';
@@ -55,7 +55,6 @@ import ThreatsStatusToggleGroupControl from './threats-status-toggle-group-contr
5555
* @param {Function} props.isThreatEligibleForFix - Function to determine if a threat is eligible for fixing.
5656
* @param {Function} props.isThreatEligibleForIgnore - Function to determine if a threat is eligible for ignoring.
5757
* @param {Function} props.isThreatEligibleForUnignore - Function to determine if a threat is eligible for unignoring.
58-
* @param {Function} props.onStatusFilterChange - Callback function run when the status filter changes.
5958
*
6059
* @return {JSX.Element} The ThreatsDataViews component.
6160
*/
@@ -69,7 +68,6 @@ export default function ThreatsDataViews( {
6968
onFixThreats,
7069
onIgnoreThreats,
7170
onUnignoreThreats,
72-
onStatusFilterChange,
7371
}: {
7472
data: Threat[];
7573
filters?: Filter[];
@@ -80,7 +78,6 @@ export default function ThreatsDataViews( {
8078
onFixThreats?: ( threats: Threat[] ) => void;
8179
onIgnoreThreats?: ActionButton< Threat >[ 'callback' ];
8280
onUnignoreThreats?: ActionButton< Threat >[ 'callback' ];
83-
onStatusFilterChange?: ( newStatus: 'active' | 'historic' | null ) => void;
8481
} ): JSX.Element {
8582
const baseView = {
8683
sort: {
@@ -535,11 +532,6 @@ export default function ThreatsDataViews( {
535532
*/
536533
const getItemId = useCallback( ( item: Threat ) => item.id.toString(), [] );
537534

538-
// Notify the consumer whenever the selectedStatusFilter changes
539-
useEffect( () => {
540-
onStatusFilterChange?.( selectedStatusFilter );
541-
}, [ selectedStatusFilter, onStatusFilterChange ] );
542-
543535
return (
544536
<DataViews
545537
actions={ actions }

projects/plugins/protect/src/js/routes/scan/index.jsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AdminSection, Container, Col } from '@automattic/jetpack-components';
2-
import { useMemo, useState, useCallback } from 'react';
2+
import { useMemo, useState } from 'react';
33
import { useLocation, useParams } from 'react-router-dom';
44
import AdminPage from '../../components/admin-page';
55
import OnboardingPopover from '../../components/onboarding-popover';
@@ -8,7 +8,6 @@ import useScanStatusQuery, { isScanInProgress } from '../../data/scan/use-scan-s
88
import useAnalyticsTracks from '../../hooks/use-analytics-tracks';
99
import { OnboardingContext } from '../../hooks/use-onboarding';
1010
import usePlan from '../../hooks/use-plan';
11-
import HistoryAdminSectionHero from './history-admin-section-hero';
1211
import onboardingSteps from './onboarding-steps';
1312
import ScanAdminSectionHero from './scan-admin-section-hero';
1413
import ScanResultsDataView from './scan-results-data-view';
@@ -29,11 +28,6 @@ const ScanPage = () => {
2928
const { data: history } = useHistoryQuery();
3029

3130
const [ scanResultsAnchor, setScanResultsAnchor ] = useState( null );
32-
const [ statusFilter, setStatusFilter ] = useState( 'active' );
33-
34-
const handleStatusFilterChange = useCallback( newStatusFilter => {
35-
setStatusFilter( newStatusFilter );
36-
}, [] );
3731

3832
let currentScanStatus;
3933
if ( status.error ) {
@@ -80,11 +74,7 @@ const ScanPage = () => {
8074
return (
8175
<OnboardingContext.Provider value={ onboardingSteps }>
8276
<AdminPage>
83-
{ 'historic' === statusFilter ? (
84-
<HistoryAdminSectionHero />
85-
) : (
86-
<ScanAdminSectionHero size={ showResults ? 'normal' : 'large' } />
87-
) }
77+
<ScanAdminSectionHero size={ showResults ? 'normal' : 'large' } />
8878
{ showResults && (
8979
<AdminSection>
9080
<Container
@@ -94,10 +84,7 @@ const ScanPage = () => {
9484
>
9585
<Col>
9686
<div ref={ setScanResultsAnchor }>
97-
<ScanResultsDataView
98-
filters={ filters }
99-
onStatusFilterChange={ hasPlan ? handleStatusFilterChange : null }
100-
/>
87+
<ScanResultsDataView filters={ filters } />
10188
</div>
10289
{ !! status && ! isScanInProgress( status ) && (
10390
<OnboardingPopover

projects/plugins/protect/src/js/routes/scan/scan-results-data-view.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@ import useModal from '../../hooks/use-modal';
88
/**
99
* Scan Results Data View
1010
*
11-
* @param {object} props - Component props.
12-
* @param {Array} props.filters - Default filters to apply to the data view.
13-
* @param {Function} props.onStatusFilterChange - Callback function to handle status filter changes.
11+
* @param {object} props - Component props.
12+
* @param {Array} props.filters - Default filters to apply to the data view.
1413
*
1514
* @return {JSX.Element} ScanResultDataView component.
1615
*/
1716
export default function ScanResultsDataView( {
1817
filters = [],
19-
onStatusFilterChange,
2018
}: {
2119
filters: React.ComponentProps< typeof ThreatsDataViews >[ 'filters' ];
22-
onStatusFilterChange: ( newStatus: 'active' | 'historic' | null ) => void;
2320
} ) {
2421
const { setModal } = useModal();
2522

@@ -54,7 +51,6 @@ export default function ScanResultsDataView( {
5451
onFixThreats={ onFixThreats }
5552
onIgnoreThreats={ onIgnoreThreats }
5653
onUnignoreThreats={ onUnignoreThreats }
57-
onStatusFilterChange={ onStatusFilterChange }
5854
/>
5955
);
6056
}

0 commit comments

Comments
 (0)