From 2157048f18b775ec8a08a228610123de7af2ac94 Mon Sep 17 00:00:00 2001 From: Maximilian Kaske <56969857+mxkaske@users.noreply.github.com> Date: Fri, 26 Apr 2024 17:08:08 +0200 Subject: [PATCH] feat: visibility filter and small tabs link improvement (#786) --- .../[domain]/_components/header.tsx | 2 +- .../src/components/dashboard/tabs-link.tsx | 66 ++++++++++++++----- .../components/data-table/monitor/columns.tsx | 9 +++ .../data-table/monitor/data-table-toolbar.tsx | 10 +++ .../data-table/monitor/data-table.tsx | 17 +++++ .../data-table/status-page/columns.tsx | 38 ++++++++--- .../src/components/layout/header/app-tabs.tsx | 2 +- 7 files changed, 117 insertions(+), 27 deletions(-) diff --git a/apps/web/src/app/status-page/[domain]/_components/header.tsx b/apps/web/src/app/status-page/[domain]/_components/header.tsx index 59f084a9..e897c745 100644 --- a/apps/web/src/app/status-page/[domain]/_components/header.tsx +++ b/apps/web/src/app/status-page/[domain]/_components/header.tsx @@ -43,7 +43,7 @@ export function Header({ navigation, plan, page }: Props) { ) : null} - + {navigation.map(({ label, href, disabled, segment }) => { const active = segment === selectedSegment; return ( diff --git a/apps/web/src/components/dashboard/tabs-link.tsx b/apps/web/src/components/dashboard/tabs-link.tsx index b72830f6..8b7b2a74 100644 --- a/apps/web/src/components/dashboard/tabs-link.tsx +++ b/apps/web/src/components/dashboard/tabs-link.tsx @@ -4,28 +4,39 @@ import * as React from "react"; import type { LinkProps } from "next/link"; import Link from "next/link"; -import { Separator } from "@openstatus/ui"; - import { cn } from "@/lib/utils"; export interface TabsContainerProps - extends React.HTMLAttributes { - hideSeparator?: boolean; -} + extends React.HTMLAttributes, + Partial {} export function TabsContainer({ className, + direction = "horizontal", + position = "end", children, - hideSeparator = false, }: TabsContainerProps) { return ( - + + + ); } @@ -43,18 +54,24 @@ export function TabsLink({ disabled, ...props }: TabsLinkProps) { + const { direction, position } = useTabs(); return (
  • ); } + +// -------------- + +interface TabsContextProps { + direction: "horizontal" | "vertical"; + position: "start" | "end"; +} + +const TabsContext = React.createContext(null); + +const useTabs = () => { + const tabsContext = React.useContext(TabsContext); + + if (!tabsContext) { + throw new Error("useTabs has to be used within "); + } + + return tabsContext; +}; diff --git a/apps/web/src/components/data-table/monitor/columns.tsx b/apps/web/src/components/data-table/monitor/columns.tsx index f56dee7d..c1e94114 100644 --- a/apps/web/src/components/data-table/monitor/columns.tsx +++ b/apps/web/src/components/data-table/monitor/columns.tsx @@ -50,6 +50,15 @@ export const columns: ColumnDef<{ ); }, }, + { + // REMINDER: visibility is handled within the `` + accessorKey: "public", + accessorFn: (row) => row.monitor.public, + filterFn: (row, id, value) => { + if (!Array.isArray(value)) return true; + return value.includes(row.original.monitor.public); + }, + }, { accessorKey: "tags", header: "Tags", diff --git a/apps/web/src/components/data-table/monitor/data-table-toolbar.tsx b/apps/web/src/components/data-table/monitor/data-table-toolbar.tsx index 43903281..a4f7f858 100644 --- a/apps/web/src/components/data-table/monitor/data-table-toolbar.tsx +++ b/apps/web/src/components/data-table/monitor/data-table-toolbar.tsx @@ -40,6 +40,16 @@ export function DataTableToolbar({ }))} /> )} + {table.getColumn("public") && ( + + )} {isFiltered && (