@@ -12,15 +12,17 @@ import { Select } from '@linode/ui';
1212import * as React from 'react' ;
1313
1414import {
15- PLAN_FILTER_GENERATION_ALL ,
15+ PLAN_FILTER_ALL ,
1616 PLAN_FILTER_GENERATION_G6 ,
1717 PLAN_FILTER_GENERATION_G7 ,
1818 PLAN_FILTER_GENERATION_G8 ,
19- PLAN_FILTER_TYPE_ALL ,
2019 PLAN_FILTER_TYPE_COMPUTE_OPTIMIZED ,
2120 PLAN_FILTER_TYPE_GENERAL_PURPOSE ,
2221} from './constants' ;
23- import { applyPlanFilters , supportsTypeFiltering } from './utils/planFilters' ;
22+ import {
23+ applyDedicatedPlanFilters ,
24+ supportsTypeFiltering ,
25+ } from './utils/planFilters' ;
2426
2527import type {
2628 PlanFilterRenderArgs ,
@@ -31,20 +33,20 @@ import type { PlanFilterGeneration, PlanFilterType } from './types/planFilters';
3133import type { SelectOption } from '@linode/ui' ;
3234
3335const GENERATION_OPTIONS : SelectOption < PlanFilterGeneration > [ ] = [
34- { label : 'All' , value : PLAN_FILTER_GENERATION_ALL } ,
36+ { label : 'All' , value : PLAN_FILTER_ALL } ,
3537 { label : 'G8 Dedicated' , value : PLAN_FILTER_GENERATION_G8 } ,
3638 { label : 'G7 Dedicated' , value : PLAN_FILTER_GENERATION_G7 } ,
3739 { label : 'G6 Dedicated' , value : PLAN_FILTER_GENERATION_G6 } ,
3840] ;
3941
4042const TYPE_OPTIONS_WITH_SUBTYPES : SelectOption < PlanFilterType > [ ] = [
41- { label : 'All' , value : PLAN_FILTER_TYPE_ALL } ,
43+ { label : 'All' , value : PLAN_FILTER_ALL } ,
4244 { label : 'Compute Optimized' , value : PLAN_FILTER_TYPE_COMPUTE_OPTIMIZED } ,
4345 { label : 'General Purpose' , value : PLAN_FILTER_TYPE_GENERAL_PURPOSE } ,
4446] ;
4547
4648const TYPE_OPTIONS_ALL_ONLY : SelectOption < PlanFilterType > [ ] = [
47- { label : 'All' , value : PLAN_FILTER_TYPE_ALL } ,
49+ { label : 'All' , value : PLAN_FILTER_ALL } ,
4850] ;
4951
5052interface DedicatedPlanFiltersComponentProps {
@@ -59,12 +61,10 @@ const DedicatedPlanFiltersComponent = React.memo(
5961 const { disabled = false , onResult, plans, resetPagination } = props ;
6062
6163 // Local state - persists automatically because component stays mounted
62- const [ generation , setGeneration ] = React . useState < PlanFilterGeneration > (
63- PLAN_FILTER_GENERATION_ALL
64- ) ;
64+ const [ generation , setGeneration ] =
65+ React . useState < PlanFilterGeneration > ( PLAN_FILTER_ALL ) ;
6566
66- const [ type , setType ] =
67- React . useState < PlanFilterType > ( PLAN_FILTER_TYPE_ALL ) ;
67+ const [ type , setType ] = React . useState < PlanFilterType > ( PLAN_FILTER_ALL ) ;
6868
6969 const typeFilteringSupported = supportsTypeFiltering ( generation ) ;
7070
@@ -109,11 +109,11 @@ const DedicatedPlanFiltersComponent = React.memo(
109109 // When clearing, default to "All" instead of undefined
110110 const newGeneration =
111111 ( option ?. value as PlanFilterGeneration | undefined ) ??
112- PLAN_FILTER_GENERATION_ALL ;
112+ PLAN_FILTER_ALL ;
113113 setGeneration ( newGeneration ) ;
114114
115115 // Reset type filter when generation changes
116- setType ( PLAN_FILTER_TYPE_ALL ) ;
116+ setType ( PLAN_FILTER_ALL ) ;
117117 } ,
118118 [ ]
119119 ) ;
@@ -124,25 +124,23 @@ const DedicatedPlanFiltersComponent = React.memo(
124124 option : null | SelectOption < number | string >
125125 ) => {
126126 setType (
127- ( option ?. value as PlanFilterType | undefined ) ?? PLAN_FILTER_TYPE_ALL
127+ ( option ?. value as PlanFilterType | undefined ) ?? PLAN_FILTER_ALL
128128 ) ;
129129 } ,
130130 [ ]
131131 ) ;
132132
133133 const filteredPlans = React . useMemo ( ( ) => {
134- const normalizedType = typeFilteringSupported
135- ? type
136- : PLAN_FILTER_TYPE_ALL ;
137- return applyPlanFilters ( plans , generation , normalizedType ) ;
134+ const normalizedType = typeFilteringSupported ? type : PLAN_FILTER_ALL ;
135+ return applyDedicatedPlanFilters ( plans , generation , normalizedType ) ;
138136 } , [ generation , plans , type , typeFilteringSupported ] ) ;
139137
140138 const selectedGenerationOption = React . useMemo ( ( ) => {
141139 return GENERATION_OPTIONS . find ( ( opt ) => opt . value === generation ) ?? null ;
142140 } , [ generation ] ) ;
143141
144142 const selectedTypeOption = React . useMemo ( ( ) => {
145- const displayType = typeFilteringSupported ? type : PLAN_FILTER_TYPE_ALL ;
143+ const displayType = typeFilteringSupported ? type : PLAN_FILTER_ALL ;
146144 return typeOptions . find ( ( opt ) => opt . value === displayType ) ?? null ;
147145 } , [ type , typeFilteringSupported , typeOptions ] ) ;
148146
@@ -155,6 +153,7 @@ const DedicatedPlanFiltersComponent = React.memo(
155153 flexWrap : 'wrap' ,
156154 gap : '19px' ,
157155 marginBottom : 16 ,
156+ marginTop : - 16 ,
158157 } }
159158 >
160159 < Select
@@ -189,7 +188,7 @@ const DedicatedPlanFiltersComponent = React.memo(
189188 return {
190189 filteredPlans,
191190 filterUI,
192- hasActiveFilters : generation !== PLAN_FILTER_GENERATION_ALL ,
191+ hasActiveFilters : generation !== PLAN_FILTER_ALL ,
193192 } ;
194193 } , [
195194 disabled ,
0 commit comments