Restore client-side search where needed.

This commit is contained in:
Maxime-J 2024-04-15 07:45:56 +00:00
parent 1579beef5b
commit fe9db71ba8
5 changed files with 15 additions and 1 deletions

View file

@ -42,6 +42,7 @@ export function CountriesTable({
metric={formatMessage(labels.visitors)}
renderLabel={renderLink}
onDataLoad={handleDataLoad}
searchFormattedValues={true}
/>
);
}

View file

@ -27,6 +27,7 @@ export function DevicesTable(props: MetricsTableProps) {
type="device"
metric={formatMessage(labels.visitors)}
renderLabel={renderLink}
searchFormattedValues={true}
/>
);
}

View file

@ -24,6 +24,7 @@ export function LanguagesTable({
metric={formatMessage(labels.visitors)}
onDataLoad={data => onDataLoad?.(percentFilter(data))}
renderLabel={renderLabel}
searchFormattedValues={true}
/>
);
}

View file

@ -28,6 +28,7 @@ export interface MetricsTableProps extends ListTableProps {
onDataLoad?: (data: any) => void;
onSearch?: (search: string) => void;
allowSearch?: boolean;
searchFormattedValues?: boolean;
children?: ReactNode;
}
@ -40,6 +41,7 @@ export function MetricsTable({
onDataLoad,
delay = null,
allowSearch = false,
searchFormattedValues = false,
children,
...props
}: MetricsTableProps) {
@ -69,7 +71,7 @@ export function MetricsTable({
region,
city,
limit,
search,
search: (searchFormattedValues) ? undefined : search,
},
{ retryDelay: delay || DEFAULT_ANIMATION_DURATION, onDataLoad },
);
@ -88,6 +90,14 @@ export function MetricsTable({
}
}
if (searchFormattedValues && search) {
items = items.filter(({ x, ...data }) => {
const value = formatValue(x, type, data);
return value?.toLowerCase().includes(search.toLowerCase());
});
}
items = percentFilter(items);
return items;

View file

@ -35,6 +35,7 @@ export function RegionsTable(props: MetricsTableProps) {
metric={formatMessage(labels.visitors)}
dataFilter={emptyFilter}
renderLabel={renderLink}
searchFormattedValues={true}
/>
);
}