diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/credits-setup.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/credits-setup.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/credits-setup.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/credits-setup.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/expiration-setup.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/expiration-setup.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx similarity index 95% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx index b8ac28a5d7..dff8523f62 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/external-id-field/index.tsx @@ -1,6 +1,6 @@ -import { useCreateIdentity } from "@/app/(app)/apis/[apiId]/_components/create-key/hooks/use-create-identity"; -import { useFetchIdentities } from "@/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities"; -import { createIdentityOptions } from "@/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options"; +import { useCreateIdentity } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-create-identity"; +import { useFetchIdentities } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-fetch-identities"; +import { createIdentityOptions } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options"; import { FormCombobox } from "@/components/ui/form-combobox"; import type { Identity } from "@unkey/db"; import { TriangleWarning2 } from "@unkey/icons"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/use-search-identities.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/external-id-field/use-search-identities.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field/use-search-identities.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/external-id-field/use-search-identities.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/general-setup.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/general-setup.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx similarity index 97% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx index 3bd6fb9486..615ca21244 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/key-created-success-dialog.tsx @@ -2,6 +2,7 @@ import { ConfirmPopover } from "@/components/confirmation-popover"; import { Dialog, DialogContent } from "@/components/ui/dialog"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { ArrowRight, Check, Key2, Plus } from "@unkey/icons"; import { Button, InfoTooltip, toast } from "@unkey/ui"; import { useRouter } from "next/navigation"; @@ -24,13 +25,13 @@ export const KeyCreatedSuccessDialog = ({ keyspaceId?: string | null; onCreateAnother?: () => void; }) => { + const workspace = useWorkspaceNavigation(); const [isConfirmOpen, setIsConfirmOpen] = useState(false); const [pendingAction, setPendingAction] = useState< "close" | "create-another" | "go-to-details" | null >(null); const dividerRef = useRef(null); const router = useRouter(); - // Prevent accidental tab/window close when dialog is open useEffect(() => { if (!isOpen) { @@ -90,7 +91,7 @@ export const KeyCreatedSuccessDialog = ({ }); return; } - router.push(`/apis/${apiId}/keys/${keyspaceId}/${keyData.id}`); + router.push(`/${workspace.slug}/apis/${apiId}/keys/${keyspaceId}/${keyData.id}`); break; default: diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-secret-section.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/key-secret-section.tsx similarity index 96% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-secret-section.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/key-secret-section.tsx index 6e7c952b1c..7b102029bd 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/key-secret-section.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/key-secret-section.tsx @@ -1,6 +1,6 @@ "use client"; -import { SecretKey } from "@/app/(app)/apis/[apiId]/_components/create-key/components/secret-key"; +import { SecretKey } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/secret-key"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { CircleInfo } from "@unkey/icons"; import { Code, CopyButton, VisibleButton } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/metadata-setup.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/metadata-setup.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/protection-switch.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/protection-switch.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/protection-switch.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/protection-switch.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/ratelimit-setup.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/ratelimit-setup.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/ratelimit-setup.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/ratelimit-setup.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/secret-key.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/secret-key.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/secret-key.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/secret-key.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/section-label.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/section-label.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/section-label.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/section-label.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.constants.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.constants.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.constants.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.constants.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.utils.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.utils.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-create-identity.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-create-identity.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-create-identity.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-create-identity.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-create-key.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-create-key.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-create-key.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-create-key.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/create-identity-options.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/index.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/index.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/index.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-fetch-identities/index.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-validate-steps.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-validate-steps.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/hooks/use-validate-steps.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/hooks/use-validate-steps.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/index.tsx similarity index 94% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/index.tsx index 887f13de46..62e515030b 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/index.tsx @@ -8,6 +8,7 @@ import { Plus } from "@unkey/icons"; import type { IconProps } from "@unkey/icons/src/props"; import { Button, + Loading, NavigableDialogBody, NavigableDialogContent, NavigableDialogFooter, @@ -16,7 +17,7 @@ import { NavigableDialogRoot, toast, } from "@unkey/ui"; -import { type FC, useEffect, useState } from "react"; +import { type FC, Suspense, useEffect, useState } from "react"; import { FormProvider } from "react-hook-form"; import { KeyCreatedSuccessDialog } from "./components/key-created-success-dialog"; import { SectionLabel } from "./components/section-label"; @@ -208,14 +209,16 @@ export const CreateKeyDialog = ({ {/* Success Dialog */} - + }> + + ); }; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/types.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/types.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/types.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/types.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/bar-chart/hooks/use-fetch-timeseries.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/bar-chart/hooks/use-fetch-timeseries.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/bar-chart/hooks/use-fetch-timeseries.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/bar-chart/hooks/use-fetch-timeseries.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/bar-chart/query-timeseries.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/bar-chart/query-timeseries.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/bar-chart/query-timeseries.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/bar-chart/query-timeseries.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/bar-chart/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/bar-chart/utils.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/bar-chart/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/bar-chart/utils.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/line-chart/hooks/use-fetch-timeseries.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/line-chart/hooks/use-fetch-timeseries.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/charts/line-chart/hooks/use-fetch-timeseries.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/charts/line-chart/hooks/use-fetch-timeseries.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-datetime/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-filters/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-filters/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-filters/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-filters/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-filters/outcome-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-filters/outcome-filter.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-filters/outcome-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-filters/outcome-filter.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-refresh.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-refresh.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-refresh.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-refresh.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-search/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-search/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/components/logs-search/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/components/logs-search/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/controls/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/components/log-header.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/components/log-header.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/components/log-header.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/components/log-header.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/components/log-outcome-distribution-section.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/components/log-outcome-distribution-section.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/components/log-outcome-distribution-section.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/components/log-outcome-distribution-section.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/components/log-section.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/components/log-section.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/components/log-section.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/components/log-section.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/components/roles-permissions.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/components/roles-permissions.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/components/roles-permissions.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/components/roles-permissions.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/log-details/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/log-details/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/outcome-popover.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/outcome-popover.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/outcome-popover.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/outcome-popover.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/override-indicator.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/override-indicator.tsx similarity index 76% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/override-indicator.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/override-indicator.tsx index 4afcf97a09..f5885f4cca 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/components/override-indicator.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/components/override-indicator.tsx @@ -1,4 +1,5 @@ "use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { shortenId } from "@/lib/shorten-id"; import { cn } from "@/lib/utils"; import type { KeysOverviewLog } from "@unkey/clickhouse/src/keys/keys"; @@ -6,7 +7,7 @@ import { TriangleWarning2 } from "@unkey/icons"; import { InfoTooltip, Loading } from "@unkey/ui"; import Link from "next/link"; import { useRouter } from "next/navigation"; -import { useCallback, useState } from "react"; +import { Suspense, useCallback, useState } from "react"; import { getErrorPercentage, getErrorSeverity } from "../utils/calculate-blocked-percentage"; type KeyIdentifierColumnProps = { @@ -44,11 +45,12 @@ const getWarningMessage = (severity: string, errorRate: number) => { }; export const KeyIdentifierColumn = ({ log, apiId, onNavigate }: KeyIdentifierColumnProps) => { + const workspace = useWorkspaceNavigation(); + const router = useRouter(); const errorPercentage = getErrorPercentage(log); const severity = getErrorSeverity(log); const hasErrors = severity !== "none"; - const [isNavigating, setIsNavigating] = useState(false); const handleLinkClick = useCallback( @@ -58,9 +60,11 @@ export const KeyIdentifierColumn = ({ log, apiId, onNavigate }: KeyIdentifierCol onNavigate?.(); - router.push(`/apis/${apiId}/keys/${log.key_details?.key_auth_id}/${log.key_id}`); + router.push( + `/${workspace.slug}/apis/${apiId}/keys/${log.key_details?.key_auth_id}/${log.key_id}`, + ); }, - [apiId, log.key_id, log.key_details?.key_auth_id, onNavigate, router.push], + [apiId, log.key_id, log.key_details?.key_auth_id, onNavigate, router.push, workspace.slug], ); return ( @@ -80,16 +84,18 @@ export const KeyIdentifierColumn = ({ log, apiId, onNavigate }: KeyIdentifierCol )} - -
- {shortenId(log.key_id)} -
- + }> + +
+ {shortenId(log.key_id)} +
+ +
); }; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/hooks/use-logs-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/hooks/use-logs-query.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/hooks/use-logs-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/hooks/use-logs-query.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/logs-table.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/logs-table.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/logs-table.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/logs-table.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/query-logs.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/query-logs.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/query-logs.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/query-logs.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/utils/calculate-blocked-percentage.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/utils/calculate-blocked-percentage.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/utils/calculate-blocked-percentage.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/utils/calculate-blocked-percentage.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/utils/get-row-class.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/utils/get-row-class.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/components/table/utils/get-row-class.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/components/table/utils/get-row-class.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/constants.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/constants.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/constants.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/constants.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/filters.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/logs-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/logs-client.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/logs-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/logs-client.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/_overview/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/utils.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/_overview/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/utils.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/actions.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/actions.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/actions.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/actions.ts diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx new file mode 100644 index 0000000000..1a510578a1 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/api-id-navbar.tsx @@ -0,0 +1,234 @@ +"use client"; + +import { QuickNavPopover } from "@/components/navbar-popover"; +import { NavbarActionButton } from "@/components/navigation/action-button"; +import { Navbar } from "@/components/navigation/navbar"; +import { useIsMobile } from "@/hooks/use-mobile"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; +import { trpc } from "@/lib/trpc/client"; +import type { Workspace } from "@unkey/db"; +import { ChevronExpandY, Nodes, Plus, TaskUnchecked } from "@unkey/icons"; +import { CreateKeyDialog } from "./_components/create-key"; + +// Types for better type safety +interface ApiLayoutData { + currentApi: { + id: string; + name: string; + workspaceId: string; + keyAuthId: string | null; + keyspaceDefaults: { + prefix?: string; + bytes?: number; + } | null; + deleteProtection: boolean | null; + ipWhitelist: string | null; + }; + workspaceApis: Array<{ + id: string; + name: string; + }>; + keyAuth: { + id: string; + defaultPrefix: string | null; + defaultBytes: number | null; + sizeApprox: number; + } | null; + workspace: { + id: string; + ipWhitelist: boolean; + }; +} + +interface ApisNavbarProps { + apiId: string; + keyspaceId?: string; + keyId?: string; + activePage?: { + href: string; + text: string; + }; +} + +interface LoadingNavbarProps { + workspace: Workspace; +} + +interface NavbarContentProps { + apiId: string; + keyspaceId?: string; + keyId?: string; + activePage?: { + href: string; + text: string; + }; + workspace: Workspace; + isMobile: boolean; + layoutData: ApiLayoutData; +} + +// Loading state component +const LoadingNavbar = ({ workspace }: LoadingNavbarProps) => ( + + }> + APIs + +
+ + +
+
+ +
+ + + + + + Create new key + +
+
+
+ +
+
+ + +); + +// Main navbar content component +const NavbarContent = ({ + keyspaceId, + keyId, + activePage, + workspace, + isMobile, + layoutData, +}: NavbarContentProps) => { + const shouldFetchKey = Boolean(keyspaceId && keyId); + + // If we expected to find a key but this component doesn't handle key details, + // we should handle this at a higher level or in a different component + if (shouldFetchKey) { + console.warn("Key fetching logic should be handled at a higher level"); + } + + const { currentApi } = layoutData; + + // Define base path for API navigation + const base = `/${workspace.slug}/apis/${currentApi.id}`; + + // Create navigation items for QuickNavPopover + const navigationItems = [ + { + id: "requests", + label: "Requests", + href: `/${workspace.slug}/apis/${currentApi.id}`, + }, + ]; + + // Add Keys navigation if keyAuthId exists + if (currentApi.keyAuthId) { + navigationItems.push({ + id: "keys", + label: "Keys", + href: `/${workspace.slug}/apis/${currentApi.id}/keys/${currentApi.keyAuthId}`, + }); + } + + // Add Settings navigation + navigationItems.push({ + id: "settings", + label: "Settings", + href: `/${workspace.slug}/apis/${currentApi.id}/settings`, + }); + + return ( +
+ + }> + + APIs + + +
{currentApi.name}
+
+ + +
+ {activePage?.text ?? ""} + +
+
+
+
+ {layoutData.keyAuth ? ( + + ) : ( + + + Create new key + + )} +
+
+ ); +}; + +// Main component +export const ApisNavbar = ({ apiId, keyspaceId, keyId, activePage }: ApisNavbarProps) => { + const workspace = useWorkspaceNavigation(); + + const isMobile = useIsMobile(); + + // Only make the query if we have a valid apiId + const { + data: layoutData, + isLoading, + error, + } = trpc.api.queryApiKeyDetails.useQuery( + { apiId }, + { + enabled: Boolean(apiId), // Only run query if apiId exists + retry: 3, + retryDelay: 1000, + }, + ); + + // Show loading state while fetching data + if (isLoading || !layoutData) { + return ; + } + + // Handle error state + if (error) { + console.error("Failed to fetch API layout data:", error); + return ; + } + + return ( + + ); +}; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/hooks/use-fetch-timeseries.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/hooks/use-fetch-timeseries.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/hooks/use-fetch-timeseries.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/hooks/use-fetch-timeseries.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/query-timeseries.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/query-timeseries.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/query-timeseries.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/query-timeseries.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/utils.ts similarity index 90% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/utils.ts index 1192437951..d9aa936e4b 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/utils.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/bar-chart/utils.ts @@ -1,5 +1,5 @@ -import { OUTCOME_BACKGROUND_COLORS } from "@/app/(app)/apis/[apiId]/_overview/constants"; -import { formatOutcomeName } from "@/app/(app)/apis/[apiId]/_overview/utils"; +import { OUTCOME_BACKGROUND_COLORS } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/constants"; +import { formatOutcomeName } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/utils"; import { KEY_VERIFICATION_OUTCOMES } from "@unkey/clickhouse/src/keys/keys"; /** diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/charts/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-datetime/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-datetime/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-datetime/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/outcome-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/outcome-filter.tsx similarity index 90% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/outcome-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/outcome-filter.tsx index 70bb1cd30e..5f3c725297 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/outcome-filter.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-filters/outcome-filter.tsx @@ -1,4 +1,7 @@ -import { getOutcomeColor, getOutcomeOptions } from "@/app/(app)/apis/[apiId]/_overview/utils"; +import { + getOutcomeColor, + getOutcomeOptions, +} from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/utils"; import { FilterCheckbox } from "@/components/logs/checkbox/filter-checkbox"; import { useFilters } from "../../../../hooks/use-filters"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-live-switch.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-live-switch.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-live-switch.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-live-switch.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-refresh.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-refresh.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-refresh.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-refresh.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-search/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-search/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-search/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/components/logs-search/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/index.tsx similarity index 97% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/index.tsx index 92f6d9e16f..37a5f9eb01 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/controls/index.tsx @@ -1,4 +1,5 @@ -import { StatusBadge } from "@/app/(app)/apis/[apiId]/settings/components/status-badge"; +"use client"; +import { StatusBadge } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/status-badge"; import { ControlsContainer, ControlsLeft, diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/log-details/components/hooks/use-logs-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/log-details/components/hooks/use-logs-query.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/log-details/components/hooks/use-logs-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/log-details/components/hooks/use-logs-query.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/log-details/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/log-details/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/log-details/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/log-details/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/status-badge.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/status-badge.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/status-badge.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/components/status-badge.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/hooks/use-logs-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/hooks/use-logs-query.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/hooks/use-logs-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/hooks/use-logs-query.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/logs-table.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/query-logs.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/query-logs.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/query-logs.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/query-logs.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/utils/calculate-blocked-percentage.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/utils/calculate-blocked-percentage.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/utils/calculate-blocked-percentage.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/utils/calculate-blocked-percentage.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/utils/get-row-class.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/utils/get-row-class.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/utils/get-row-class.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/components/table/utils/get-row-class.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/context/logs.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/context/logs.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/context/logs.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/context/logs.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/filters.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/logs-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/logs-client.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/logs-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/logs-client.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx similarity index 75% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx index c8d29ce0ed..32cb47aa46 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/[keyId]/page.tsx @@ -1,12 +1,13 @@ "use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { ApisNavbar } from "../../../api-id-navbar"; import { KeyDetailsLogsClient } from "./logs-client"; - export default function KeyDetailsPage(props: { params: { apiId: string; keyAuthId: string; keyId: string }; }) { const { apiId, keyAuthId: keyspaceId, keyId } = props.params; + const workspace = useWorkspaceNavigation(); return (
@@ -15,7 +16,7 @@ export default function KeyDetailsPage(props: { keyspaceId={keyspaceId} keyId={keyId} activePage={{ - href: `/apis/${apiId}/keys/${keyspaceId}`, + href: `/${workspace.slug}/apis/${apiId}/keys/${keyspaceId}/${keyId}`, text: "Keys", }} /> diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/components/logs-filters/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/components/logs-filters/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/components/logs-filters/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/components/logs-filters/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/components/logs-search/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/components/logs-search/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/components/logs-search/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/components/logs-search/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/index.tsx similarity index 81% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/index.tsx index 97e8c07861..e2b1fb6166 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/controls/index.tsx @@ -1,4 +1,4 @@ -import { LogsDateTime } from "@/app/(app)/apis/_components/controls/components/logs-datetime"; +import { LogsDateTime } from "@/app/(app)/[workspaceSlug]/apis/_components/controls/components/logs-datetime"; import { ControlsContainer, ControlsLeft } from "@/components/logs/controls-container"; import { LogsFilters } from "./components/logs-filters"; import { LogsSearch } from "./components/logs-search"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/delete-key.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/delete-key.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/delete-key.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/delete-key.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/disable-key.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/disable-key.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/disable-key.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/disable-key.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/index.tsx similarity index 95% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/index.tsx index da9d7254bc..e429a98d68 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/index.tsx @@ -1,8 +1,8 @@ -import { UsageSetup } from "@/app/(app)/apis/[apiId]/_components/create-key/components/credits-setup"; +import { UsageSetup } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/credits-setup"; import { type CreditsFormValues, creditsSchema, -} from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.schema"; +} from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.schema"; import type { ActionComponentProps } from "@/components/logs/table-action.popover"; import { usePersistedForm } from "@/hooks/use-persisted-form"; import { trpc } from "@/lib/trpc/client"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/utils.ts similarity index 76% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/utils.ts index 7e39d40da2..2a3072cace 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/utils.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-credits/utils.ts @@ -1,9 +1,12 @@ -import type { refillSchema } from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.schema"; -import { getDefaultValues } from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.utils"; +import { getDefaultValues } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.utils"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; import type { z } from "zod"; -type Refill = z.infer; +// biome-ignore format: the comma after z.infer is incorrect syntax +type Refill = z.infer< + typeof import("@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.schema").refillSchema +>; + export const getKeyLimitDefaults = (keyDetails: KeyDetails) => { const defaultRemaining = keyDetails.key.credits.remaining ?? getDefaultValues().limit?.data?.remaining ?? 100; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/index.tsx similarity index 94% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/index.tsx index de87becc7b..beaf94d04e 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/index.tsx @@ -1,8 +1,8 @@ -import { ExpirationSetup } from "@/app/(app)/apis/[apiId]/_components/create-key/components/expiration-setup"; +import { ExpirationSetup } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/expiration-setup"; import { type ExpirationFormValues, expirationSchema, -} from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.schema"; +} from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.schema"; import type { ActionComponentProps } from "@/components/logs/table-action.popover"; import { usePersistedForm } from "@/hooks/use-persisted-form"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/utils.ts similarity index 77% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/utils.ts index 267a265430..d00f385136 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/utils.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-expiration/utils.ts @@ -1,4 +1,4 @@ -import { getDefaultValues } from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.utils"; +import { getDefaultValues } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.utils"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; export const getKeyExpirationDefaults = (keyDetails: KeyDetails) => { diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx similarity index 97% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx index 68974acf67..b813a256af 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-external-id/index.tsx @@ -1,4 +1,4 @@ -import { ExternalIdField } from "@/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field"; +import { ExternalIdField } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/external-id-field"; import { ConfirmPopover } from "@/components/confirmation-popover"; import type { ActionComponentProps } from "@/components/logs/table-action.popover"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-key-name.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-key-name.tsx similarity index 97% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-key-name.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-key-name.tsx index 271910111f..65180d5359 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-key-name.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-key-name.tsx @@ -1,4 +1,4 @@ -import { nameSchema } from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.schema"; +import { nameSchema } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.schema"; import type { ActionComponentProps } from "@/components/logs/table-action.popover"; import { usePersistedForm } from "@/hooks/use-persisted-form"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/index.tsx similarity index 94% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/index.tsx index 2b3e712a62..b6b9c4ea0a 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/index.tsx @@ -1,8 +1,9 @@ -import { MetadataSetup } from "@/app/(app)/apis/[apiId]/_components/create-key/components/metadata-setup"; +"use client"; +import { MetadataSetup } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/metadata-setup"; import { type MetadataFormValues, metadataSchema, -} from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.schema"; +} from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.schema"; import type { ActionComponentProps } from "@/components/logs/table-action.popover"; import { usePersistedForm } from "@/hooks/use-persisted-form"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/utils.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-metadata/utils.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/index.tsx similarity index 94% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/index.tsx index 67aba0f57f..b058a8c060 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/index.tsx @@ -1,8 +1,8 @@ -import { RatelimitSetup } from "@/app/(app)/apis/[apiId]/_components/create-key/components/ratelimit-setup"; +import { RatelimitSetup } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/ratelimit-setup"; import { type RatelimitFormValues, ratelimitSchema, -} from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.schema"; +} from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.schema"; import type { ActionComponentProps } from "@/components/logs/table-action.popover"; import { usePersistedForm } from "@/hooks/use-persisted-form"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/utils.ts similarity index 82% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/utils.ts index 769b833f26..26830959dc 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/utils.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-ratelimits/utils.ts @@ -1,4 +1,4 @@ -import { getDefaultValues } from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.utils"; +import { getDefaultValues } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.utils"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; export const getKeyRatelimitsDefaults = (keyDetails: KeyDetails) => { diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/create-permission-options.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/create-permission-options.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/create-permission-options.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/create-permission-options.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/hooks/use-fetch-keys-permissions.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/hooks/use-fetch-keys-permissions.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/hooks/use-fetch-keys-permissions.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/hooks/use-fetch-keys-permissions.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/hooks/use-search-keys-permissions.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/hooks/use-search-keys-permissions.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/hooks/use-search-keys-permissions.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/hooks/use-search-keys-permissions.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/permissions-field.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/permissions-field.tsx similarity index 98% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/permissions-field.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/permissions-field.tsx index 7cf5c883d1..e89d1f51eb 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/permissions-field.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-permission/permissions-field.tsx @@ -1,4 +1,4 @@ -import { StatusBadge } from "@/app/(app)/apis/[apiId]/settings/components/status-badge"; +import { StatusBadge } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/status-badge"; import { SelectedItemsList } from "@/components/selected-item-list"; import { FormCombobox } from "@/components/ui/form-combobox"; import type { KeyPermission, KeyRole } from "@/lib/trpc/routers/key/rbac/connected-roles-and-perms"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/create-key-options.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/create-key-options.tsx similarity index 98% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/create-key-options.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/create-key-options.tsx index 753cb7dc61..87d87eb8e7 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/create-key-options.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/create-key-options.tsx @@ -1,4 +1,4 @@ -import { StatusBadge } from "@/app/(app)/apis/[apiId]/settings/components/status-badge"; +import { StatusBadge } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/status-badge"; import { Lock, Tag } from "@unkey/icons"; import { Badge, Button, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/hooks/use-fetch-keys-roles.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/hooks/use-fetch-keys-roles.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/hooks/use-fetch-keys-roles.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/hooks/use-fetch-keys-roles.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/hooks/use-search-keys-roles.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/hooks/use-search-keys-roles.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/hooks/use-search-keys-roles.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/hooks/use-search-keys-roles.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/role-field.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/role-field.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/role-field.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/assign-role/role-field.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/granted-access.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/granted-access.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/granted-access.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/granted-access.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/hooks/use-fetch-permission-slugs.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/hooks/use-fetch-permission-slugs.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/hooks/use-fetch-permission-slugs.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/components/hooks/use-fetch-permission-slugs.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/update-key-rbac.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/update-key-rbac.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/update-key-rbac.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/edit-rbac/update-key-rbac.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-delete-key.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-delete-key.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-delete-key.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-delete-key.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-credits.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-credits.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-credits.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-credits.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-expiration.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-expiration.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-expiration.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-expiration.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-external-id.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-external-id.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-external-id.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-external-id.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-key.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-key.tsx similarity index 94% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-key.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-key.tsx index 1c0d89e63f..0e6fd729e5 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-key.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-key.tsx @@ -1,4 +1,4 @@ -import { UNNAMED_KEY } from "@/app/(app)/apis/[apiId]/_components/create-key/create-key.constants"; +import { UNNAMED_KEY } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/create-key.constants"; import { trpc } from "@/lib/trpc/client"; import { toast } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-metadata.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-metadata.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-metadata.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-metadata.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-ratelimits.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-ratelimits.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-ratelimits.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-ratelimits.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-rbac.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-rbac.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-rbac.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-edit-rbac.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-update-key-status.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-update-key-status.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-update-key-status.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/hooks/use-update-key-status.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/key-info.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/key-info.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/key-info.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/components/key-info.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/keys-table-action.popover.constants.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/keys-table-action.popover.constants.tsx similarity index 97% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/keys-table-action.popover.constants.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/keys-table-action.popover.constants.tsx index 92d897e586..fcafffb09e 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/keys-table-action.popover.constants.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/actions/keys-table-action.popover.constants.tsx @@ -1,4 +1,4 @@ -import { MAX_KEYS_FETCH_LIMIT } from "@/app/(app)/authorization/roles/components/upsert-role/components/assign-key/hooks/use-fetch-keys"; +import { MAX_KEYS_FETCH_LIMIT } from "@/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/hooks/use-fetch-keys"; import { type MenuItem, TableActionPopover } from "@/components/logs/table-action.popover"; import { trpc } from "@/lib/trpc/client"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/components/outcome-explainer.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/components/outcome-explainer.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/components/outcome-explainer.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/components/outcome-explainer.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/query-timeseries.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/query-timeseries.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/query-timeseries.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/query-timeseries.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/use-fetch-timeseries.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/use-fetch-timeseries.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/use-fetch-timeseries.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/bar-chart/use-fetch-timeseries.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/hidden-value.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/hidden-value.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/hidden-value.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/hidden-value.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/last-used.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/last-used.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/last-used.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/last-used.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx similarity index 97% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx index 59d648b81a..28a6ca599d 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/components/batch-edit-external-id.tsx @@ -1,4 +1,4 @@ -import { ExternalIdField } from "@/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field"; +import { ExternalIdField } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_components/create-key/components/external-id-field"; import { ConfirmPopover } from "@/components/confirmation-popover"; import { TriangleWarning2 } from "@unkey/icons"; import { Button, DialogContainer } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/skeletons.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/skeletons.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/skeletons.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/skeletons.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/components/status-badge.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/components/status-badge.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/components/status-badge.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/components/status-badge.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/constants.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/constants.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/constants.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/constants.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/index.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/query-timeseries.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/query-timeseries.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/query-timeseries.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/query-timeseries.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/use-key-status.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/use-key-status.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/use-key-status.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/status-cell/use-key-status.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/hooks/use-keys-list-query.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx similarity index 97% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx index 5bdfa1f9ed..becc70107d 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/keys-list.tsx @@ -1,6 +1,7 @@ "use client"; import { VirtualTable } from "@/components/virtual-table/index"; import type { Column } from "@/components/virtual-table/types"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { shortenId } from "@/lib/shorten-id"; import type { KeyDetails } from "@/lib/trpc/routers/api/keys/query-api-keys/schema"; import { BookBookmark, Dots, Focus, Key } from "@unkey/icons"; @@ -53,6 +54,8 @@ export const KeysList = ({ keyspaceId: string; apiId: string; }) => { + const workspace = useWorkspaceNavigation(); + const { keys, isLoading, isLoadingMore, loadMore, totalCount, hasMore } = useKeysListQuery({ keyAuthId: keyspaceId, }); @@ -62,7 +65,6 @@ export const KeysList = ({ const [selectedKeys, setSelectedKeys] = useState>(new Set()); // Track which row is being hovered const [hoveredKeyId, setHoveredKeyId] = useState(null); - const handleLinkClick = useCallback((keyId: string) => { setNavigatingKeyId(keyId); setSelectedKey(null); @@ -146,11 +148,11 @@ export const KeysList = ({ content={ <> This key is associated with the identity:{" "} - {key.identity_id ? ( + {key.identity_id && workspace ? ( { handleLinkClick(key.id); @@ -266,6 +268,7 @@ export const KeysList = ({ selectedKeys, toggleSelection, hoveredKeyId, + workspace, ], ); diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/query-logs.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/query-logs.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/query-logs.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/query-logs.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/utils/get-row-class.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/utils/get-row-class.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/utils/get-row-class.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/utils/get-row-class.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/filters.schema.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/keys-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/keys-client.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/keys-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/keys-client.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/page.tsx similarity index 64% rename from apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/page.tsx index 419919b90a..09c85a1b87 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/page.tsx @@ -1,4 +1,5 @@ "use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { ApisNavbar } from "../../api-id-navbar"; import { KeysClient } from "./_components/keys-client"; @@ -9,18 +10,20 @@ export default function APIKeysPage(props: { }; }) { const apiId = props.params.apiId; + const workspace = useWorkspaceNavigation(); + const keyspaceId = props.params.keyAuthId; return (
- +
); } diff --git a/apps/dashboard/app/(app)/apis/[apiId]/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/page.tsx similarity index 58% rename from apps/dashboard/app/(app)/apis/[apiId]/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/page.tsx index 3fbb896df6..5851ce6347 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/page.tsx @@ -1,16 +1,18 @@ "use client"; -import { LogsClient } from "@/app/(app)/apis/[apiId]/_overview/logs-client"; +import { LogsClient } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/_overview/logs-client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { ApisNavbar } from "./api-id-navbar"; export default function ApiPage(props: { params: { apiId: string } }) { const apiId = props.params.apiId; + const workspace = useWorkspaceNavigation(); return (
diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/actions.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/actions.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/actions.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/actions.ts diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/copy-api-id.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/components/copy-api-id.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/copy-api-id.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-bytes.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/default-bytes.tsx similarity index 92% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-bytes.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/default-bytes.tsx index 8a3ffa6204..a75a7acb1f 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/default-bytes.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/default-bytes.tsx @@ -1,5 +1,6 @@ "use client"; import { revalidate } from "@/app/actions"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { trpc } from "@/lib/trpc/client"; import { Button, Input, SettingCard } from "@unkey/ui"; import { Controller, useForm } from "react-hook-form"; @@ -27,6 +28,7 @@ type Props = { export const DefaultBytes: React.FC = ({ keyAuth, apiId }) => { const { onUpdateSuccess, onError } = createMutationHandlers(); + const workspace = useWorkspaceNavigation(); const { control, @@ -57,7 +59,8 @@ export const DefaultBytes: React.FC = ({ keyAuth, apiId }) => { } await setDefaultBytes.mutateAsync(values); - revalidate(`/apis/${apiId}/settings`); + + revalidate(`/${workspace.slug}/apis/${apiId}/settings`); } return ( @@ -69,7 +72,7 @@ export const DefaultBytes: React.FC = ({ keyAuth, apiId }) => {
} border="top" - className="border-b-1" + className="border-b" contentWidth="w-full lg:w-[420px] h-full justify-end items-end" >
= ({ keyAuth, apiId }) => { const { onUpdateSuccess, onError } = createMutationHandlers(); + const workspace = useWorkspaceNavigation(); const { control, @@ -46,6 +48,9 @@ export const DefaultPrefix: React.FC = ({ keyAuth, apiId }) => { }); async function onSubmit(values: z.infer) { + if (!workspace) { + return; + } if ( !validateFormChange( keyAuth.defaultPrefix, @@ -57,7 +62,7 @@ export const DefaultPrefix: React.FC = ({ keyAuth, apiId }) => { } await setDefaultPrefix.mutateAsync(values); - revalidate(`/apis/${apiId}/settings`); + revalidate(`/${workspace.slug}/apis/${apiId}/settings`); } return ( diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/delete-api.tsx similarity index 96% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/delete-api.tsx index e957e67ec7..13aa6bc56a 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-api.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/delete-api.tsx @@ -1,4 +1,5 @@ "use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { trpc } from "@/lib/trpc/client"; import { Lock } from "@unkey/icons"; import { Button, DialogContainer, Input, SettingCard } from "@unkey/ui"; @@ -21,10 +22,10 @@ type Props = { }; export const DeleteApi: React.FC = ({ api, keys }) => { + const workspace = useWorkspaceNavigation(); const { onDeleteSuccess, onError } = createMutationHandlers(); const [open, setOpen] = useState(false); const router = useRouter(); - const intent = keys > 0 ? `delete this api and ${keys} key${keys > 1 ? "s" : ""}` : "delete this api"; @@ -54,7 +55,7 @@ export const DeleteApi: React.FC = ({ api, keys }) => { const deleteApi = trpc.api.delete.useMutation({ async onSuccess() { onDeleteSuccess(keys)(); - router.push("/apis"); + router.push(`/${workspace.slug}/apis`); }, onError, }); diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/delete-protection.tsx similarity index 99% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/delete-protection.tsx index 3097bbcde1..1e998fea65 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/delete-protection.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/delete-protection.tsx @@ -80,7 +80,7 @@ export const DeleteProtection: React.FC = ({ api }) => { ) } border="top" - className="border-b-1" + className="border-b" >
{api.deleteProtection ? ( diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/key-settings-form-helper.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/key-settings-form-helper.ts similarity index 89% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/components/key-settings-form-helper.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/key-settings-form-helper.ts index bdb583f737..c5e5b5fbc9 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/key-settings-form-helper.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/key-settings-form-helper.ts @@ -14,6 +14,13 @@ const createInvalidationHelper = () => { utils.api.overview.query.invalidate(); utils.api.queryApiKeyDetails.invalidate(); }, + /** + * Invalidates only workspace-level queries after API deletion + * Doesn't invalidate API-specific queries since the API no longer exists + */ + invalidateAfterApiDeletion: () => { + utils.api.overview.query.invalidate(); + }, }; }; @@ -47,7 +54,7 @@ export const handleMutationError = (err: unknown) => { * Standard mutation handlers for API operations */ export const createMutationHandlers = () => { - const { invalidateApiQueries } = createInvalidationHelper(); + const { invalidateApiQueries, invalidateAfterApiDeletion } = createInvalidationHelper(); return { /** @@ -82,7 +89,7 @@ export const createMutationHandlers = () => { toast.success("API Deleted", { description: `Your API and ${keyCount} keys have been deleted.`, }); - invalidateApiQueries(); + invalidateAfterApiDeletion(); }, }; }; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/settings-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/settings-client.tsx similarity index 94% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/components/settings-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/settings-client.tsx index 609bae59bd..38cf74d965 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/settings-client.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/settings-client.tsx @@ -31,7 +31,7 @@ export const SettingsClient = ({ apiId }: { apiId: string }) => { throw new Error("KeyAuth configuration not found"); } - const { currentApi, keyAuth, workspace } = layoutData; + const { currentApi, keyAuth, workspace: workspaceData } = layoutData; const api = { id: currentApi.id, @@ -49,7 +49,7 @@ export const SettingsClient = ({ apiId }: { apiId: string }) => { }; const workspaceForComponents = { - features: { ipWhitelist: workspace.ipWhitelist }, + features: { ipWhitelist: workspaceData.ipWhitelist }, }; return ( diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/skeleton.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/skeleton.tsx similarity index 98% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/components/skeleton.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/skeleton.tsx index e4ed3f55a1..90f5ea32ed 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/skeleton.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/skeleton.tsx @@ -12,7 +12,7 @@ export const SettingsClientSkeleton = () => { {/* Name and ID cards skeleton */}
{/* Name card skeleton - border="top" */} -
+
@@ -49,7 +49,7 @@ export const SettingsClientSkeleton = () => { {/* Default bytes and prefix cards skeleton */}
{/* Default bytes card skeleton - border="top" */} -
+
@@ -121,7 +121,7 @@ export const SettingsClientSkeleton = () => { {/* Delete protection and delete API cards skeleton */}
{/* Delete protection card skeleton - border="top" */} -
+
diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/status-badge.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/status-badge.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/components/status-badge.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/status-badge.tsx diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-api-name.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/update-api-name.tsx similarity index 98% rename from apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-api-name.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/update-api-name.tsx index 1e29dd2341..52129281d2 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/components/update-api-name.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/update-api-name.tsx @@ -66,7 +66,7 @@ export const UpdateApiName: React.FC = ({ api }) => { title="Name" description="Change the name of your API. This is only visible to you and your team." border="top" - className="border-b-1" + className="border-b" contentWidth="w-full lg:w-[420px] h-full justify-end items-end" > diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/api-list-card.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/api-list-card.tsx new file mode 100644 index 0000000000..d1f33dac2f --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/api-list-card.tsx @@ -0,0 +1,67 @@ +"use client"; +import { StatsCard } from "@/components/stats-card"; +import { StatsTimeseriesBarChart } from "@/components/stats-card/components/chart/stats-chart"; +import { MetricStats } from "@/components/stats-card/components/metric-stats"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; +import { formatNumber } from "@/lib/fmt"; +import type { ApiOverview } from "@/lib/trpc/routers/api/overview/query-overview/schemas"; +import { Key, ProgressBar } from "@unkey/icons"; +import { Loading } from "@unkey/ui"; +import { Suspense } from "react"; +import { useFetchVerificationTimeseries } from "./hooks/use-query-timeseries"; +type Props = { + api: ApiOverview; +}; + +export const ApiListCard = ({ api }: Props) => { + const { timeseries, isError } = useFetchVerificationTimeseries(api.keyspaceId); + const workspace = useWorkspaceNavigation(); + const passed = timeseries?.reduce((acc, crr) => acc + crr.success, 0) ?? 0; + const blocked = timeseries?.reduce((acc, crr) => acc + crr.error, 0) ?? 0; + + const keyCount = api.keys.reduce((acc, crr) => acc + crr.count, 0); + return ( + }> + + } + stats={ + <> + +
+ +
+ {`${formatNumber(keyCount)} ${keyCount === 1 ? "Key" : "Keys"}`} +
+
+ + } + icon={} + /> +
+ ); +}; diff --git a/apps/dashboard/app/(app)/apis/_components/api-list-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/api-list-client.tsx similarity index 96% rename from apps/dashboard/app/(app)/apis/_components/api-list-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/api-list-client.tsx index 2256810f9d..45232c4938 100644 --- a/apps/dashboard/app/(app)/apis/_components/api-list-client.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/api-list-client.tsx @@ -14,7 +14,7 @@ import { ApiCardSkeleton } from "./skeleton"; const DEFAULT_LIMIT = 10; -export const ApiListClient = () => { +export const ApiListClient = ({ workspaceSlug }: { workspaceSlug: string }) => { const router = useRouter(); const searchParams = useSearchParams(); const isNewApi = searchParams?.get("new") === "true"; @@ -112,7 +112,7 @@ export const ApiListClient = () => { {!isSearching && ( - + & Props) => { const [isOpen, setIsOpen] = useState(defaultOpen ?? false); const router = useRouter(); const { api } = trpc.useUtils(); - const { register, handleSubmit, @@ -49,9 +50,9 @@ export const CreateApiButton = ({ const create = trpc.api.create.useMutation({ async onSuccess(res) { toast.success("Your API has been created"); - await revalidate("/apis"); + await revalidate(`/${workspaceSlug}/apis`); api.overview.query.invalidate(); - router.push(`/apis/${res.id}`); + router.push(`/${workspaceSlug}/apis/${res.id}`); setIsOpen(false); }, onError(err) { diff --git a/apps/dashboard/app/(app)/apis/_components/filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/_components/filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/filters.schema.ts diff --git a/apps/dashboard/app/(app)/apis/_components/hooks/query-timeseries.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/hooks/query-timeseries.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/_components/hooks/query-timeseries.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/hooks/query-timeseries.schema.ts diff --git a/apps/dashboard/app/(app)/apis/_components/hooks/use-fetch-api-overview.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/hooks/use-fetch-api-overview.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/_components/hooks/use-fetch-api-overview.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/hooks/use-fetch-api-overview.ts diff --git a/apps/dashboard/app/(app)/apis/_components/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/_components/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/apis/_components/hooks/use-query-timeseries.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/hooks/use-query-timeseries.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/_components/hooks/use-query-timeseries.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/hooks/use-query-timeseries.ts diff --git a/apps/dashboard/app/(app)/apis/_components/skeleton.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/skeleton.tsx similarity index 100% rename from apps/dashboard/app/(app)/apis/_components/skeleton.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/_components/skeleton.tsx diff --git a/apps/dashboard/app/(app)/apis/actions.ts b/apps/dashboard/app/(app)/[workspaceSlug]/apis/actions.ts similarity index 100% rename from apps/dashboard/app/(app)/apis/actions.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/actions.ts diff --git a/apps/dashboard/app/(app)/apis/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/apis/page.tsx similarity index 75% rename from apps/dashboard/app/(app)/apis/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/apis/page.tsx index c4bd82010f..14e53a0b40 100644 --- a/apps/dashboard/app/(app)/apis/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/apis/page.tsx @@ -1,13 +1,15 @@ "use client"; - import { PostAuthInvitationHandler } from "@/components/auth/post-auth-invitation-handler"; import { Navbar } from "@/components/navigation/navbar"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { Nodes } from "@unkey/icons"; import { useSearchParams } from "next/navigation"; import { ApiListClient } from "./_components/api-list-client"; import { CreateApiButton } from "./_components/create-api-button"; export default function ApisOverviewPage() { + const workspace = useWorkspaceNavigation(); + const searchParams = useSearchParams(); const isNewApi = searchParams?.get("new") === "true"; @@ -16,15 +18,15 @@ export default function ApisOverviewPage() { }> - + APIs - + - +
); } diff --git a/apps/dashboard/app/(app)/audit/actions.ts b/apps/dashboard/app/(app)/[workspaceSlug]/audit/actions.ts similarity index 100% rename from apps/dashboard/app/(app)/audit/actions.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/actions.ts diff --git a/apps/dashboard/app/(app)/audit/components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-datetime/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-datetime/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-datetime/index.tsx diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/bucket-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/bucket-filter.tsx similarity index 82% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/bucket-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/bucket-filter.tsx index 531a7a8c17..0bb2552ddb 100644 --- a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/bucket-filter.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/bucket-filter.tsx @@ -1,11 +1,7 @@ -import { useFilters } from "@/app/(app)/audit/hooks/use-filters"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/audit/hooks/use-filters"; import { FilterCheckbox } from "@/components/logs/checkbox/filter-checkbox"; -export const BucketFilter = ({ - buckets, -}: { - buckets: string[]; -}) => { +export const BucketFilter = ({ buckets }: { buckets: string[] }) => { const { filters, updateFilters } = useFilters(); return ( diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/events-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/events-filter.tsx similarity index 91% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/events-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/events-filter.tsx index 65fbda6f0c..f5836939df 100644 --- a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/events-filter.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/events-filter.tsx @@ -1,4 +1,4 @@ -import { useFilters } from "@/app/(app)/audit/hooks/use-filters"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/audit/hooks/use-filters"; import { FilterCheckbox } from "@/components/logs/checkbox/filter-checkbox"; import { unkeyAuditLogEvents } from "@unkey/schema/src/auditlog"; diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/root-keys-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/root-keys-filter.tsx similarity index 93% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/root-keys-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/root-keys-filter.tsx index 67cb6b8bdd..791962ee96 100644 --- a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/root-keys-filter.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/root-keys-filter.tsx @@ -1,4 +1,4 @@ -import { useFilters } from "@/app/(app)/audit/hooks/use-filters"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/audit/hooks/use-filters"; import { FilterCheckbox } from "@/components/logs/checkbox/filter-checkbox"; import { shortenId } from "@/lib/shorten-id"; diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/users-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/users-filter.tsx similarity index 90% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/users-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/users-filter.tsx index 9d098908e1..441f4f6e21 100644 --- a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/components/users-filter.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/components/users-filter.tsx @@ -1,4 +1,4 @@ -import { useFilters } from "@/app/(app)/audit/hooks/use-filters"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/audit/hooks/use-filters"; import { FilterCheckbox } from "@/components/logs/checkbox/filter-checkbox"; export const UsersFilter = ({ diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/index.tsx similarity index 96% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/index.tsx index 86ea2c2429..0ca5ab2b0d 100644 --- a/apps/dashboard/app/(app)/audit/components/controls/components/logs-filters/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-filters/index.tsx @@ -1,4 +1,4 @@ -import { useFilters } from "@/app/(app)/audit/hooks/use-filters"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/audit/hooks/use-filters"; import { FiltersPopover } from "@/components/logs/checkbox/filters-popover"; import { BarsFilter } from "@unkey/icons"; import { Button } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-queries/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-queries/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-queries/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-queries/index.tsx diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-queries/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-queries/utils.ts similarity index 94% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-queries/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-queries/utils.ts index 46007f79f1..65adccc660 100644 --- a/apps/dashboard/app/(app)/audit/components/controls/components/logs-queries/utils.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-queries/utils.ts @@ -1,4 +1,4 @@ -import type { QuerySearchParams } from "@/app/(app)/audit/filters.schema"; +import type { QuerySearchParams } from "@/app/(app)/[workspaceSlug]/audit/filters.schema"; import { iconsPerField } from "@/components/logs/queries/utils"; import { ChartActivity2 } from "@unkey/icons"; import { format } from "date-fns"; @@ -93,7 +93,10 @@ export function formatFilterValues( export function getFilterFieldIcon(field: string): JSX.Element { const Icon = iconsPerField[field] || ChartActivity2; - return React.createElement(Icon, { size: "md-regular", className: "justify-center" }); + return React.createElement(Icon, { + size: "md-regular", + className: "justify-center", + }); } export const FieldsToTruncate = [ diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-refresh.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-refresh.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-refresh.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-refresh.tsx diff --git a/apps/dashboard/app/(app)/audit/components/controls/components/logs-search/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-search/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/controls/components/logs-search/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/components/logs-search/index.tsx diff --git a/apps/dashboard/app/(app)/audit/components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/controls/index.tsx diff --git a/apps/dashboard/app/(app)/audit/components/logs-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/logs-client.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/logs-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/logs-client.tsx diff --git a/apps/dashboard/app/(app)/audit/components/table/hooks/use-logs-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/hooks/use-logs-query.ts similarity index 100% rename from apps/dashboard/app/(app)/audit/components/table/hooks/use-logs-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/hooks/use-logs-query.ts diff --git a/apps/dashboard/app/(app)/audit/components/table/log-details/components/log-footer.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/log-details/components/log-footer.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/table/log-details/components/log-footer.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/log-details/components/log-footer.tsx diff --git a/apps/dashboard/app/(app)/audit/components/table/log-details/components/log-header.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/log-details/components/log-header.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/table/log-details/components/log-header.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/log-details/components/log-header.tsx diff --git a/apps/dashboard/app/(app)/audit/components/table/log-details/components/log-section.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/log-details/components/log-section.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/table/log-details/components/log-section.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/log-details/components/log-section.tsx diff --git a/apps/dashboard/app/(app)/audit/components/table/log-details/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/log-details/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/table/log-details/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/log-details/index.tsx diff --git a/apps/dashboard/app/(app)/audit/components/table/logs-table.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/logs-table.tsx similarity index 100% rename from apps/dashboard/app/(app)/audit/components/table/logs-table.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/logs-table.tsx diff --git a/apps/dashboard/app/(app)/audit/components/table/query-logs.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/query-logs.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/audit/components/table/query-logs.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/query-logs.schema.ts diff --git a/apps/dashboard/app/(app)/audit/components/table/utils/get-row-class.ts b/apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/utils/get-row-class.ts similarity index 100% rename from apps/dashboard/app/(app)/audit/components/table/utils/get-row-class.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/components/table/utils/get-row-class.ts diff --git a/apps/dashboard/app/(app)/audit/constants.ts b/apps/dashboard/app/(app)/[workspaceSlug]/audit/constants.ts similarity index 100% rename from apps/dashboard/app/(app)/audit/constants.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/constants.ts diff --git a/apps/dashboard/app/(app)/audit/filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/audit/filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/audit/filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/filters.schema.ts diff --git a/apps/dashboard/app/(app)/audit/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/audit/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/audit/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/audit/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/audit/page.tsx similarity index 86% rename from apps/dashboard/app/(app)/audit/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/audit/page.tsx index ccd9c011d8..fc364f7681 100644 --- a/apps/dashboard/app/(app)/audit/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/audit/page.tsx @@ -11,7 +11,7 @@ export default async function AuditPage() { return (
- } /> + } />
); diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/authorization/constants.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/constants.ts new file mode 100644 index 0000000000..a2b1324f6c --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/constants.ts @@ -0,0 +1,12 @@ +export const navigation = (workspaceSlug: string) => [ + { + label: "Roles", + href: `/${workspaceSlug}/authorization/roles`, + segment: "roles", + }, + { + label: "Permissions", + href: `/${workspaceSlug}/authorization/permissions`, + segment: "permissions", + }, +]; diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/controls/components/logs-filters/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/controls/components/logs-filters/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/controls/components/logs-filters/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/controls/components/logs-filters/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/controls/components/logs-search/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/controls/components/logs-search/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/controls/components/logs-search/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/controls/components/logs-search/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/controls/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/controls/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/components/delete-permission.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/components/delete-permission.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/components/delete-permission.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/components/delete-permission.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/components/edit-permission.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/components/edit-permission.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/components/edit-permission.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/components/edit-permission.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/components/hooks/use-delete-permission.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/components/hooks/use-delete-permission.ts similarity index 95% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/components/hooks/use-delete-permission.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/components/hooks/use-delete-permission.ts index 0785a93f1b..35c6e3441a 100644 --- a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/components/hooks/use-delete-permission.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/components/hooks/use-delete-permission.ts @@ -9,9 +9,9 @@ export const useDeletePermission = ( ) => { const trpcUtils = trpc.useUtils(); const deletePermission = trpc.authorization.permissions.delete.useMutation({ - onSuccess(_, variables) { + onSuccess(data, variables) { trpcUtils.authorization.permissions.invalidate(); - const permissionCount = variables.permissionIds.length; + const permissionCount = data.deletedCount; const isPlural = permissionCount > 1; toast.success(isPlural ? "Permissions Deleted" : "Permission Deleted", { description: isPlural diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/components/permission-info.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/components/permission-info.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/components/permission-info.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/components/permission-info.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/keys-table-action.popover.constants.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/keys-table-action.popover.constants.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/components/actions/keys-table-action.popover.constants.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/actions/keys-table-action.popover.constants.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/assigned-items-cell.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/assigned-items-cell.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/components/assigned-items-cell.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/assigned-items-cell.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/last-updated.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/last-updated.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/components/last-updated.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/last-updated.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/selection-controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/selection-controls/index.tsx similarity index 95% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/components/selection-controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/selection-controls/index.tsx index d8fc0a969f..e9fda54446 100644 --- a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/selection-controls/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/selection-controls/index.tsx @@ -1,4 +1,4 @@ -import { AnimatedCounter } from "@/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls"; +import { AnimatedCounter } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls"; import { ConfirmPopover } from "@/components/confirmation-popover"; import { Trash, XMark } from "@unkey/icons"; import { Button } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/components/skeletons.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/skeletons.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/components/skeletons.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/components/skeletons.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/hooks/use-permissions-list-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/hooks/use-permissions-list-query.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/hooks/use-permissions-list-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/hooks/use-permissions-list-query.ts diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/permissions-list.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/permissions-list.tsx similarity index 97% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/permissions-list.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/permissions-list.tsx index 29c47a5175..ba2836aefc 100644 --- a/apps/dashboard/app/(app)/authorization/permissions/components/table/permissions-list.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/permissions-list.tsx @@ -28,13 +28,13 @@ export const PermissionsList = () => { const [selectedPermissions, setSelectedPermissions] = useState>(new Set()); const [hoveredPermissionName, setHoveredPermissionName] = useState(null); - const toggleSelection = useCallback((permissionName: string) => { + const toggleSelection = useCallback((permissionId: string) => { setSelectedPermissions((prevSelected) => { const newSelected = new Set(prevSelected); - if (newSelected.has(permissionName)) { - newSelected.delete(permissionName); + if (newSelected.has(permissionId)) { + newSelected.delete(permissionId); } else { - newSelected.add(permissionName); + newSelected.add(permissionId); } return newSelected; }); @@ -48,7 +48,7 @@ export const PermissionsList = () => { width: "20%", headerClassName: "pl-[18px]", render: (permission) => { - const isSelected = selectedPermissions.has(permission.name); + const isSelected = selectedPermissions.has(permission.permissionId); const isHovered = hoveredPermissionName === permission.name; const iconContainer = ( @@ -66,7 +66,7 @@ export const PermissionsList = () => { toggleSelection(permission.name)} + onCheckedChange={() => toggleSelection(permission.permissionId)} /> )}
diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/query-logs.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/query-logs.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/query-logs.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/query-logs.schema.ts diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/table/utils/get-row-class.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/utils/get-row-class.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/table/utils/get-row-class.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/table/utils/get-row-class.ts diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/upsert-permission/hooks/use-upsert-permission.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/upsert-permission/hooks/use-upsert-permission.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/upsert-permission/hooks/use-upsert-permission.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/upsert-permission/hooks/use-upsert-permission.ts diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/upsert-permission/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/upsert-permission/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/upsert-permission/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/upsert-permission/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/permissions/components/upsert-permission/upsert-permission.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/upsert-permission/upsert-permission.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/components/upsert-permission/upsert-permission.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/components/upsert-permission/upsert-permission.schema.ts diff --git a/apps/dashboard/app/(app)/authorization/permissions/filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/filters.schema.ts diff --git a/apps/dashboard/app/(app)/authorization/permissions/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/authorization/permissions/navigation.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/navigation.tsx similarity index 70% rename from apps/dashboard/app/(app)/authorization/permissions/navigation.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/navigation.tsx index 02de121cbe..19ab23739c 100644 --- a/apps/dashboard/app/(app)/authorization/permissions/navigation.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/navigation.tsx @@ -1,6 +1,7 @@ "use client"; import { NavbarActionButton } from "@/components/navigation/action-button"; import { Navbar } from "@/components/navigation/navbar"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { Plus, ShieldKey } from "@unkey/icons"; import dynamic from "next/dynamic"; @@ -18,11 +19,15 @@ const UpsertPermissionDialog = dynamic( ); export function Navigation() { + const workspace = useWorkspaceNavigation(); + return ( } className="flex-1 w-full"> - Authorization - + + Authorization + + Permissions diff --git a/apps/dashboard/app/(app)/authorization/permissions/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/page.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/permissions/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/permissions/page.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/controls/components/logs-filters/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/controls/components/logs-filters/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/controls/components/logs-filters/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/controls/components/logs-filters/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/controls/components/logs-search/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/controls/components/logs-search/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/controls/components/logs-search/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/controls/components/logs-search/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/controls/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/controls/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/delete-role.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/delete-role.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/delete-role.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/delete-role.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/edit-role.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/edit-role.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/edit-role.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/edit-role.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/hooks/use-delete-role.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/hooks/use-delete-role.ts similarity index 96% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/hooks/use-delete-role.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/hooks/use-delete-role.ts index 5b8b0ba750..13e5ec8860 100644 --- a/apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/hooks/use-delete-role.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/hooks/use-delete-role.ts @@ -6,10 +6,10 @@ export const useDeleteRole = ( ) => { const trpcUtils = trpc.useUtils(); const deleteRole = trpc.authorization.roles.delete.useMutation({ - onSuccess(_, variables) { + onSuccess(data, variables) { trpcUtils.authorization.roles.invalidate(); - const roleCount = variables.roleIds.length; + const roleCount = data.deletedCount; const isPlural = roleCount > 1; toast.success(isPlural ? "Roles Deleted" : "Role Deleted", { diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/hooks/use-fetch-connected-keys-and-perms.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/hooks/use-fetch-connected-keys-and-perms.ts similarity index 83% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/hooks/use-fetch-connected-keys-and-perms.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/hooks/use-fetch-connected-keys-and-perms.ts index 4c81d03316..3af054a4ee 100644 --- a/apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/hooks/use-fetch-connected-keys-and-perms.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/hooks/use-fetch-connected-keys-and-perms.ts @@ -1,4 +1,4 @@ -import { useRoleLimits } from "@/app/(app)/authorization/roles/components/table/hooks/use-role-limits"; +import { useRoleLimits } from "@/app/(app)/[workspaceSlug]/authorization/roles/components/table/hooks/use-role-limits"; import { trpc } from "@/lib/trpc/client"; export const useFetchConnectedKeysAndPermsData = (roleId: string) => { diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/role-info.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/role-info.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/components/role-info.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/components/role-info.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/keys-table-action.popover.constants.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/keys-table-action.popover.constants.tsx similarity index 94% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/keys-table-action.popover.constants.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/keys-table-action.popover.constants.tsx index dfde9dc432..3f071c314e 100644 --- a/apps/dashboard/app/(app)/authorization/roles/components/table/components/actions/keys-table-action.popover.constants.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/actions/keys-table-action.popover.constants.tsx @@ -14,10 +14,13 @@ import { MAX_PERMS_FETCH_LIMIT } from "../../../upsert-role/components/assign-pe import { DeleteRole } from "./components/delete-role"; import { EditRole } from "./components/edit-role"; +// Wrapper component to handle React Loadable props +const LoadingTrigger = () => ; + const KeysTableActionPopover = dynamic( () => import("@/components/logs/table-action.popover").then((mod) => mod.TableActionPopover), { - loading: TableActionPopoverDefaultTrigger, + loading: LoadingTrigger, }, ); diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/assigned-items-cell.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/assigned-items-cell.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/assigned-items-cell.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/assigned-items-cell.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/last-updated.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/last-updated.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/last-updated.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/last-updated.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/selection-controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/selection-controls/index.tsx similarity index 95% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/selection-controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/selection-controls/index.tsx index 068625af5d..59675bb9fe 100644 --- a/apps/dashboard/app/(app)/authorization/roles/components/table/components/selection-controls/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/selection-controls/index.tsx @@ -1,4 +1,4 @@ -import { AnimatedCounter } from "@/app/(app)/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls"; +import { AnimatedCounter } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/keys/[keyAuthId]/_components/components/table/components/selection-controls"; import { ConfirmPopover } from "@/components/confirmation-popover"; import { Trash, XMark } from "@unkey/icons"; import { Button } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/components/skeletons.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/skeletons.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/components/skeletons.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/components/skeletons.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/hooks/use-role-limits.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/hooks/use-role-limits.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/hooks/use-role-limits.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/hooks/use-role-limits.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/hooks/use-roles-list-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/hooks/use-roles-list-query.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/hooks/use-roles-list-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/hooks/use-roles-list-query.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/query-logs.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/query-logs.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/query-logs.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/query-logs.schema.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/roles-list.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/roles-list.tsx similarity index 96% rename from apps/dashboard/app/(app)/authorization/roles/components/table/roles-list.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/roles-list.tsx index fb4056b34c..52783abf08 100644 --- a/apps/dashboard/app/(app)/authorization/roles/components/table/roles-list.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/roles-list.tsx @@ -27,13 +27,13 @@ export const RolesList = () => { const [selectedRoles, setSelectedRoles] = useState>(new Set()); const [hoveredRoleName, setHoveredRoleName] = useState(null); - const toggleSelection = useCallback((roleName: string) => { + const toggleSelection = useCallback((roleId: string) => { setSelectedRoles((prevSelected) => { const newSelected = new Set(prevSelected); - if (newSelected.has(roleName)) { - newSelected.delete(roleName); + if (newSelected.has(roleId)) { + newSelected.delete(roleId); } else { - newSelected.add(roleName); + newSelected.add(roleId); } return newSelected; }); @@ -47,7 +47,7 @@ export const RolesList = () => { width: "20%", headerClassName: "pl-[18px]", render: (role) => { - const isSelected = selectedRoles.has(role.name); + const isSelected = selectedRoles.has(role.roleId); const isHovered = hoveredRoleName === role.name; const iconContainer = ( @@ -65,7 +65,7 @@ export const RolesList = () => { toggleSelection(role.name)} + onCheckedChange={() => toggleSelection(role.roleId)} /> )}
diff --git a/apps/dashboard/app/(app)/authorization/roles/components/table/utils/get-row-class.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/utils/get-row-class.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/table/utils/get-row-class.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/table/utils/get-row-class.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-key/create-key-options.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/create-key-options.tsx similarity index 97% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-key/create-key-options.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/create-key-options.tsx index 4b6d18a168..aaebfb594e 100644 --- a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-key/create-key-options.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/create-key-options.tsx @@ -1,4 +1,4 @@ -import { StatusBadge } from "@/app/(app)/apis/[apiId]/settings/components/status-badge"; +import { StatusBadge } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/status-badge"; import { Key2, Lock } from "@unkey/icons"; import { Badge, Button, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-key/hooks/use-fetch-keys.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/hooks/use-fetch-keys.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-key/hooks/use-fetch-keys.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/hooks/use-fetch-keys.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-key/hooks/use-search-keys.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/hooks/use-search-keys.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-key/hooks/use-search-keys.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/hooks/use-search-keys.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-key/key-field.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/key-field.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-key/key-field.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-key/key-field.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-permission/create-permission-options.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-permission/create-permission-options.tsx similarity index 98% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-permission/create-permission-options.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-permission/create-permission-options.tsx index 79dd61fa7b..a807ec72d4 100644 --- a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-permission/create-permission-options.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-permission/create-permission-options.tsx @@ -1,4 +1,4 @@ -import { StatusBadge } from "@/app/(app)/apis/[apiId]/settings/components/status-badge"; +import { StatusBadge } from "@/app/(app)/[workspaceSlug]/apis/[apiId]/settings/components/status-badge"; import { Lock, Page2 } from "@unkey/icons"; import { Badge, Button, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-permission/hooks/use-fetch-permissions.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-permission/hooks/use-fetch-permissions.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-permission/hooks/use-fetch-permissions.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-permission/hooks/use-fetch-permissions.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-permission/hooks/use-search-permissions.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-permission/hooks/use-search-permissions.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-permission/hooks/use-search-permissions.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-permission/hooks/use-search-permissions.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-permission/permissions-field.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-permission/permissions-field.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/assign-permission/permissions-field.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/assign-permission/permissions-field.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/warning-callout.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/warning-callout.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/components/warning-callout.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/components/warning-callout.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/hooks/use-upsert-role.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/hooks/use-upsert-role.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/hooks/use-upsert-role.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/hooks/use-upsert-role.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/index.tsx diff --git a/apps/dashboard/app/(app)/authorization/roles/components/upsert-role/upsert-role.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/upsert-role.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/components/upsert-role/upsert-role.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/components/upsert-role/upsert-role.schema.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/filters.schema.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/authorization/roles/navigation.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/navigation.tsx similarity index 69% rename from apps/dashboard/app/(app)/authorization/roles/navigation.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/navigation.tsx index d6e34308e3..bc512f827f 100644 --- a/apps/dashboard/app/(app)/authorization/roles/navigation.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/navigation.tsx @@ -1,6 +1,7 @@ "use client"; import { NavbarActionButton } from "@/components/navigation/action-button"; import { Navbar } from "@/components/navigation/navbar"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { Plus, ShieldKey } from "@unkey/icons"; import dynamic from "next/dynamic"; @@ -18,11 +19,15 @@ const UpsertRoleDialog = dynamic( ); export function Navigation() { + const workspace = useWorkspaceNavigation(); + return ( } className="flex-1 w-full"> - Authorization - + + Authorization + + Roles diff --git a/apps/dashboard/app/(app)/authorization/roles/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/page.tsx similarity index 100% rename from apps/dashboard/app/(app)/authorization/roles/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/authorization/roles/page.tsx diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/identities/[identityId]/navigation.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/identities/[identityId]/navigation.tsx new file mode 100644 index 0000000000..f1d03f0849 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/identities/[identityId]/navigation.tsx @@ -0,0 +1,30 @@ +"use client"; + +import { Navbar } from "@/components/navigation/navbar"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; +import { Fingerprint } from "@unkey/icons"; + +type NavigationProps = { + readonly identityId: string; +}; + +export function Navigation({ identityId }: NavigationProps): JSX.Element { + const workspace = useWorkspaceNavigation(); + + return ( + + + + ); +} diff --git a/apps/dashboard/app/(app)/identities/[identityId]/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/identities/[identityId]/page.tsx similarity index 91% rename from apps/dashboard/app/(app)/identities/[identityId]/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/identities/[identityId]/page.tsx index 9baca8075d..a975aa4cfa 100644 --- a/apps/dashboard/app/(app)/identities/[identityId]/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/identities/[identityId]/page.tsx @@ -1,5 +1,3 @@ -import { notFound } from "next/navigation"; - import { PageContent } from "@/components/page-content"; import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; import { @@ -18,7 +16,9 @@ import { Badge, Button, Code, CopyButton } from "@unkey/ui"; import { ChevronRight, Minus } from "lucide-react"; import ms from "ms"; import Link from "next/link"; +import { notFound } from "next/navigation"; import { Navigation } from "./navigation"; + type Props = { params: { identityId: string; @@ -32,7 +32,9 @@ export default async function Page(props: Props) { with: { workspace: { columns: { + id: true, orgId: true, + slug: true, }, }, keys: { @@ -139,18 +141,26 @@ export default async function Page(props: Props) { {key.id} {key.meta ? ( - JSON.stringify(JSON.parse(key.meta), null, 2) + (() => { + try { + return JSON.stringify(JSON.parse(key.meta), null, 2); + } catch { + return key.meta; + } + })() ) : ( )} - + diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/identities/components/results.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/identities/components/results.tsx new file mode 100644 index 0000000000..551c3e0957 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/identities/components/results.tsx @@ -0,0 +1,81 @@ +"use client"; + +import { Table, TableBody, TableHead, TableHeader, TableRow } from "@/components/ui/table"; +import { trpc } from "@/lib/trpc/client"; +import { Row } from "../row"; + +export const Results: React.FC<{ search: string; limit: number }> = (props) => { + const { + data: workspace, + isLoading, + error, + } = trpc.identity.searchWithRelations.useQuery({ + search: props.search, + limit: props.limit, + }); + + if (isLoading) { + return ( +
+

Loading identities...

+
+ ); + } + + if (error) { + return ( +
+

+ Unable to load identities. Please try refreshing the page or contact support if the issue + persists. +

+
+ ); + } + + if (!workspace) { + return ( +
+

No workspace found.

+
+ ); + } + + return ( + <> + + + + External ID + Meta + Keys + Ratelimits + + + + {workspace.identities.map((identity) => { + return ( + + ); + })} + +
+ {workspace.identities.length === 0 ? ( +

+ No identities found +

+ ) : null} + + ); +}; diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/identities/filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/identities/filter.tsx new file mode 100644 index 0000000000..b5e710ca16 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/identities/filter.tsx @@ -0,0 +1,51 @@ +"use client"; + +import { Search } from "lucide-react"; +import { parseAsString, useQueryState } from "nuqs"; +import { useEffect, useState } from "react"; + +export function SearchField(): JSX.Element { + const [search, setSearch] = useQueryState( + "search", + parseAsString.withDefault("").withOptions({ + history: "replace", + shallow: true, + clearOnDefault: true, + }), + ); + + // Local draft state for immediate UI updates + const [draft, setDraft] = useState(search ?? ""); + + // Update draft when search changes (e.g., from browser back/forward) + useEffect(() => { + setDraft(search ?? ""); + }, [search]); + + // Debounced search update + useEffect(() => { + const timeoutId = setTimeout(() => { + if (draft !== search) { + setSearch(draft); + } + }, 300); // 300ms debounce + + return () => clearTimeout(timeoutId); + }, [draft, search, setSearch]); + + return ( +
+
+ ); +} diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/identities/navigation.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/identities/navigation.tsx new file mode 100644 index 0000000000..05648fc1c1 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/identities/navigation.tsx @@ -0,0 +1,19 @@ +"use client"; + +import { Navbar } from "@/components/navigation/navbar"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; +import { Fingerprint } from "@unkey/icons"; + +export function Navigation() { + const workspace = useWorkspaceNavigation(); + + return ( + + + + ); +} diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/identities/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/identities/page.tsx new file mode 100644 index 0000000000..503fe837b1 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/identities/page.tsx @@ -0,0 +1,60 @@ +"use client"; +import { OptIn } from "@/components/opt-in"; +import { PageContent } from "@/components/page-content"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; +import { Empty } from "@unkey/ui"; +import { Loader2 } from "lucide-react"; +import { Suspense } from "react"; +import { z } from "zod"; +import { Results } from "./components/results"; +import { SearchField } from "./filter"; +import { Navigation } from "./navigation"; +export const dynamic = "force-dynamic"; + +type Props = { + searchParams: { + search?: string; + limit?: string; + }; +}; + +const DEFAULT_LIMIT = 100; + +const searchParamsSchema = z.object({ + search: z.string().optional(), + limit: z.string().regex(/^\d+$/).optional(), +}); + +export default function Page(props: Props) { + const validatedParams = searchParamsSchema.parse(props.searchParams); + const search = validatedParams.search ?? ""; + const limit = validatedParams.limit ? Number.parseInt(validatedParams.limit, 10) : DEFAULT_LIMIT; + + const workspace = useWorkspaceNavigation(); + + if (!workspace.betaFeatures.identities) { + return ; + } + + return ( +
+ + + +
+ + + + + + } + > + + +
+
+
+ ); +} diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/identities/row.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/identities/row.tsx new file mode 100644 index 0000000000..49f73e340b --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/identities/row.tsx @@ -0,0 +1,90 @@ +"use client"; + +import { TableCell, TableRow } from "@/components/ui/table"; +import { useRouter } from "next/navigation"; +import { memo, useCallback, useMemo, useRef } from "react"; + +type Props = { + identity: { + id: string; + externalId: string; + meta?: Record; + ratelimits: Array<{ + id: string; + }>; + keys: Array<{ + id: string; + }>; + workspaceId: string; + }; + workspaceSlug: string; +}; + +function RowComponent(props: Props) { + const { identity, workspaceSlug } = props; + const router = useRouter(); + + const detailsUrl = useMemo(() => { + const encodedWorkspaceId = encodeURIComponent(workspaceSlug); + const encodedId = encodeURIComponent(identity.id); + return `/${encodedWorkspaceId}/identities/${encodedId}`; + }, [workspaceSlug, identity.id]); + + const prefetchTimeoutRef = useRef(null); + const hasPrefetchedRef = useRef(false); + + const handlePrefetch = useCallback(() => { + if (hasPrefetchedRef.current) { + return; + } + + if (prefetchTimeoutRef.current) { + clearTimeout(prefetchTimeoutRef.current); + } + + prefetchTimeoutRef.current = setTimeout(() => { + // Use Link's built-in prefetch behavior instead of manual router.prefetch + hasPrefetchedRef.current = true; + }, 100); // 100ms debounce + }, []); + + const handleRowClick = useCallback(() => { + router.push(detailsUrl); + }, [router, detailsUrl]); + + return ( + { + if (e.key === "Enter" || e.key === " ") { + e.preventDefault(); + handleRowClick(); + } + }} + aria-label={`View details for identity ${identity.externalId}`} + > + + {identity.externalId} + + +
+          {JSON.stringify(identity.meta, null, 2)}
+        
+
+ + + {identity.keys.length} + + + + {identity.ratelimits.length} + +
+ ); +} + +export const Row = memo(RowComponent); diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/layout.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/layout.tsx new file mode 100644 index 0000000000..8a270fb98a --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/layout.tsx @@ -0,0 +1,23 @@ +"use client"; + +import { Loading } from "@unkey/ui"; +import { Suspense } from "react"; + +interface WorkspaceLayoutProps { + children: React.ReactNode; +} + +function WorkspaceLoadingFallback() { + return ( +
+
+ +

Loading workspace...

+
+
+ ); +} + +export default function WorkspaceLayout({ children }: WorkspaceLayoutProps) { + return }>{children}; +} diff --git a/apps/dashboard/app/(app)/logs/components/charts/hooks/use-fetch-timeseries.ts b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/charts/hooks/use-fetch-timeseries.ts similarity index 100% rename from apps/dashboard/app/(app)/logs/components/charts/hooks/use-fetch-timeseries.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/charts/hooks/use-fetch-timeseries.ts diff --git a/apps/dashboard/app/(app)/logs/components/charts/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/charts/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/charts/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/charts/index.tsx diff --git a/apps/dashboard/app/(app)/logs/components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-datetime/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-datetime/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-datetime/index.tsx diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-display/components/display-popover.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-display/components/display-popover.tsx similarity index 98% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-display/components/display-popover.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-display/components/display-popover.tsx index 11f0cf4440..827c8f86fa 100644 --- a/apps/dashboard/app/(app)/logs/components/controls/components/logs-display/components/display-popover.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-display/components/display-popover.tsx @@ -1,4 +1,4 @@ -import { isDisplayProperty, useLogsContext } from "@/app/(app)/logs/context/logs"; +import { isDisplayProperty, useLogsContext } from "@/app/(app)/[workspaceSlug]/logs/context/logs"; import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; import { useKeyboardShortcut } from "@/hooks/use-keyboard-shortcut"; import { KeyboardButton } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-display/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-display/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-display/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-display/index.tsx diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/components/methods-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/components/methods-filter.tsx similarity index 91% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/components/methods-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/components/methods-filter.tsx index 2887f8f528..9bf227a16f 100644 --- a/apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/components/methods-filter.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/components/methods-filter.tsx @@ -1,4 +1,4 @@ -import { useFilters } from "@/app/(app)/logs/hooks/use-filters"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/logs/hooks/use-filters"; import { FilterCheckbox } from "@/components/logs/checkbox/filter-checkbox"; type MethodOption = { diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/components/paths-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/components/paths-filter.tsx similarity index 92% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/components/paths-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/components/paths-filter.tsx index aaca6342a5..1e28bf2176 100644 --- a/apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/components/paths-filter.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/components/paths-filter.tsx @@ -1,4 +1,4 @@ -import { useFilters } from "@/app/(app)/logs/hooks/use-filters"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/logs/hooks/use-filters"; import { FilterOperatorInput } from "@/components/logs/filter-operator-input"; import { logsFilterFieldConfig } from "@/lib/schemas/logs.filter.schema"; diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/components/status-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/components/status-filter.tsx similarity index 90% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/components/status-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/components/status-filter.tsx index fc574f3f7b..280afd5fdc 100644 --- a/apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/components/status-filter.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/components/status-filter.tsx @@ -1,5 +1,5 @@ -import { useFilters } from "@/app/(app)/logs/hooks/use-filters"; -import type { ResponseStatus } from "@/app/(app)/logs/types"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/logs/hooks/use-filters"; +import type { ResponseStatus } from "@/app/(app)/[workspaceSlug]/logs/types"; import { FilterCheckbox } from "@/components/logs/checkbox/filter-checkbox"; type StatusOption = { diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/index.tsx similarity index 95% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/index.tsx index 38eed0a0b2..313e77e06a 100644 --- a/apps/dashboard/app/(app)/logs/components/controls/components/logs-filters/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-filters/index.tsx @@ -1,4 +1,4 @@ -import { useFilters } from "@/app/(app)/logs/hooks/use-filters"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/logs/hooks/use-filters"; import { type FilterItemConfig, FiltersPopover } from "@/components/logs/checkbox/filters-popover"; import { BarsFilter } from "@unkey/icons"; import { Button } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-live-switch.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-live-switch.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-live-switch.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-live-switch.tsx diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-queries/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-queries/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-queries/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-queries/index.tsx diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-queries/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-queries/utils.ts similarity index 100% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-queries/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-queries/utils.ts diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-refresh.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-refresh.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-refresh.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-refresh.tsx diff --git a/apps/dashboard/app/(app)/logs/components/controls/components/logs-search/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-search/index.tsx similarity index 94% rename from apps/dashboard/app/(app)/logs/components/controls/components/logs-search/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-search/index.tsx index 58a0e5f7d0..09d975528c 100644 --- a/apps/dashboard/app/(app)/logs/components/controls/components/logs-search/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/components/logs-search/index.tsx @@ -1,4 +1,5 @@ -import { useFilters } from "@/app/(app)/logs/hooks/use-filters"; +"use client"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/logs/hooks/use-filters"; import { trpc } from "@/lib/trpc/client"; import { LLMSearch, toast, transformStructuredOutputToFilters } from "@unkey/ui"; diff --git a/apps/dashboard/app/(app)/logs/components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/controls/index.tsx diff --git a/apps/dashboard/app/(app)/logs/components/logs-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/logs-client.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/logs-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/logs-client.tsx diff --git a/apps/dashboard/app/(app)/logs/components/table/hooks/use-logs-query.test.ts b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/table/hooks/use-logs-query.test.ts similarity index 100% rename from apps/dashboard/app/(app)/logs/components/table/hooks/use-logs-query.test.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/table/hooks/use-logs-query.test.ts diff --git a/apps/dashboard/app/(app)/logs/components/table/hooks/use-logs-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/table/hooks/use-logs-query.ts similarity index 100% rename from apps/dashboard/app/(app)/logs/components/table/hooks/use-logs-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/table/hooks/use-logs-query.ts diff --git a/apps/dashboard/app/(app)/logs/components/table/log-details/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/table/log-details/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/table/log-details/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/table/log-details/index.tsx diff --git a/apps/dashboard/app/(app)/logs/components/table/logs-table.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/components/table/logs-table.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/components/table/logs-table.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/components/table/logs-table.tsx diff --git a/apps/dashboard/app/(app)/logs/constants.ts b/apps/dashboard/app/(app)/[workspaceSlug]/logs/constants.ts similarity index 100% rename from apps/dashboard/app/(app)/logs/constants.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/constants.ts diff --git a/apps/dashboard/app/(app)/logs/context/logs.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/context/logs.tsx similarity index 100% rename from apps/dashboard/app/(app)/logs/context/logs.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/context/logs.tsx diff --git a/apps/dashboard/app/(app)/logs/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/logs/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/logs/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/logs/navigation.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/navigation.tsx similarity index 54% rename from apps/dashboard/app/(app)/logs/navigation.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/navigation.tsx index 770fd58fbf..b6ff007647 100644 --- a/apps/dashboard/app/(app)/logs/navigation.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/logs/navigation.tsx @@ -1,13 +1,16 @@ "use client"; import { Navbar } from "@/components/navigation/navbar"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { Layers3 } from "@unkey/icons"; export function Navigation() { + const workspace = useWorkspaceNavigation(); + return ( }> - Logs + Logs ); diff --git a/apps/dashboard/app/(app)/logs/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/logs/page.tsx similarity index 56% rename from apps/dashboard/app/(app)/logs/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/page.tsx index ddb1511017..eadbfe191b 100644 --- a/apps/dashboard/app/(app)/logs/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/logs/page.tsx @@ -1,13 +1,14 @@ "use client"; +import { Navigation } from "@/components/navigation/navigation"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { Layers3 } from "@unkey/icons"; import { LogsClient } from "./components/logs-client"; -import { Navigation } from "@/components/navigation/navigation"; - export default function Page() { + const workspace = useWorkspaceNavigation(); return (
- } /> + } />
); diff --git a/apps/dashboard/app/(app)/logs/types.ts b/apps/dashboard/app/(app)/[workspaceSlug]/logs/types.ts similarity index 100% rename from apps/dashboard/app/(app)/logs/types.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/types.ts diff --git a/apps/dashboard/app/(app)/logs/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/logs/utils.ts similarity index 100% rename from apps/dashboard/app/(app)/logs/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/logs/utils.ts diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/page.tsx new file mode 100644 index 0000000000..a42d0d51e3 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/page.tsx @@ -0,0 +1,10 @@ +"use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; +import { useRouter } from "next/navigation"; + +export default function WorkspacePage() { + const router = useRouter(); + const workspace = useWorkspaceNavigation(); + + router.replace(`/${workspace.slug}/apis`); +} diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_components/delete-dialog.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/delete-dialog.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_components/delete-dialog.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/delete-dialog.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_components/identifier-dialog.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/identifier-dialog.tsx similarity index 93% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_components/identifier-dialog.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/identifier-dialog.tsx index 3e8294e7cc..c2a7ecce17 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_components/identifier-dialog.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/identifier-dialog.tsx @@ -1,5 +1,6 @@ "use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { collection } from "@/lib/collections"; import { zodResolver } from "@hookform/resolvers/zod"; import { DuplicateKeyError } from "@tanstack/react-db"; @@ -43,6 +44,8 @@ export const IdentifierDialog = ({ overrideDetails, isLoading = false, }: Props) => { + const workspace = useWorkspaceNavigation(); + const { register, handleSubmit, @@ -82,11 +85,14 @@ export const IdentifierDialog = ({ duration: values.duration, }); onOpenChange(false); - router.push(`/ratelimits/${namespaceId}/overrides`); + router.push(`/${workspace.slug}/ratelimits/${namespaceId}/overrides`); } } catch (error) { if (error instanceof DuplicateKeyError) { - setError("identifier", { type: "custom", message: "Identifier already exists" }); + setError("identifier", { + type: "custom", + message: "Identifier already exists", + }); } else { throw error; } diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/namespace-delete-dialog.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/namespace-delete-dialog.tsx new file mode 100644 index 0000000000..fe7281c1b4 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/namespace-delete-dialog.tsx @@ -0,0 +1,95 @@ +"use client"; + +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; +import { collection } from "@/lib/collections"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { Button, DialogContainer, Input, Loading } from "@unkey/ui"; +import { useRouter } from "next/navigation"; +import { Suspense } from "react"; +import { useForm } from "react-hook-form"; +import { z } from "zod"; + +const formSchema = z.object({ + name: z + .string() + // biome-ignore lint/suspicious/noSelfCompare: + .refine((v) => v === v, "Please confirm the namespace name"), +}); + +type FormValues = z.infer; +type DeleteNamespaceProps = { + isModalOpen: boolean; + onOpenChange: (value: boolean) => void; + namespace: { + id: string; + name: string; + }; +}; + +export const DeleteNamespaceDialog = ({ + isModalOpen, + onOpenChange, + namespace, +}: DeleteNamespaceProps) => { + const router = useRouter(); + const workspace = useWorkspaceNavigation(); + + const { register, handleSubmit, watch } = useForm({ + mode: "onChange", + resolver: zodResolver(formSchema), + defaultValues: { + name: "", + }, + }); + const isValid = watch("name") === namespace.name; + + const onSubmit = async () => { + collection.ratelimitNamespaces.delete(namespace.id); + router.push(`/${workspace.slug}/ratelimits`); + + //await deleteNamespace.mutateAsync({ namespaceId: namespace.id }); + }; + return ( + }> + + +
+ This action cannot be undone – proceed with caution +
+
+ } + > +

+ Warning: + Deleting this namespace while it is in use may cause your current requests to fail. You + will lose access to analytical data. +

+ + +
+

+ Type {namespace.name} to confirm +

+ + +
+ + + + ); +}; diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/charts/bar-chart/hooks/use-fetch-timeseries.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/charts/bar-chart/hooks/use-fetch-timeseries.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/charts/bar-chart/hooks/use-fetch-timeseries.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/charts/bar-chart/hooks/use-fetch-timeseries.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/charts/bar-chart/query-timeseries.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/charts/bar-chart/query-timeseries.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/charts/bar-chart/query-timeseries.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/charts/bar-chart/query-timeseries.schema.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/charts/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/charts/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/charts/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/charts/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/charts/line-chart/hooks/use-fetch-timeseries.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/charts/line-chart/hooks/use-fetch-timeseries.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/charts/line-chart/hooks/use-fetch-timeseries.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/charts/line-chart/hooks/use-fetch-timeseries.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-datetime/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-datetime/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-datetime/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-filters/components/status-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-filters/components/status-filter.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-filters/components/status-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-filters/components/status-filter.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-filters/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-filters/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-filters/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-filters/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-refresh.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-refresh.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-refresh.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-refresh.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-search/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-search/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/components/logs-search/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/components/logs-search/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/controls/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/components/inline-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/components/inline-filter.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/components/inline-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/components/inline-filter.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/components/logs-actions/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/components/logs-actions/index.tsx similarity index 81% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/components/logs-actions/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/components/logs-actions/index.tsx index 2049b61d7f..24c9b23702 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/components/logs-actions/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/components/logs-actions/index.tsx @@ -1,13 +1,14 @@ "use client"; -import { DeleteDialog } from "@/app/(app)/ratelimits/[namespaceId]/_components/delete-dialog"; - -import { IdentifierDialog } from "@/app/(app)/ratelimits/[namespaceId]/_components/identifier-dialog"; -import type { OverrideDetails } from "@/app/(app)/ratelimits/[namespaceId]/types"; +import { DeleteDialog } from "@/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/delete-dialog"; +import { IdentifierDialog } from "@/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_components/identifier-dialog"; +import type { OverrideDetails } from "@/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/types"; import { type MenuItem, TableActionPopover } from "@/components/logs/table-action.popover"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { Clone, Layers3, PenWriting3, Trash } from "@unkey/icons"; -import { toast } from "@unkey/ui"; +import { Loading, toast } from "@unkey/ui"; import { useRouter } from "next/navigation"; +import { Suspense } from "react"; import { useFilters } from "../../../../hooks/use-filters"; export const LogsTableAction = ({ @@ -21,6 +22,7 @@ export const LogsTableAction = ({ }) => { const router = useRouter(); const { filters } = useFilters(); + const workspace = useWorkspaceNavigation(); const getTimeParams = () => { const timeFilters = filters.filter((f) => ["startTime", "endTime", "since"].includes(f.field)); @@ -51,7 +53,7 @@ export const LogsTableAction = ({ icon: , onClick: (e) => { e.stopPropagation(); - router.push(`/ratelimits/${namespaceId}/logs?${getTimeParams()}`); + router.push(`/${workspace.slug}/ratelimits/${namespaceId}/logs?${getTimeParams()}`); }, }, { @@ -112,5 +114,9 @@ export const LogsTableAction = ({ const menuItems = getLogsTableActionItems(); - return ; + return ( + }> + + + ); }; diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/components/override-indicator.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/components/override-indicator.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/components/override-indicator.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/components/override-indicator.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/hooks/use-logs-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/hooks/use-logs-query.ts similarity index 97% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/hooks/use-logs-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/hooks/use-logs-query.ts index bd9db15a39..566f4b5e1f 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/hooks/use-logs-query.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/hooks/use-logs-query.ts @@ -3,7 +3,7 @@ import { trpc } from "@/lib/trpc/client"; import { useQueryTime } from "@/providers/query-time-provider"; import type { RatelimitOverviewLog } from "@unkey/clickhouse/src/ratelimits"; import { useEffect, useMemo, useState } from "react"; -import { useSort } from "../../../../../../../../components/logs/hooks/use-sort"; +import { useSort } from "../../../../../../../../../components/logs/hooks/use-sort"; import { useFilters } from "../../../hooks/use-filters"; import type { RatelimitQueryOverviewLogsPayload, SortFields } from "../query-logs.schema"; diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/logs-table.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/logs-table.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/logs-table.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/logs-table.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/query-logs.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/query-logs.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/query-logs.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/query-logs.schema.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/utils/calculate-blocked-percentage.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/utils/calculate-blocked-percentage.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/utils/calculate-blocked-percentage.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/utils/calculate-blocked-percentage.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/utils/format-duration.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/utils/format-duration.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/utils/format-duration.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/utils/format-duration.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/utils/get-row-class.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/utils/get-row-class.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/components/table/utils/get-row-class.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/table/utils/get-row-class.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/context/logs.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/context/logs.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/context/logs.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/context/logs.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/filters.schema.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/logs-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/logs-client.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/_overview/logs-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/logs-client.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/charts/hooks/use-fetch-timeseries.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/charts/hooks/use-fetch-timeseries.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/charts/hooks/use-fetch-timeseries.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/charts/hooks/use-fetch-timeseries.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/charts/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/charts/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/charts/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/charts/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/charts/query-timeseries.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/charts/query-timeseries.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/charts/query-timeseries.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/charts/query-timeseries.schema.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-datetime/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/components/identifiers-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/components/identifiers-filter.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/components/identifiers-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/components/identifiers-filter.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/components/status-filter.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/components/status-filter.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/components/status-filter.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/components/status-filter.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-filters/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-live-switch.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-live-switch.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-live-switch.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-live-switch.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/utils.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/utils.ts similarity index 93% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/utils.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/utils.ts index 4a9834eb7d..424d7d6eb4 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/utils.ts +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-queries/utils.ts @@ -1,4 +1,4 @@ -import type { QuerySearchParams } from "@/app/(app)/audit/filters.schema"; +import type { QuerySearchParams } from "@/app/(app)/[workspaceSlug]/audit/filters.schema"; import { iconsPerField } from "@/components/logs/queries/utils"; import { ChartActivity2 } from "@unkey/icons"; import { format } from "date-fns"; @@ -84,7 +84,10 @@ export function formatFilterValues( export function getFilterFieldIcon(field: string): JSX.Element { const Icon = iconsPerField[field] || ChartActivity2; - return React.createElement(Icon, { size: "md-regular", className: "justify-center" }); + return React.createElement(Icon, { + size: "md-regular", + className: "justify-center", + }); } export const FieldsToTruncate = [ diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-refresh.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-refresh.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-refresh.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-refresh.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-search/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-search/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/components/logs-search/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/components/logs-search/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/controls/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/logs-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/logs-client.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/logs-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/logs-client.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/hooks/use-logs-query.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/hooks/use-logs-query.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/hooks/use-logs-query.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/hooks/use-logs-query.ts diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/log-details/components/log-meta.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/log-details/components/log-meta.tsx new file mode 100644 index 0000000000..3361a1e0a3 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/log-details/components/log-meta.tsx @@ -0,0 +1,22 @@ +import { Card, CardContent, CopyButton } from "@unkey/ui"; + +export const LogMetaSection = ({ content }: { content: string }) => { + return ( +
+
Meta
+ + +
{content ?? ""} 
+ +
+
+
+ ); +}; diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/log-details/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/log-details/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/log-details/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/log-details/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/logs-actions/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/logs-actions/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/logs-actions/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/logs-actions/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx similarity index 99% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx index 9e84754a6c..4cc47aa25b 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/logs-table.tsx @@ -1,6 +1,6 @@ "use client"; -import { safeParseJson } from "@/app/(app)/logs/utils"; +import { safeParseJson } from "@/app/(app)/[workspaceSlug]/logs/utils"; import { VirtualTable } from "@/components/virtual-table/index"; import type { Column } from "@/components/virtual-table/types"; import { cn } from "@/lib/utils"; diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/query-logs.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/query-logs.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/components/table/query-logs.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/components/table/query-logs.schema.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/constants.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/constants.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/constants.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/constants.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/context/logs.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/context/logs.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/context/logs.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/context/logs.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/filters.schema.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/hooks/use-filters.test.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/hooks/use-filters.test.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/hooks/use-filters.test.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/hooks/use-filters.test.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/hooks/use-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/hooks/use-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/hooks/use-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/hooks/use-filters.ts diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/page.tsx similarity index 70% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/page.tsx index cb2dc5ccc0..0a5e52d7f5 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/logs/page.tsx @@ -1,5 +1,7 @@ "use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; + import { NamespaceNavbar } from "../namespace-navbar"; import { LogsClient } from "./components/logs-client"; @@ -8,12 +10,14 @@ export default function RatelimitLogsPage({ }: { params: { namespaceId: string }; }) { + const workspace = useWorkspaceNavigation(); + return (
diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/namespace-navbar.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/namespace-navbar.tsx similarity index 83% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/namespace-navbar.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/namespace-navbar.tsx index 26ddc26b56..cc398ece99 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/namespace-navbar.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/namespace-navbar.tsx @@ -3,6 +3,7 @@ import { QuickNavPopover } from "@/components/navbar-popover"; import { NavbarActionButton } from "@/components/navigation/action-button"; import { CopyableIDButton } from "@/components/navigation/copyable-id-button"; import { Navbar } from "@/components/navigation/navbar"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { collection } from "@/lib/collections"; import { useLiveQuery } from "@tanstack/react-db"; import { ChevronExpandY, Gauge, TaskUnchecked } from "@unkey/icons"; @@ -28,6 +29,7 @@ type NamespaceNavbarProps = { export const NamespaceNavbar = ({ namespaceId, activePage }: NamespaceNavbarProps) => { const [open, setOpen] = useState(false); + const workspace = useWorkspaceNavigation(); const { data } = useLiveQuery((q) => q.from({ namespace: collection.ratelimitNamespaces })); @@ -35,7 +37,9 @@ export const NamespaceNavbar = ({ namespaceId, activePage }: NamespaceNavbarProp return ( }> - Ratelimits + + Ratelimits +
@@ -65,9 +69,11 @@ export const NamespaceNavbar = ({ namespaceId, activePage }: NamespaceNavbarProp <> }> - Ratelimits + + Ratelimits + ({ id: ns.id, label: ns.name, - href: `/ratelimits/${ns.id}`, + href: `/${workspace.slug}/ratelimits/${ns.id}`, }))} shortcutKey="N" > @@ -89,22 +95,22 @@ export const NamespaceNavbar = ({ namespaceId, activePage }: NamespaceNavbarProp { id: "requests", label: "Requests", - href: `/ratelimits/${namespaceId}`, + href: `/${workspace.slug}/ratelimits/${namespaceId}`, }, { id: "logs", label: "Logs", - href: `/ratelimits/${namespaceId}/logs`, + href: `/${workspace.slug}/ratelimits/${namespaceId}/logs`, }, { id: "settings", label: "Settings", - href: `/ratelimits/${namespaceId}/settings`, + href: `/${workspace.slug}/ratelimits/${namespaceId}/settings`, }, { id: "overrides", label: "Overrides", - href: `/ratelimits/${namespaceId}/overrides`, + href: `/${workspace.slug}/ratelimits/${namespaceId}/overrides`, }, ]} shortcutKey="M" diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/last-used-cell.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/last-used-cell.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/last-used-cell.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/last-used-cell.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/logs-actions/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/logs-actions/index.tsx similarity index 92% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/logs-actions/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/logs-actions/index.tsx index 75b73c63be..52c917d879 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/logs-actions/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/logs-actions/index.tsx @@ -2,7 +2,8 @@ import { type MenuItem, TableActionPopover } from "@/components/logs/table-action.popover"; import { Clone, PenWriting3, Trash } from "@unkey/icons"; -import { toast } from "@unkey/ui"; +import { Loading, toast } from "@unkey/ui"; +import { Suspense } from "react"; import { DeleteDialog } from "../../_components/delete-dialog"; import { IdentifierDialog } from "../../_components/identifier-dialog"; import type { OverrideDetails } from "../../types"; @@ -74,5 +75,9 @@ export const OverridesTableAction = ({ const menuItems = getOverridesTableActionItems(); - return ; + return ( + }> + + + ); }; diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/overrides-table.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/overrides-table.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/overrides-table.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/overrides-table.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/page.tsx similarity index 69% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/page.tsx index 5ddf32e497..86fc0ed3ad 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/overrides/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/overrides/page.tsx @@ -1,5 +1,6 @@ "use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { NamespaceNavbar } from "../namespace-navbar"; import { OverridesTable } from "./overrides-table"; @@ -8,11 +9,13 @@ export default function OverridePage({ }: { params: { namespaceId: string }; }) { + const workspace = useWorkspaceNavigation(); + return (
{
} border="top" - className="border-b-1" + className="border-b" contentWidth="w-full lg:w-[420px] h-full justify-end items-end" >
{
{/* Namespace name card skeleton */}
-
+
diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/settings/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/settings/page.tsx similarity index 72% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/settings/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/settings/page.tsx index 2352b8c84f..bf9ed6a16a 100644 --- a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/settings/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/settings/page.tsx @@ -1,5 +1,6 @@ "use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { NamespaceNavbar } from "../namespace-navbar"; import { SettingsClient } from "./components/settings-client"; @@ -11,12 +12,14 @@ type Props = { export default function SettingsPage(props: Props) { const namespaceId = props.params.namespaceId; + const workspace = useWorkspaceNavigation(); + return (
diff --git a/apps/dashboard/app/(app)/ratelimits/[namespaceId]/types.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/types.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/[namespaceId]/types.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/types.ts diff --git a/apps/dashboard/app/(app)/ratelimits/_components/control-cloud/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/control-cloud/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/control-cloud/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/control-cloud/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/_components/controls/components/namespace-list-datetime/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/components/logs-datetime/index.tsx similarity index 95% rename from apps/dashboard/app/(app)/ratelimits/_components/controls/components/namespace-list-datetime/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/components/logs-datetime/index.tsx index 5db4ccd1ee..faf91c3323 100644 --- a/apps/dashboard/app/(app)/ratelimits/_components/controls/components/namespace-list-datetime/index.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/components/logs-datetime/index.tsx @@ -1,4 +1,4 @@ -import { useFilters } from "@/app/(app)/ratelimits/[namespaceId]/_overview/hooks/use-filters"; +import { useFilters } from "@/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/hooks/use-filters"; import { DatetimePopover } from "@/components/logs/datetime/datetime-popover"; import { cn } from "@/lib/utils"; import { Calendar } from "@unkey/icons"; diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/components/namespace-list-datetime/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/components/namespace-list-datetime/index.tsx new file mode 100644 index 0000000000..faf91c3323 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/components/namespace-list-datetime/index.tsx @@ -0,0 +1,90 @@ +import { useFilters } from "@/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/hooks/use-filters"; +import { DatetimePopover } from "@/components/logs/datetime/datetime-popover"; +import { cn } from "@/lib/utils"; +import { Calendar } from "@unkey/icons"; +import { Button } from "@unkey/ui"; +import { useEffect, useState } from "react"; + +export const NamespaceListDateTime = () => { + const [title, setTitle] = useState(null); + const { filters, updateFilters } = useFilters(); + + useEffect(() => { + if (!title) { + setTitle("Last 12 hours"); + } + }, [title]); + + const timeValues = filters + .filter((f) => ["startTime", "endTime", "since"].includes(f.field)) + .reduce( + (acc, f) => ({ + // biome-ignore lint/performance/noAccumulatingSpread: it's safe to spread + ...acc, + [f.field]: f.value, + }), + {}, + ); + + return ( + { + const activeFilters = filters.filter( + (f) => !["endTime", "startTime", "since"].includes(f.field), + ); + if (since !== undefined) { + updateFilters([ + ...activeFilters, + { + field: "since", + value: since, + id: crypto.randomUUID(), + operator: "is", + }, + ]); + return; + } + if (since === undefined && startTime) { + activeFilters.push({ + field: "startTime", + value: startTime, + id: crypto.randomUUID(), + operator: "is", + }); + if (endTime) { + activeFilters.push({ + field: "endTime", + value: endTime, + id: crypto.randomUUID(), + operator: "is", + }); + } + } + updateFilters(activeFilters); + }} + initialTitle={title ?? ""} + onSuggestionChange={setTitle} + > +
+ +
+
+ ); +}; diff --git a/apps/dashboard/app/(app)/ratelimits/_components/controls/components/namespace-list-refresh.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/components/namespace-list-refresh.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/controls/components/namespace-list-refresh.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/components/namespace-list-refresh.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/_components/controls/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/controls/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/controls/index.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/_components/create-namespace-button.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/create-namespace-button.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/create-namespace-button.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/create-namespace-button.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/_components/hooks/use-namespace-list-filters.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/hooks/use-namespace-list-filters.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/hooks/use-namespace-list-filters.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/hooks/use-namespace-list-filters.ts diff --git a/apps/dashboard/app/(app)/ratelimits/_components/list/index.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/list/index.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/list/index.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/list/index.tsx diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/list/namespace-card.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/list/namespace-card.tsx new file mode 100644 index 0000000000..7021d90dc4 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/list/namespace-card.tsx @@ -0,0 +1,79 @@ +"use client"; +import { useFetchRatelimitOverviewTimeseries } from "@/app/(app)/[workspaceSlug]/ratelimits/[namespaceId]/_overview/components/charts/bar-chart/hooks/use-fetch-timeseries"; +import { StatsCard } from "@/components/stats-card"; +import { StatsTimeseriesBarChart } from "@/components/stats-card/components/chart/stats-chart"; +import { MetricStats } from "@/components/stats-card/components/metric-stats"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; +import { Clock, ProgressBar } from "@unkey/icons"; +import { Loading } from "@unkey/ui"; +import ms from "ms"; +import { Suspense } from "react"; + +type Props = { + namespace: { + id: string; + name: string; + }; +}; + +export const NamespaceCard = ({ namespace }: Props) => { + const workspace = useWorkspaceNavigation(); + const { timeseries, isLoading, isError } = useFetchRatelimitOverviewTimeseries(namespace.id); + + const passed = timeseries?.reduce((acc, crr) => acc + crr.success, 0) ?? 0; + const blocked = timeseries?.reduce((acc, crr) => acc + crr.error, 0) ?? 0; + const lastRatelimit = timeseries + ? timeseries + .filter((entry) => entry.total > 0) + .sort((a, b) => b.originalTimestamp - a.originalTimestamp)[0] + : null; + + return ( +
+ }> + + } + stats={ + <> + +
+ +
+ {lastRatelimit + ? `${ms(Date.now() - lastRatelimit.originalTimestamp, { + long: true, + })} ago` + : "No data"} +
+
+ + } + icon={} + /> +
+
+ ); +}; diff --git a/apps/dashboard/app/(app)/ratelimits/_components/list/namespace-list.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/list/namespace-list.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/list/namespace-list.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/list/namespace-list.schema.ts diff --git a/apps/dashboard/app/(app)/ratelimits/_components/list/skeletons.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/list/skeletons.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/list/skeletons.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/list/skeletons.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/_components/namespace-list-client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/namespace-list-client.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/namespace-list-client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/namespace-list-client.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/_components/namespace-list-filters.schema.ts b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/namespace-list-filters.schema.ts similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/_components/namespace-list-filters.schema.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/namespace-list-filters.schema.ts diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/skeletons.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/skeletons.tsx new file mode 100644 index 0000000000..53eea55a2e --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/_components/skeletons.tsx @@ -0,0 +1,53 @@ +import { Clock, ProgressBar } from "@unkey/icons"; + +export const ChartSkeleton = () => { + return
; +}; + +export const MetricStatsSkeleton = () => { + return ( + <> +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ + ); +}; + +export const NamespaceCardSkeleton = () => { + return ( +
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+ ); +}; diff --git a/apps/dashboard/app/(app)/ratelimits/navigation.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/navigation.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/navigation.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/navigation.tsx diff --git a/apps/dashboard/app/(app)/ratelimits/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/page.tsx similarity index 100% rename from apps/dashboard/app/(app)/ratelimits/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/ratelimits/page.tsx diff --git a/apps/dashboard/app/(app)/settings/billing/client.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/client.tsx similarity index 90% rename from apps/dashboard/app/(app)/settings/billing/client.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/client.tsx index 961f1aaa83..f997f841bd 100644 --- a/apps/dashboard/app/(app)/settings/billing/client.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/client.tsx @@ -37,7 +37,7 @@ type Props = { }>; }; -const Mutations = () => { +const useBillingMutations = () => { const router = useRouter(); const createSubscription = trpc.stripe.createSubscription.useMutation({ @@ -86,8 +86,9 @@ const Mutations = () => { }; export const Client: React.FC = (props) => { - const mutations = Mutations(); - const allowUpdate = props.subscription && props.subscription.status === "active"; + const mutations = useBillingMutations(); + const allowUpdate = + props.subscription && ["active", "trialing"].includes(props.subscription.status); const allowCancel = props.subscription && props.subscription.status === "active" && !props.subscription.cancelAt; const isFreeTier = !props.subscription || props.subscription.status !== "active"; @@ -97,12 +98,15 @@ export const Client: React.FC = (props) => { return (
- - - {props.subscription ? : null} + + + {props.subscription ? ( + + ) : null} {isFreeTier ? : null} @@ -158,7 +162,7 @@ export const Client: React.FC = (props) => { ); return; } - mutations.updateSubscription.mutateAsync({ + await mutations.updateSubscription.mutateAsync({ oldProductId: props.currentProductId, newProductId: p.id, }); @@ -204,7 +208,9 @@ export const Client: React.FC = (props) => { >
@@ -218,7 +224,9 @@ export const Client: React.FC = (props) => { >
@@ -268,7 +276,7 @@ const FreeTierAlert: React.FC = () => { }; const CancelAlert: React.FC<{ cancelAt?: number }> = (props) => { - const mutations = Mutations(); + const mutations = useBillingMutations(); if (!props.cancelAt) { return null; @@ -301,8 +309,11 @@ const CancelAlert: React.FC<{ cancelAt?: number }> = (props) => { ); }; -const SusbcriptionStatus: React.FC<{ +const SubscriptionStatus: React.FC<{ status: Stripe.Subscription.Status; + trialUntil?: number; + workspaceId: string; + workspaceSlug: string; }> = (props) => { switch (props.status) { case "active": @@ -321,7 +332,9 @@ const SusbcriptionStatus: React.FC<{ >
diff --git a/apps/dashboard/app/(app)/settings/billing/components/confirmation.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/components/confirmation.tsx similarity index 100% rename from apps/dashboard/app/(app)/settings/billing/components/confirmation.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/components/confirmation.tsx index 74f3eeaae0..5ad2b81af6 100644 --- a/apps/dashboard/app/(app)/settings/billing/components/confirmation.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/components/confirmation.tsx @@ -35,8 +35,8 @@ export const Confirm: React.FC = (props) => { className="w-full rounded-lg" onClick={async () => { setLoading(true); - setOpen(false); await props.onConfirm(); + setOpen(false); setLoading(false); }} > diff --git a/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/components/shell.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/components/shell.tsx new file mode 100644 index 0000000000..d9e7c82115 --- /dev/null +++ b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/components/shell.tsx @@ -0,0 +1,18 @@ +"use client"; +import type { PropsWithChildren } from "react"; +interface ShellProps extends PropsWithChildren { + title?: string; +} + +export const Shell = ({ children, title = "Billing Settings" }: ShellProps) => { + return ( +
+
+

+ {title} +

+ {children} +
+
+ ); +}; diff --git a/apps/dashboard/app/(app)/settings/billing/components/usage.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/components/usage.tsx similarity index 98% rename from apps/dashboard/app/(app)/settings/billing/components/usage.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/components/usage.tsx index b8bbbe3cec..baab5ce9c2 100644 --- a/apps/dashboard/app/(app)/settings/billing/components/usage.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/components/usage.tsx @@ -1,7 +1,7 @@ import { formatNumber } from "@/lib/fmt"; import { SettingCard } from "@unkey/ui"; -export const Usage: React.FC<{ current: number; max: number }> = async ({ current, max }) => { +export const Usage: React.FC<{ current: number; max: number }> = ({ current, max }) => { return ( - + Stripe is not configured @@ -72,8 +72,8 @@ export default async function BillingPage() { if (isLegacy) { return ( - - + +
- - + +
diff --git a/apps/dashboard/app/(app)/settings/billing/stripe/checkout/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/stripe/checkout/page.tsx similarity index 100% rename from apps/dashboard/app/(app)/settings/billing/stripe/checkout/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/stripe/checkout/page.tsx diff --git a/apps/dashboard/app/(app)/settings/billing/stripe/portal/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/stripe/portal/page.tsx similarity index 96% rename from apps/dashboard/app/(app)/settings/billing/stripe/portal/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/stripe/portal/page.tsx index a1546711af..e0b76ce1a8 100644 --- a/apps/dashboard/app/(app)/settings/billing/stripe/portal/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/settings/billing/stripe/portal/page.tsx @@ -10,13 +10,20 @@ export const dynamic = "force-dynamic"; export default async function StripeRedirect() { const { orgId } = await getAuth(); + if (!orgId) { + return redirect("/sign-in"); + } + const ws = await db.query.workspaces.findFirst({ where: (table, { and, eq, isNull }) => and(eq(table.orgId, orgId), isNull(table.deletedAtM)), }); + if (!ws) { return redirect("/new"); } + const e = stripeEnv(); + if (!e) { return ( diff --git a/apps/dashboard/app/(app)/settings/constants.ts b/apps/dashboard/app/(app)/[workspaceSlug]/settings/constants.ts similarity index 100% rename from apps/dashboard/app/(app)/settings/constants.ts rename to apps/dashboard/app/(app)/[workspaceSlug]/settings/constants.ts diff --git a/apps/dashboard/app/(app)/settings/general/copy-workspace-id.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/settings/general/copy-workspace-id.tsx similarity index 100% rename from apps/dashboard/app/(app)/settings/general/copy-workspace-id.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/settings/general/copy-workspace-id.tsx diff --git a/apps/dashboard/app/(app)/settings/general/page.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/settings/general/page.tsx similarity index 52% rename from apps/dashboard/app/(app)/settings/general/page.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/settings/general/page.tsx index 3dc63dcb84..d7b6fa82ce 100644 --- a/apps/dashboard/app/(app)/settings/general/page.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/settings/general/page.tsx @@ -1,6 +1,6 @@ -import { getAuth } from "@/lib/auth"; -import { db } from "@/lib/db"; -import { redirect } from "next/navigation"; +"use client"; + +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { WorkspaceNavbar } from "../workspace-navbar"; import { CopyWorkspaceId } from "./copy-workspace-id"; import { UpdateWorkspaceName } from "./update-workspace-name"; @@ -9,30 +9,21 @@ import { UpdateWorkspaceName } from "./update-workspace-name"; * TODO: WorkOS doesn't have workspace images */ -export const dynamic = "force-dynamic"; - -export default async function SettingsPage() { - const { orgId } = await getAuth(); - - const workspace = await db.query.workspaces.findFirst({ - where: (table, { and, eq, isNull }) => and(eq(table.orgId, orgId), isNull(table.deletedAtM)), - }); - if (!workspace) { - return redirect("/new"); - } +export default function SettingsPage() { + const workspace = useWorkspaceNavigation(); return (
- +
Workspace Settings
- + {/* */} - + {workspace && }
diff --git a/apps/dashboard/app/(app)/settings/general/update-workspace-name.tsx b/apps/dashboard/app/(app)/[workspaceSlug]/settings/general/update-workspace-name.tsx similarity index 75% rename from apps/dashboard/app/(app)/settings/general/update-workspace-name.tsx rename to apps/dashboard/app/(app)/[workspaceSlug]/settings/general/update-workspace-name.tsx index c90df274fb..d2282166fb 100644 --- a/apps/dashboard/app/(app)/settings/general/update-workspace-name.tsx +++ b/apps/dashboard/app/(app)/[workspaceSlug]/settings/general/update-workspace-name.tsx @@ -1,4 +1,5 @@ "use client"; +import { useWorkspaceNavigation } from "@/hooks/use-workspace-navigation"; import { trpc } from "@/lib/trpc/client"; import { zodResolver } from "@hookform/resolvers/zod"; import { Button, FormInput, SettingCard, toast } from "@unkey/ui"; @@ -7,17 +8,12 @@ import { useState } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; -type Props = { - workspace: { - id: string; - name: string; - }; -}; - -export const UpdateWorkspaceName: React.FC = ({ workspace }) => { +export function UpdateWorkspaceName() { + const workspace = useWorkspaceNavigation(); const router = useRouter(); const utils = trpc.useUtils(); - const [name, setName] = useState(workspace.name); + + const [name, setName] = useState(workspace?.name); const formSchema = z.object({ workspaceId: z.string(), @@ -25,7 +21,9 @@ export const UpdateWorkspaceName: React.FC = ({ workspace }) => { .string() .trim() .min(3, { message: "Workspace name must be at least 3 characters long" }) - .max(50, { message: "Workspace name must be less than 50 characters long" }), + .max(50, { + message: "Workspace name must be less than 50 characters long", + }), }); const { @@ -37,7 +35,7 @@ export const UpdateWorkspaceName: React.FC = ({ workspace }) => { resolver: zodResolver(formSchema), mode: "onChange", defaultValues: { - workspaceId: workspace.id, + workspaceId: workspace?.id, workspaceName: name, }, }); @@ -47,22 +45,30 @@ export const UpdateWorkspaceName: React.FC = ({ workspace }) => { toast.success("Workspace name updated"); // invalidate the current user so it refetches utils.user.getCurrentUser.invalidate(); + utils.workspace.invalidate(); setName(watch("workspaceName")); router.refresh(); }, onError(err) { - toast.error("Failed to update namespace name", { + toast.error("Failed to update workspace name", { description: err.message, }); }, }); const onSubmit = async (values: z.infer) => { - if (workspace.name === values.workspaceName || !values.workspaceName) { + if (workspace?.name === values.workspaceName || !values.workspaceName) { return toast.error("Please provide a different name before saving."); } - await updateName.mutateAsync({ workspaceId: workspace.id, name: values.workspaceName }); + if (!workspace?.id) { + return toast.error("Workspace not found"); + } + + await updateName.mutateAsync({ + workspaceId: workspace.id, + name: values.workspaceName, + }); }; return ( @@ -71,18 +77,19 @@ export const UpdateWorkspaceName: React.FC = ({ workspace }) => { title={"Workspace Name"} description={"Not customer-facing. Choose a name that is easy to recognize."} border="top" - className="border-b-1" + className="border-b" contentWidth="w-full lg:w-[420px]" >
- -