Adds a client-side status filter (All / Active / Inactive / No connection) to the Providers page, applied over the already-fetched provider + connection list. Status derives from getProviderStats (total, allDisabled); noAuth providers count as Active. Filter composes with the existing search across all provider sections. Part of #3699.
20 lines
742 B
JavaScript
20 lines
742 B
JavaScript
export const STATUS_FILTER_OPTIONS = [
|
|
{ value: "all", label: "All" },
|
|
{ value: "active", label: "Active" },
|
|
{ value: "inactive", label: "Inactive" },
|
|
{ value: "none", label: "No connection" },
|
|
];
|
|
|
|
// noAuth providers (e.g. free proxies) are always usable even though they
|
|
// never have a stored connection record, so they never fall into "none".
|
|
export function getConnectionStatus(stats, isNoAuth = false) {
|
|
if (isNoAuth) return "active";
|
|
if (!stats || stats.total === 0) return "none";
|
|
return stats.allDisabled ? "inactive" : "active";
|
|
}
|
|
|
|
export function matchesStatusFilter(statusFilter, stats, isNoAuth = false) {
|
|
if (statusFilter === "all") return true;
|
|
return getConnectionStatus(stats, isNoAuth) === statusFilter;
|
|
}
|