Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 65 additions & 56 deletions apps/frontend/src/components/key-browser/key-details/key-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface BaseKeyInfo {
ttl: number;
size: number;
collectionSize?: number;
elementsWarning?: string;
}

interface ElementInfo {
Expand Down Expand Up @@ -155,68 +156,76 @@ export default function KeyDetails({ selectedKey, selectedKeyInfo, connectionId,
</div>
</div>

{/* show different key types */}
{selectedKeyInfo.type === "string" && (
<KeyDetailsString
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}
{selectedKeyInfo.elementsWarning ? (
<div className="text-center text-muted-foreground py-8">
<Typography variant="bodySm">{selectedKeyInfo.elementsWarning}</Typography>
</div>
) : (
<>
{/* show different key types */}
{selectedKeyInfo.type === "string" && (
<KeyDetailsString
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}

{selectedKeyInfo.type === "hash" && (
<KeyDetailsHash
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}
{selectedKeyInfo.type === "hash" && (
<KeyDetailsHash
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}

{selectedKeyInfo.type === "list" && (
<KeyDetailsList
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}
{selectedKeyInfo.type === "list" && (
<KeyDetailsList
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}

{selectedKeyInfo.type === "set" && (
<KeyDetailsSet
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}
{selectedKeyInfo.type === "set" && (
<KeyDetailsSet
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}

{selectedKeyInfo.type === "zset" && (
<KeyDetailsZSet
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}
{selectedKeyInfo.type === "zset" && (
<KeyDetailsZSet
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}

{selectedKeyInfo.type === "stream" && (
<KeyDetailsStream
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}
{selectedKeyInfo.type === "stream" && (
<KeyDetailsStream
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}

{selectedKeyInfo.type === "ReJSON-RL" && (
<KeyDetailsJson
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
{selectedKeyInfo.type === "ReJSON-RL" && (
<KeyDetailsJson
connectionId={connectionId}
readOnly={readOnly}
selectedKey={selectedKey}
selectedKeyInfo={selectedKeyInfo}
/>
)}
</>
)}
</div>
) : (
Expand Down
3 changes: 2 additions & 1 deletion apps/server/src/keys-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface EnrichedKeyInfo {
collectionSize?: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
elements?: any; // this can be array, object, or string depending on the key type.
elementsWarning?: string; // alternative for elements when they cannot be displayed.
}

async function getScanKeyInfo(
Expand Down Expand Up @@ -147,7 +148,7 @@ export async function getKeyInfo(
if (commands.sizeCmd){
keyInfo.collectionSize = await (client.customCommand([commands.sizeCmd, key])) as number
}
keyInfo.elements = `This key is ${formatBytes(memoryUsage)}, which is larger than the maximum display size of ${formatBytes(VALKEY_CLIENT.KEY_VALUE_SIZE_LIMIT)}.`
keyInfo.elementsWarning = `This key is ${formatBytes(memoryUsage)}, which is larger than the maximum display size of ${formatBytes(VALKEY_CLIENT.KEY_VALUE_SIZE_LIMIT)}.`

return keyInfo
}
Expand Down
Loading