diff --git a/bun.lockb b/bun.lockb
index d7b765d..19f4425 100755
Binary files a/bun.lockb and b/bun.lockb differ
diff --git a/src/components/databrowser/components/display/index.tsx b/src/components/databrowser/components/display/index.tsx
index 8a2890e..6605fb2 100644
--- a/src/components/databrowser/components/display/index.tsx
+++ b/src/components/databrowser/components/display/index.tsx
@@ -1,5 +1,6 @@
/* eslint-disable unicorn/no-negated-condition */
+import { DATA_TYPES, SIMPLE_DATA_TYPES, type SimpleDataType } from "@/types"
import { useKeys, useKeyType } from "../../hooks/use-keys"
import { ListDisplay } from "./display-list"
import { EditorDisplay } from "./display-simple"
@@ -23,12 +24,16 @@ export const DataDisplay = () => {
) : (
)
+ ) : !DATA_TYPES.includes(type as any) ? (
+
+ Unrecognized key type: {type}
+
) : (
<>
- {type === "string" || type === "json" ? (
-
+ {SIMPLE_DATA_TYPES.includes(type as SimpleDataType) ? (
+
) : (
-
+ } />
)}
>
)}
diff --git a/src/components/databrowser/components/sidebar/keys-list.tsx b/src/components/databrowser/components/sidebar/keys-list.tsx
index 0532055..1294b4b 100644
--- a/src/components/databrowser/components/sidebar/keys-list.tsx
+++ b/src/components/databrowser/components/sidebar/keys-list.tsx
@@ -1,6 +1,6 @@
import { Fragment, useRef } from "react"
import { useTab } from "@/tab-provider"
-import type { DataType, RedisKey } from "@/types"
+import type { RedisKey } from "@/types"
import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
@@ -36,7 +36,7 @@ export const KeysList = () => {
)
}
-const keyStyles = {
+const keyStyles: Record = {
string: "border-sky-400 !bg-sky-50 text-sky-900",
hash: "border-amber-400 !bg-amber-50 text-amber-900",
set: "border-indigo-400 !bg-indigo-50 text-indigo-900",
@@ -44,7 +44,9 @@ const keyStyles = {
json: "border-purple-400 !bg-purple-50 text-purple-900",
list: "border-orange-400 !bg-orange-50 text-orange-900",
stream: "border-green-400 !bg-green-50 text-green-900",
-} as Record
+}
+
+const defaultKeyStyle = "border-gray-400 !bg-gray-50 text-gray-900"
const KeyItem = ({
data,
@@ -92,7 +94,7 @@ const KeyItem = ({
"relative flex h-10 w-full items-center justify-start gap-2 px-3 py-0 !ring-0 focus-visible:bg-zinc-50",
"-my-px select-none border border-transparent text-left",
isKeySelected && "shadow-sm",
- isKeySelected && keyStyles[dataType]
+ isKeySelected && (keyStyles[dataType] ?? defaultKeyStyle)
)}
onClick={handleClick}
>
diff --git a/src/components/databrowser/components/type-tag.tsx b/src/components/databrowser/components/type-tag.tsx
index 02ed40e..8984a27 100644
--- a/src/components/databrowser/components/type-tag.tsx
+++ b/src/components/databrowser/components/type-tag.tsx
@@ -7,12 +7,13 @@ import {
IconLayersIntersect,
IconList,
IconQuote,
+ IconQuestionMark,
} from "@tabler/icons-react"
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "@/lib/utils"
-const iconsMap = {
+const iconsMap: Record = {
string: ,
set: ,
hash: ,
@@ -20,7 +21,7 @@ const iconsMap = {
zset: ,
list: ,
stream: ,
-} as const
+}
const tagVariants = cva("inline-flex shrink-0 items-center rounded-md justify-center", {
variants: {
@@ -32,6 +33,7 @@ const tagVariants = cva("inline-flex shrink-0 items-center rounded-md justify-ce
json: "bg-purple-200 text-purple-800",
list: "bg-orange-200 text-orange-800",
stream: "bg-green-200 text-green-800",
+ default: "bg-gray-200 text-gray-800",
},
type: {
icon: "size-5",
@@ -39,7 +41,7 @@ const tagVariants = cva("inline-flex shrink-0 items-center rounded-md justify-ce
},
},
defaultVariants: {
- variant: "string",
+ variant: "default",
type: "icon",
},
})
@@ -49,9 +51,14 @@ export interface TypeTagProps
VariantProps {}
export function TypeTag({ className, variant, type }: TypeTagProps) {
+ const defaultIcon =
+ const variantKey = variant && variant in iconsMap ? variant : "default"
+
return (
-
- {type === "icon" ? iconsMap[variant as DataType] : DATA_TYPE_NAMES[variant as DataType]}
+
+ {type === "icon"
+ ? (iconsMap[variant as string] ?? defaultIcon)
+ : (DATA_TYPE_NAMES[variant as DataType] ?? variant ?? "Unknown")}
)
}