Skip to content

Commit

Permalink
feat(SupportedDeviceTable): Add excludeIf and includeIf props
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Dec 14, 2023
1 parent b87f5e4 commit a80f1b7
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface SupportedDeviceContentProps {
filters: DeviceModelFilters
manufacturers: string[] | null
excludedManufacturers: string[]
includeIf: string[] | null
excludeIf: string[]
}

export function SupportedDeviceContent({
Expand All @@ -23,13 +25,17 @@ export function SupportedDeviceContent({
filters,
manufacturers,
excludedManufacturers,
includeIf,
excludeIf,
}: SupportedDeviceContentProps): JSX.Element | null {
const { deviceModels, isLoading, isError, refetch } = useFilteredDeviceModels(
{
filterValue,
filters,
manufacturers,
excludedManufacturers,
includeIf,
excludeIf,
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const props: ElementProps<SupportedDeviceTableProps> = {
disableFilter: 'boolean',
manufacturers: 'array',
excludedManufacturers: 'array',
includeIf: 'array',
excludeIf: 'array',
}

export { SupportedDeviceTable as Component } from './SupportedDeviceTable.js'
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface SupportedDeviceTableProps extends CommonProps {
disableFilter?: boolean
manufacturers?: string[] | null
excludedManufacturers?: string[]
includeIf?: string[] | null
excludeIf?: string[]
}

export const NestedSupportedDeviceTable =
Expand All @@ -24,6 +26,8 @@ export function SupportedDeviceTable({
disableFilter = false,
manufacturers = null,
excludedManufacturers = [],
includeIf = null,
excludeIf = [],
className,
}: SupportedDeviceTableProps = {}): JSX.Element {
useComponentTelemetry('SupportedDeviceTable')
Expand Down Expand Up @@ -59,6 +63,8 @@ export function SupportedDeviceTable({
filters={filters}
manufacturers={manufacturers}
excludedManufacturers={excludedManufacturers}
includeIf={includeIf}
excludeIf={excludeIf}
/>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,26 @@ export interface DeviceModelFilters {
export const useFilteredDeviceModels = ({
filterValue,
filters,
includeIf,
excludeIf,
...manufacturersParams
}: {
filterValue: string
filters: DeviceModelFilters
manufacturers: string[] | null
excludedManufacturers: string[]
includeIf: string[] | null
excludeIf: string[]
}): ReturnType<typeof useDeviceModels> => {
const { manufacturers } = useFilteredManufacturers(manufacturersParams)

const params: UseDeviceModelsParams = {}
const params: UseDeviceModelsParams = {
exclude_if: excludeIf,
}

if (includeIf != null) {
params.include_if = includeIf
}

if (filterValue.trim() !== '') {
params.text_search = filterValue.trim()
Expand Down

0 comments on commit a80f1b7

Please sign in to comment.