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)} metric={formatMessage(labels.visitors)}
renderLabel={renderLink} renderLabel={renderLink}
onDataLoad={handleDataLoad} onDataLoad={handleDataLoad}
searchFormattedValues={true}
/> />
); );
} }

View file

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

View file

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

View file

@ -28,6 +28,7 @@ export interface MetricsTableProps extends ListTableProps {
onDataLoad?: (data: any) => void; onDataLoad?: (data: any) => void;
onSearch?: (search: string) => void; onSearch?: (search: string) => void;
allowSearch?: boolean; allowSearch?: boolean;
searchFormattedValues?: boolean;
children?: ReactNode; children?: ReactNode;
} }
@ -40,6 +41,7 @@ export function MetricsTable({
onDataLoad, onDataLoad,
delay = null, delay = null,
allowSearch = false, allowSearch = false,
searchFormattedValues = false,
children, children,
...props ...props
}: MetricsTableProps) { }: MetricsTableProps) {
@ -69,7 +71,7 @@ export function MetricsTable({
region, region,
city, city,
limit, limit,
search, search: (searchFormattedValues) ? undefined : search,
}, },
{ retryDelay: delay || DEFAULT_ANIMATION_DURATION, onDataLoad }, { 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); items = percentFilter(items);
return items; return items;

View file

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