- {table.getColumn("action") && actionOptions.length > 0 && (
-
- )}
{table.getColumn("actorType") && actorTypeOptions.length > 0 && (
+ )}
+ {table.getColumn("action") && actionOptions.length > 0 && (
+
)}
{table.getColumn("entityType") && entityTypeOptions.length > 0 && (
@@ -67,6 +69,7 @@ export function AuditLogsDataTableToolbar({
column={table.getColumn("entityType")}
title="Entity type"
options={entityTypeOptions}
+ icon={Database}
/>
)}
{isFiltered && (
diff --git a/apps/dashboard/src/components/data-table/monitors/data-table-toolbar.tsx b/apps/dashboard/src/components/data-table/monitors/data-table-toolbar.tsx
index 4f68b119..6e3f6541 100644
--- a/apps/dashboard/src/components/data-table/monitors/data-table-toolbar.tsx
+++ b/apps/dashboard/src/components/data-table/monitors/data-table-toolbar.tsx
@@ -1,7 +1,7 @@
"use client";
import type { Table } from "@tanstack/react-table";
-import { X } from "lucide-react";
+import { Tag, X } from "lucide-react";
import { Button } from "@openstatus/ui/components/ui/button";
import { Input } from "@openstatus/ui/components/ui/input";
@@ -40,6 +40,7 @@ export function MonitorDataTableToolbar({
label: tag.name,
value: tag.id,
}))}
+ icon={Tag}
/>
)}
{isFiltered && (
diff --git a/apps/dashboard/src/components/data-table/response-logs/data-table-toolbar.tsx b/apps/dashboard/src/components/data-table/response-logs/data-table-toolbar.tsx
index 3eaab591..4aea3508 100644
--- a/apps/dashboard/src/components/data-table/response-logs/data-table-toolbar.tsx
+++ b/apps/dashboard/src/components/data-table/response-logs/data-table-toolbar.tsx
@@ -1,7 +1,7 @@
"use client";
import type { Table } from "@tanstack/react-table";
-import { X } from "lucide-react";
+import { Activity, MapPin, TriangleAlert, X } from "lucide-react";
import { Button } from "@openstatus/ui/components/ui/button";
@@ -32,6 +32,7 @@ export function ResponseLogsDataTableToolbar({
label: code.code.toString(),
value: code.code.toString(),
}))}
+ icon={Activity}
/>
)}
{table.getColumn("region") && (
@@ -42,6 +43,7 @@ export function ResponseLogsDataTableToolbar({
label: region.location,
value: region.code,
}))}
+ icon={MapPin}
/>
)}
{table.getColumn("error") && (
@@ -52,6 +54,7 @@ export function ResponseLogsDataTableToolbar({
{ label: "Yes", value: "true" },
{ label: "No", value: "false" },
]}
+ icon={TriangleAlert}
/>
)}
{isFiltered && (
diff --git a/apps/dashboard/src/components/data-table/subscribers/data-table-toolbar.tsx b/apps/dashboard/src/components/data-table/subscribers/data-table-toolbar.tsx
index d46fcae2..b64c793c 100644
--- a/apps/dashboard/src/components/data-table/subscribers/data-table-toolbar.tsx
+++ b/apps/dashboard/src/components/data-table/subscribers/data-table-toolbar.tsx
@@ -4,10 +4,30 @@ import { DataTableFacetedFilter } from "@/components/ui/data-table/data-table-fa
import type { RouterOutputs } from "@openstatus/api";
import { Button } from "@openstatus/ui/components/ui/button";
import type { Table } from "@tanstack/react-table";
-import { X } from "lucide-react";
+import { CircleCheck, Globe, X } from "lucide-react";
type Subscriber = RouterOutputs["pageSubscriber"]["list"][number];
+const STATUS_OPTIONS = [
+ { label: "Active", value: "active" },
+ { label: "Pending", value: "pending" },
+ { label: "Unsubscribed", value: "unsubscribed" },
+];
+
+const SOURCE_OPTIONS = [
+ { label: "Self-signup", value: "self_signup" },
+ { label: "Vendor", value: "vendor" },
+ { label: "Import", value: "import" },
+];
+
+function filterAvailable
(
+ options: T[],
+ facets: Map | undefined,
+) {
+ if (!facets) return [];
+ return options.filter((option) => facets.has(option.value));
+}
+
export function SubscribersDataTableToolbar({
table,
}: {
@@ -15,29 +35,29 @@ export function SubscribersDataTableToolbar({
}) {
const isFiltered = table.getState().columnFilters.length > 0;
+ const statusFacets = table.getColumn("status")?.getFacetedUniqueValues();
+ const sourceFacets = table.getColumn("source")?.getFacetedUniqueValues();
+
+ const statusOptions = filterAvailable(STATUS_OPTIONS, statusFacets);
+ const sourceOptions = filterAvailable(SOURCE_OPTIONS, sourceFacets);
+
return (
- {table.getColumn("status") && (
+ {table.getColumn("status") && statusOptions.length > 0 && (
)}
- {table.getColumn("source") && (
+ {table.getColumn("source") && sourceOptions.length > 0 && (
)}
{isFiltered && (
diff --git a/apps/dashboard/src/components/ui/data-table/data-table-faceted-filter.tsx b/apps/dashboard/src/components/ui/data-table/data-table-faceted-filter.tsx
index d40c0eec..c4ca1073 100644
--- a/apps/dashboard/src/components/ui/data-table/data-table-faceted-filter.tsx
+++ b/apps/dashboard/src/components/ui/data-table/data-table-faceted-filter.tsx
@@ -18,12 +18,12 @@ import {
PopoverContent,
PopoverTrigger,
} from "@openstatus/ui/components/ui/popover";
-import { Separator } from "@openstatus/ui/components/ui/separator";
import { cn } from "@openstatus/ui/lib/utils";
interface DataTableFacetedFilterProps
{
column?: Column;
title?: string;
+ icon?: React.ComponentType<{ className?: string }>;
options: {
label: string;
value: string | number;
@@ -34,6 +34,7 @@ interface DataTableFacetedFilterProps {
export function DataTableFacetedFilter({
column,
title,
+ icon: Icon,
options,
}: DataTableFacetedFilterProps) {
const facets = column?.getFacetedUniqueValues();
@@ -44,12 +45,18 @@ export function DataTableFacetedFilter({
return (
-
{option.icon && (
)}
-
{option.label}
+
{option.label}
{facets?.get(option.value) && (
{facets.get(option.value)}
diff --git a/apps/status-page/src/components/ui/data-table/data-table-toobar.tsx b/apps/status-page/src/components/ui/data-table/data-table-toolbar.tsx
similarity index 100%
rename from apps/status-page/src/components/ui/data-table/data-table-toobar.tsx
rename to apps/status-page/src/components/ui/data-table/data-table-toolbar.tsx
diff --git a/apps/status-page/src/components/ui/data-table/data-table.tsx b/apps/status-page/src/components/ui/data-table/data-table.tsx
index fcbae714..1f3dfb62 100644
--- a/apps/status-page/src/components/ui/data-table/data-table.tsx
+++ b/apps/status-page/src/components/ui/data-table/data-table.tsx
@@ -30,7 +30,7 @@ import {
import { Fragment } from "react";
import type { DataTableActionBarProps } from "./data-table-action-bar";
import type { DataTablePaginationProps } from "./data-table-pagination";
-import type { DataTableToolbarProps } from "./data-table-toobar";
+import type { DataTableToolbarProps } from "./data-table-toolbar";
export interface DataTableProps {
columns: ColumnDef[];
--
2.51.2