feat(redis): support connection-level default key filters
This commit is contained in:
55 files changed
+703
-114
No files matched your search
@@ -441,6 +441,7 @@ const defaultForm = (): ConnectionForm => ({
|
||||
redis_key_separator: ":",
|
||||
redis_scan_page_size: REDIS_SCAN_PAGE_SIZE_DEFAULT,
|
||||
redis_key_templates: [],
|
||||
redis_key_filter: "",
|
||||
etcd_endpoints: "",
|
||||
gbase_server: "",
|
||||
informix_server: "",
|
||||
@@ -3131,6 +3132,7 @@ watch(
|
||||
redis_key_separator: config.redis_key_separator ?? ":",
|
||||
redis_scan_page_size: config.redis_scan_page_size ?? REDIS_SCAN_PAGE_SIZE_DEFAULT,
|
||||
redis_key_templates: normalizeRedisKeyTemplates(config.redis_key_templates),
|
||||
redis_key_filter: config.redis_key_filter ?? "",
|
||||
redis_key_grouping: config.redis_key_grouping,
|
||||
etcd_endpoints: config.etcd_endpoints || "",
|
||||
gbase_server: config.gbase_server || "",
|
||||
@@ -5161,6 +5163,7 @@ function connectionConfigForSubmit(id: string, generatedName = "", validatePlugi
|
||||
config.redis_scan_page_size = undefined;
|
||||
config.redis_database_aliases = undefined;
|
||||
config.redis_key_templates = undefined;
|
||||
config.redis_key_filter = undefined;
|
||||
config.redis_key_grouping = undefined;
|
||||
} else if (config.redis_connection_mode === "sentinel") {
|
||||
config.redis_sentinel_master = config.redis_sentinel_master?.trim() || "";
|
||||
@@ -5195,6 +5198,7 @@ function connectionConfigForSubmit(id: string, generatedName = "", validatePlugi
|
||||
}
|
||||
if (config.db_type === "redis") {
|
||||
config.redis_key_separator = config.redis_key_separator?.trim() ?? ":";
|
||||
config.redis_key_filter = config.redis_key_filter?.trim() || undefined;
|
||||
const scanSize = Number(config.redis_scan_page_size);
|
||||
config.redis_scan_page_size = Number.isFinite(scanSize) && scanSize >= REDIS_SCAN_PAGE_SIZE_MIN && scanSize <= REDIS_SCAN_PAGE_SIZE_MAX ? Math.round(scanSize) : REDIS_SCAN_PAGE_SIZE_DEFAULT;
|
||||
{
|
||||
@@ -8103,6 +8107,13 @@ function openExternalUrl(url: string) {
|
||||
<Label :class="connectionLabelSmallClass">{{ t("connection.redisKeySeparator") }}</Label>
|
||||
<Input v-model="form.redis_key_separator" class="col-span-3 h-8 text-xs" placeholder=":" />
|
||||
</div>
|
||||
<div class="grid grid-cols-4 items-start gap-4">
|
||||
<Label for="redis-key-filter" :class="connectionLabelTopClass">{{ t("connection.redisKeyFilter") }}</Label>
|
||||
<div class="col-span-3 space-y-1">
|
||||
<Input id="redis-key-filter" v-model="form.redis_key_filter" class="h-8 text-xs" placeholder="order:*" spellcheck="false" />
|
||||
<p class="text-xs text-muted-foreground">{{ t("connection.redisKeyFilterHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-4 items-start gap-4">
|
||||
<Label :class="connectionLabelTopClass">{{ t("connection.redisKeyTemplates") }}</Label>
|
||||
<div class="col-span-3 space-y-1">
|
||||
|
||||
+437
-14
@@ -9,6 +9,9 @@ import type { RedisKeyInfo } from "@/lib/backend/api";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
redisScanKeysBatch: vi.fn(),
|
||||
redisScanValues: vi.fn(),
|
||||
redisKeyFilter: "",
|
||||
renamedKeyName: "",
|
||||
redisGetValue: vi.fn(),
|
||||
redisSetString: vi.fn(),
|
||||
redisJsonSet: vi.fn(),
|
||||
@@ -47,10 +50,12 @@ const mocks = vi.hoisted(() => ({
|
||||
queryResultMaxRowsEnabled: true,
|
||||
queryResultMaxRows: 5000,
|
||||
loadedTtl: -1,
|
||||
loadedKeyMissing: false,
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/backend/api", () => ({
|
||||
redisScanKeysBatch: mocks.redisScanKeysBatch,
|
||||
redisScanValues: mocks.redisScanValues,
|
||||
redisGetValue: mocks.redisGetValue,
|
||||
redisSetString: mocks.redisSetString,
|
||||
redisJsonSet: mocks.redisJsonSet,
|
||||
@@ -88,7 +93,7 @@ vi.mock("@/lib/redis/redisKeyTree", async (importOriginal) => {
|
||||
vi.mock("@/stores/connectionStore", () => ({
|
||||
useConnectionStore: () => ({
|
||||
ensureConnected: vi.fn().mockResolvedValue(undefined),
|
||||
getConfig: () => ({ name: "Redis", redis_key_separator: ":", redis_scan_page_size: mocks.redisScanPageSize }),
|
||||
getConfig: () => ({ name: "Redis", redis_key_filter: mocks.redisKeyFilter, redis_key_separator: ":", redis_scan_page_size: mocks.redisScanPageSize }),
|
||||
updateRedisDbKeyStats: mocks.updateRedisDbKeyStats,
|
||||
listRedisCompletionCommandDocs: mocks.listRedisCompletionCommandDocs,
|
||||
listRedisCompletionKeys: mocks.listRedisCompletionKeys,
|
||||
@@ -316,20 +321,30 @@ vi.mock("./RedisValueViewer.vue", async () => {
|
||||
return {
|
||||
default: defineComponent({
|
||||
props: { keyDisplay: String, keyRaw: String },
|
||||
emits: ["loaded"],
|
||||
emits: ["loaded", "renamed", "deleted"],
|
||||
setup(props, { emit }) {
|
||||
return () =>
|
||||
h("button", {
|
||||
"data-test-emit-key-loaded": "",
|
||||
onClick: () =>
|
||||
emit("loaded", {
|
||||
key_display: props.keyDisplay,
|
||||
key_raw: props.keyRaw,
|
||||
ttl: mocks.loadedTtl,
|
||||
redis_type: "hash",
|
||||
data: { kind: "hash", items: [] },
|
||||
}),
|
||||
});
|
||||
h("div", [
|
||||
h("button", {
|
||||
"data-test-emit-key-loaded": "",
|
||||
onClick: () =>
|
||||
emit("loaded", {
|
||||
key_display: props.keyDisplay,
|
||||
key_raw: props.keyRaw,
|
||||
ttl: mocks.loadedTtl,
|
||||
redis_type: mocks.loadedKeyMissing ? "none" : "hash",
|
||||
data: { kind: "hash", items: [] },
|
||||
}),
|
||||
}),
|
||||
h("button", {
|
||||
"data-test-emit-key-renamed": "",
|
||||
onClick: () => emit("renamed", props.keyRaw, btoa(mocks.renamedKeyName), mocks.renamedKeyName),
|
||||
}),
|
||||
h("button", {
|
||||
"data-test-emit-key-deleted": "",
|
||||
onClick: () => emit("deleted", props.keyRaw),
|
||||
}),
|
||||
]);
|
||||
},
|
||||
}),
|
||||
};
|
||||
@@ -477,10 +492,14 @@ function deferred<T>() {
|
||||
function resetApiMocks() {
|
||||
vi.clearAllMocks();
|
||||
mocks.redisScanPageSize = 100;
|
||||
mocks.redisKeyFilter = "";
|
||||
mocks.renamedKeyName = "";
|
||||
mocks.redisScanValues.mockResolvedValue({ cursor: 0, keys: [], total_keys: 0 });
|
||||
mocks.infiniteScroll = false;
|
||||
mocks.queryResultMaxRowsEnabled = true;
|
||||
mocks.queryResultMaxRows = 5000;
|
||||
mocks.loadedTtl = -1;
|
||||
mocks.loadedKeyMissing = false;
|
||||
mocks.scrollerItems.length = 0;
|
||||
mocks.scrollerCallOrder.length = 0;
|
||||
mocks.scrollerVisiblePositions.length = 0;
|
||||
@@ -1642,6 +1661,10 @@ describe("RedisKeyBrowser fuzzy key hierarchy", () => {
|
||||
expect(document.body.textContent).toContain("redis.noKeysInScanHint");
|
||||
|
||||
clickButtonWithText("redis.loadMoreKeys");
|
||||
await vi.waitFor(() => expect(groupRowOrUndefined("issue5012")).toBeDefined());
|
||||
expect(Array.from(document.querySelectorAll<HTMLElement>(".dbx-editor-font-family")).map((element) => element.textContent)).not.toContain("target");
|
||||
groupRow("issue5012").dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
|
||||
await settle();
|
||||
await vi.waitFor(() => {
|
||||
const labels = Array.from(document.querySelectorAll<HTMLElement>(".dbx-editor-font-family")).map((element) => element.textContent);
|
||||
expect(labels).toContain("target");
|
||||
@@ -1701,6 +1724,10 @@ describe("RedisKeyBrowser fuzzy key hierarchy", () => {
|
||||
});
|
||||
|
||||
await submitKeySearch("issue5012");
|
||||
await vi.waitFor(() => expect(groupRowOrUndefined("issue5012")).toBeDefined());
|
||||
expect(document.body.textContent).not.toContain("first");
|
||||
groupRow("issue5012").dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
|
||||
await settle();
|
||||
await vi.waitFor(() => expect(document.body.textContent).toContain("first"));
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1+ keys");
|
||||
|
||||
@@ -1752,6 +1779,11 @@ describe("RedisKeyBrowser fuzzy key hierarchy", () => {
|
||||
requiredElement<HTMLInputElement>("[data-redis-search-input]").dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
|
||||
await settle();
|
||||
|
||||
expect(groupRowOrUndefined("old")).toBeUndefined();
|
||||
expect(groupRowOrUndefined("new")).toBeDefined();
|
||||
expect(document.body.textContent).not.toContain("result");
|
||||
groupRow("new").dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
|
||||
await settle();
|
||||
await vi.waitFor(() => expect(document.body.textContent).toContain("result"));
|
||||
expect(mocks.redisScanKeysBatch.mock.calls.map((call) => call[3])).toEqual(["*old*", "*new*"]);
|
||||
});
|
||||
@@ -1872,7 +1904,17 @@ describe("RedisKeyBrowser fuzzy key hierarchy", () => {
|
||||
clickButtonWithText("redis.fuzzyMatch");
|
||||
await settle();
|
||||
|
||||
// Hierarchy restores leaf + group checkboxes (groups stay opacity-0 until hover/selection).
|
||||
// New searches start collapsed; expanding each level reveals the original
|
||||
// leaf and group controls without broadening the loaded matching subset.
|
||||
expect(document.querySelectorAll('input[type="checkbox"]')).toHaveLength(1);
|
||||
expect(groupRowOrUndefined("profile")).toBeUndefined();
|
||||
const scanCallsBeforeExpand = mocks.redisScanKeysBatch.mock.calls.length;
|
||||
groupRow("user").dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
|
||||
await settle();
|
||||
expect(document.querySelectorAll('input[type="checkbox"]')).toHaveLength(3);
|
||||
groupRow("profile").dispatchEvent(new MouseEvent("click", { bubbles: true, cancelable: true }));
|
||||
await settle();
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(scanCallsBeforeExpand);
|
||||
expect(document.querySelectorAll('input[type="checkbox"]')).toHaveLength(keys.length + 2);
|
||||
await selectGroup("user");
|
||||
|
||||
@@ -2733,3 +2775,384 @@ describe("RedisKeyBrowser interrupted Fetch All", () => {
|
||||
expect(checkboxes.every((checkbox) => !isCheckboxChecked(checkbox as HTMLElement))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("RedisKeyBrowser connection default key scope", () => {
|
||||
const key = (name: string): RedisKeyInfo => ({ key_display: name, key_raw: btoa(name), key_type: "string", ttl: -1 });
|
||||
const first = key("order:region01:pending");
|
||||
const second = key("order:region02:paid");
|
||||
const outside = key("session:pending");
|
||||
|
||||
beforeEach(() => {
|
||||
mocks.redisKeyFilter = "order:*";
|
||||
});
|
||||
|
||||
it("keeps the input and history empty while browsing a collapsed, scoped hierarchy", async () => {
|
||||
localStorage.removeItem("dbx-redis-key-search-history");
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first, second, outside], total_keys: 1305 });
|
||||
mountBrowser();
|
||||
await settle();
|
||||
|
||||
expect(requiredElement<HTMLInputElement>("[data-redis-search-input]").value).toBe("");
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[0]?.[3]).toBe("order:*");
|
||||
expect(groupRowOrUndefined("order")).toBeDefined();
|
||||
expect(groupRowOrUndefined("region01")).toBeUndefined();
|
||||
expect(groupRowOrUndefined("session")).toBeUndefined();
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("2 keys");
|
||||
requiredElement<HTMLButtonElement>("[data-redis-search-history-toggle]").click();
|
||||
await settle();
|
||||
expect(document.querySelectorAll("[data-redis-search-history-item]")).toHaveLength(0);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["exact", "session:pending", false, "session:pending", [outside], 0],
|
||||
["glob", "order:region*", false, "order:region*", [first, second], 2],
|
||||
["fuzzy", "pending", true, "*pending*", [first, outside], 1],
|
||||
] as const)("intersects %s user search with the default scope and restores the scope on clearing", async (_kind, query, fuzzy, pattern, results, count) => {
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first, second], total_keys: 1305 });
|
||||
mountBrowser();
|
||||
await settle();
|
||||
if (fuzzy) {
|
||||
clickButtonWithText("redis.fuzzyMatch");
|
||||
await settle();
|
||||
}
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: results, total_keys: 1305 });
|
||||
await submitKeySearch(query);
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe(pattern);
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe(`${count} keys`);
|
||||
expect(document.querySelector(`[data-redis-leaf="${outside.key_raw}"]`)).toBeNull();
|
||||
if (fuzzy) {
|
||||
expect(groupRowOrUndefined("order")).toBeDefined();
|
||||
expect(groupRowOrUndefined("region01")).toBeUndefined();
|
||||
} else if (count) {
|
||||
expect(document.querySelector(`[data-redis-leaf="${first.key_raw}"]`)).not.toBeNull();
|
||||
}
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first, second], total_keys: 1305 });
|
||||
await submitKeySearch("");
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe("order:*");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("2 keys");
|
||||
expect(groupRowOrUndefined("region01")).toBeUndefined();
|
||||
});
|
||||
|
||||
it.each(["value", "all"] as const)("passes the default scope through %s search and its Fetch All continuation", async (mode) => {
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first], total_keys: 1305 });
|
||||
mocks.redisScanValues.mockImplementation((_id, _db, cursor) => Promise.resolve(cursor === 0 ? { cursor: 7, keys: [first, outside], total_keys: 1305 } : { cursor: 0, keys: [second, outside], total_keys: 0 }));
|
||||
mountBrowser();
|
||||
await settle();
|
||||
clickButtonWithText(mode === "value" ? "redis.searchByValue" : "redis.searchByAll");
|
||||
await settle();
|
||||
expect(mocks.redisScanValues).not.toHaveBeenCalled();
|
||||
expect(groupRowOrUndefined("order")).toBeDefined();
|
||||
await submitKeySearch("value-needle");
|
||||
expect(mocks.redisScanValues).toHaveBeenCalledWith("connection", 0, 0, "order:*", "value-needle", 100, mode === "all");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1+ keys");
|
||||
clickButtonWithText("redis.fetchAllKeys");
|
||||
await settle();
|
||||
await vi.waitFor(() => expect(document.body.textContent).not.toContain("redis.stopFetchAll"));
|
||||
expect(mocks.redisScanValues).toHaveBeenLastCalledWith("connection", 0, 7, "order:*", "value-needle", 100, mode === "all");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("2 keys");
|
||||
expect(groupRowOrUndefined("session")).toBeUndefined();
|
||||
await submitKeySearch("");
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe("order:*");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys");
|
||||
});
|
||||
|
||||
it("retains a cursor and bounded continuation when every backend match is outside the scope", async () => {
|
||||
mocks.redisScanPageSize = 1000;
|
||||
mountBrowser();
|
||||
await settle();
|
||||
let batch = 0;
|
||||
mocks.redisScanKeysBatch.mockReset();
|
||||
mocks.redisScanKeysBatch.mockImplementation(() => {
|
||||
batch += 1;
|
||||
return Promise.resolve(batch === 8 ? { cursor: 0, keys: [first], total_keys: 0 } : { cursor: batch, keys: [outside], total_keys: 5_000_000 });
|
||||
});
|
||||
await submitKeySearch("*pending*");
|
||||
await vi.waitFor(() => expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(7));
|
||||
await vi.waitFor(() => expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("0+ keys"));
|
||||
clickButtonWithText("redis.loadMoreKeys");
|
||||
await vi.waitFor(() => expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys"));
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[7]?.[2]).toBe(7);
|
||||
expect(document.querySelector(`[data-redis-leaf="${outside.key_raw}"]`)).toBeNull();
|
||||
});
|
||||
|
||||
it("caches only the completed default scope for local searches and clearing", async () => {
|
||||
mocks.redisScanKeysBatch.mockImplementation((_id, _db, cursor) => Promise.resolve(cursor === 0 ? { cursor: 1, keys: [first], total_keys: 1305 } : { cursor: 0, keys: [second, outside], total_keys: 0 }));
|
||||
mountBrowser();
|
||||
await settle();
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1+ keys");
|
||||
clickButtonWithText("redis.fetchAllKeys");
|
||||
await settle();
|
||||
await vi.waitFor(() => expect(document.body.textContent).not.toContain("redis.stopFetchAll"));
|
||||
const scanCalls = mocks.redisScanKeysBatch.mock.calls.length;
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("2 keys");
|
||||
await submitKeySearch("session:*");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("0 keys");
|
||||
await submitKeySearch(first.key_display);
|
||||
expect(document.querySelector(`[data-redis-leaf="${first.key_raw}"]`)).not.toBeNull();
|
||||
await submitKeySearch("");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("2 keys");
|
||||
expect(groupRowOrUndefined("region01")).toBeUndefined();
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(scanCalls);
|
||||
});
|
||||
|
||||
it("does not treat a completed user-filtered Fetch All as the complete scope", async () => {
|
||||
mountBrowser();
|
||||
await settle();
|
||||
mocks.redisScanKeysBatch.mockImplementation((_id, _db, cursor, pattern) => Promise.resolve(pattern === "order:region01:*" ? { cursor: cursor === 0 ? 1 : 0, keys: [first], total_keys: 1305 } : { cursor: 0, keys: [first, second], total_keys: 1305 }));
|
||||
await submitKeySearch("order:region01:*");
|
||||
clickButtonWithText("redis.fetchAllKeys");
|
||||
await settle();
|
||||
await vi.waitFor(() => expect(document.body.textContent).not.toContain("redis.stopFetchAll"));
|
||||
const scanCalls = mocks.redisScanKeysBatch.mock.calls.length;
|
||||
await submitKeySearch("");
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(scanCalls + 1);
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe("order:*");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("2 keys");
|
||||
});
|
||||
|
||||
it("preserves expanded groups on refresh without subtree scans or whole-prefix deletion", async () => {
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first, second], total_keys: 1305 });
|
||||
mocks.redisDeleteKeys.mockResolvedValue(2);
|
||||
mountBrowser();
|
||||
await settle();
|
||||
groupRow("order").click();
|
||||
await settle();
|
||||
groupRow("region01").click();
|
||||
await settle();
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(1);
|
||||
expect(document.querySelector('button[title="redis.deleteGroup"]')).toBeNull();
|
||||
const refresh = Array.from(document.querySelectorAll<HTMLButtonElement>("button")).find((button) => button.className.includes("h-6 w-6") && !button.hasAttribute("title"));
|
||||
expect(refresh).toBeDefined();
|
||||
refresh!.click();
|
||||
await settle();
|
||||
expect(document.querySelector(`[data-redis-leaf="${first.key_raw}"]`)).not.toBeNull();
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(2);
|
||||
await selectGroup("order");
|
||||
requiredElement<HTMLButtonElement>("[data-redis-batch-delete]").click();
|
||||
await settle();
|
||||
requiredElement<HTMLButtonElement>("[data-test-danger-confirm]").click();
|
||||
await settle();
|
||||
expect(mocks.redisDeleteKeys).toHaveBeenCalledWith("connection", 0, [first.key_raw, second.key_raw]);
|
||||
expect(mocks.redisDeleteKeysByPattern).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("discards a late scoped scan after the user changes the query", async () => {
|
||||
const stale = deferred<{ cursor: number; keys: RedisKeyInfo[]; total_keys: number }>();
|
||||
mocks.redisScanKeysBatch.mockReturnValueOnce(stale.promise);
|
||||
mountBrowser();
|
||||
await settle();
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [second], total_keys: 1305 });
|
||||
await submitKeySearch(second.key_display);
|
||||
stale.resolve({ cursor: 0, keys: [first], total_keys: 1305 });
|
||||
await settle();
|
||||
expect(document.querySelector(`[data-redis-leaf="${first.key_raw}"]`)).toBeNull();
|
||||
expect(document.querySelector(`[data-redis-leaf="${second.key_raw}"]`)).not.toBeNull();
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys");
|
||||
});
|
||||
|
||||
it.each(["cached-key", "key", "value", "all"] as const)("reapplies %s search after creating an in-scope nonmatching key", async (mode) => {
|
||||
const created = key("order:region03:new");
|
||||
mocks.redisScanKeysBatch.mockImplementation((_id, _db, cursor) => Promise.resolve(cursor === 0 ? { cursor: 1, keys: [first], total_keys: 1305 } : { cursor: 0, keys: [second], total_keys: 0 }));
|
||||
mountBrowser();
|
||||
await settle();
|
||||
if (mode === "cached-key") {
|
||||
clickButtonWithText("redis.fetchAllKeys");
|
||||
await settle();
|
||||
await vi.waitFor(() => expect(document.body.textContent).not.toContain("redis.stopFetchAll"));
|
||||
}
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first], total_keys: 1305 });
|
||||
mocks.redisScanValues.mockResolvedValue({ cursor: 0, keys: [first], total_keys: 1305 });
|
||||
const valueSearch = mode === "value" || mode === "all";
|
||||
if (valueSearch) {
|
||||
clickButtonWithText(mode === "value" ? "redis.searchByValue" : "redis.searchByAll");
|
||||
await settle();
|
||||
}
|
||||
const query = valueSearch ? "value-needle" : first.key_display;
|
||||
await submitKeySearch(query);
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys");
|
||||
const scanCalls = valueSearch ? mocks.redisScanValues.mock.calls.length : mocks.redisScanKeysBatch.mock.calls.length;
|
||||
mocks.redisGetValue.mockResolvedValue({ ...redisValue(created.key_raw), key_display: created.key_display });
|
||||
await openCreateDialog();
|
||||
await setInput('input[placeholder="redis.createKeyNamePlaceholder"]', created.key_display);
|
||||
await fillCreateValue("string");
|
||||
await submitCreate();
|
||||
expect(mocks.redisSetString).toHaveBeenCalledWith("connection", 0, created.key_raw, "value");
|
||||
expect(requiredElement<HTMLInputElement>("[data-redis-search-input]").value).toBe(query);
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys");
|
||||
expect(document.querySelector(`[data-redis-leaf="${created.key_raw}"]`)).toBeNull();
|
||||
if (valueSearch) {
|
||||
expect(mocks.redisScanValues).toHaveBeenCalledTimes(scanCalls + 1);
|
||||
expect(mocks.redisScanValues).toHaveBeenLastCalledWith("connection", 0, 0, "order:*", query, 100, mode === "all");
|
||||
} else {
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(scanCalls + 1);
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe(query);
|
||||
expect(document.querySelector(`[data-redis-leaf="${first.key_raw}"]`)).not.toBeNull();
|
||||
expect(document.querySelector(`[data-redis-leaf="${second.key_raw}"]`)).toBeNull();
|
||||
}
|
||||
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first, second, created, outside], total_keys: 1306 });
|
||||
await submitKeySearch("");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("3 keys");
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe("order:*");
|
||||
expect(groupRowOrUndefined("session")).toBeUndefined();
|
||||
groupRow("order").click();
|
||||
await settle();
|
||||
groupRow("region03").click();
|
||||
await settle();
|
||||
expect(document.querySelector(`[data-redis-leaf="${created.key_raw}"]`)).not.toBeNull();
|
||||
});
|
||||
|
||||
it.each(["deleted", "missing"] as const)("reapplies local search when the selected key is %s", async (event) => {
|
||||
mocks.redisScanKeysBatch.mockImplementation((_id, _db, cursor) => Promise.resolve(cursor === 0 ? { cursor: 1, keys: [first], total_keys: 1305 } : { cursor: 0, keys: [second], total_keys: 0 }));
|
||||
mountBrowser();
|
||||
await settle();
|
||||
clickButtonWithText("redis.fetchAllKeys");
|
||||
await settle();
|
||||
await vi.waitFor(() => expect(document.body.textContent).not.toContain("redis.stopFetchAll"));
|
||||
await submitKeySearch(first.key_display);
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys");
|
||||
requiredElement<HTMLElement>(`[data-redis-leaf="${first.key_raw}"]`).closest<HTMLElement>(".group")!.click();
|
||||
await settle();
|
||||
const scanCalls = mocks.redisScanKeysBatch.mock.calls.length;
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [], total_keys: 1304 });
|
||||
mocks.loadedKeyMissing = event === "missing";
|
||||
requiredElement<HTMLButtonElement>(event === "missing" ? "[data-test-emit-key-loaded]" : "[data-test-emit-key-deleted]").click();
|
||||
await settle();
|
||||
expect(requiredElement<HTMLInputElement>("[data-redis-search-input]").value).toBe(first.key_display);
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("0 keys");
|
||||
expect(document.querySelector(`[data-redis-leaf="${second.key_raw}"]`)).toBeNull();
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(scanCalls + 1);
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe(first.key_display);
|
||||
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [second, outside], total_keys: 1304 });
|
||||
await submitKeySearch("");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys");
|
||||
groupRow("order").click();
|
||||
await settle();
|
||||
groupRow("region02").click();
|
||||
await settle();
|
||||
expect(document.querySelector(`[data-redis-leaf="${second.key_raw}"]`)).not.toBeNull();
|
||||
expect(groupRowOrUndefined("session")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("preserves local search and the completed scope after creating an out-of-scope key", async () => {
|
||||
mocks.redisScanKeysBatch.mockImplementation((_id, _db, cursor) => Promise.resolve(cursor === 0 ? { cursor: 1, keys: [first], total_keys: 1305 } : { cursor: 0, keys: [second], total_keys: 0 }));
|
||||
mountBrowser();
|
||||
await settle();
|
||||
clickButtonWithText("redis.fetchAllKeys");
|
||||
await settle();
|
||||
await vi.waitFor(() => expect(document.body.textContent).not.toContain("redis.stopFetchAll"));
|
||||
const scanCalls = mocks.redisScanKeysBatch.mock.calls.length;
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("2 keys");
|
||||
|
||||
await submitKeySearch(first.key_display);
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys");
|
||||
await openCreateDialog();
|
||||
await fillCreateValue("string");
|
||||
await submitCreate();
|
||||
expect(mocks.redisSetString).toHaveBeenCalled();
|
||||
expect(requiredElement<HTMLInputElement>("[data-redis-search-input]").value).toBe(first.key_display);
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys");
|
||||
expect(document.querySelector(`[data-redis-leaf="${first.key_raw}"]`)).not.toBeNull();
|
||||
expect(document.querySelector(`[data-redis-leaf="${second.key_raw}"]`)).toBeNull();
|
||||
expect(document.querySelector(`[data-redis-leaf="${KEY_RAW}"]`)).toBeNull();
|
||||
|
||||
await submitKeySearch("");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("2 keys");
|
||||
groupRow("order").click();
|
||||
await settle();
|
||||
groupRow("region01").click();
|
||||
groupRow("region02").click();
|
||||
await settle();
|
||||
expect(document.querySelector(`[data-redis-leaf="${first.key_raw}"]`)).not.toBeNull();
|
||||
expect(document.querySelector(`[data-redis-leaf="${second.key_raw}"]`)).not.toBeNull();
|
||||
expect(document.querySelector(`[data-redis-leaf="${KEY_RAW}"]`)).toBeNull();
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(scanCalls);
|
||||
});
|
||||
|
||||
it("does not insert a newly created out-of-scope key into the list", async () => {
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first], total_keys: 1305 });
|
||||
mountBrowser();
|
||||
await settle();
|
||||
await openCreateDialog();
|
||||
await fillCreateValue("string");
|
||||
await submitCreate();
|
||||
expect(mocks.redisSetString).toHaveBeenCalled();
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("1 keys");
|
||||
expect(document.querySelector(`[data-redis-leaf="${KEY_RAW}"]`)).toBeNull();
|
||||
expect(groupRowOrUndefined("order")).toBeDefined();
|
||||
});
|
||||
|
||||
it.each(["order:region01:renamed", "session:renamed"])("reloads the scoped tab on activation after a background rename to %s", async (newName) => {
|
||||
const renamed = key(newName);
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first, second], total_keys: 1305 });
|
||||
const browser = mountKeptAliveBrowser();
|
||||
await settle();
|
||||
groupRow("order").click();
|
||||
await settle();
|
||||
groupRow("region01").click();
|
||||
await settle();
|
||||
requiredElement<HTMLElement>(`[data-redis-leaf="${first.key_raw}"]`).closest<HTMLElement>(".group")!.click();
|
||||
await settle();
|
||||
const renameButton = requiredElement<HTMLButtonElement>("[data-test-emit-key-renamed]");
|
||||
const scanCalls = mocks.redisScanKeysBatch.mock.calls.length;
|
||||
await browser.deactivate();
|
||||
mocks.renamedKeyName = newName;
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [second, renamed], total_keys: 1305 });
|
||||
// Simulate the rename response arriving after KeepAlive paused the tab.
|
||||
renameButton.click();
|
||||
await settle();
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(scanCalls);
|
||||
|
||||
await browser.activate();
|
||||
await settle();
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(scanCalls + 1);
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe("order:*");
|
||||
expect(requiredElement<HTMLInputElement>("[data-redis-search-input]").value).toBe("");
|
||||
expect(document.querySelector(`[data-redis-leaf="${first.key_raw}"]`)).toBeNull();
|
||||
expect(document.querySelector("[data-test-emit-key-renamed]")).toBeNull();
|
||||
expect(groupRowOrUndefined("session")).toBeUndefined();
|
||||
if (newName.startsWith("order:")) {
|
||||
expect(document.querySelector(`[data-redis-leaf="${renamed.key_raw}"]`)).not.toBeNull();
|
||||
} else {
|
||||
expect(document.querySelector(`[data-redis-leaf="${renamed.key_raw}"]`)).toBeNull();
|
||||
}
|
||||
groupRow("region02").click();
|
||||
await settle();
|
||||
expect(document.querySelector(`[data-redis-leaf="${second.key_raw}"]`)).not.toBeNull();
|
||||
});
|
||||
|
||||
it("rescans and clears selection when a key is renamed outside the scope", async () => {
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first], total_keys: 1305 });
|
||||
mocks.redisGetValue.mockResolvedValue({ ...redisValue(first.key_raw), key_display: first.key_display });
|
||||
mountBrowser();
|
||||
await settle();
|
||||
groupRow("order").click();
|
||||
await settle();
|
||||
groupRow("region01").click();
|
||||
await settle();
|
||||
requiredElement<HTMLInputElement>(`[data-redis-leaf="${first.key_raw}"]`).closest<HTMLElement>(".group")!.click();
|
||||
await settle();
|
||||
await selectGroup("order");
|
||||
mocks.renamedKeyName = outside.key_display;
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [outside], total_keys: 1305 });
|
||||
requiredElement<HTMLButtonElement>("[data-test-emit-key-renamed]").click();
|
||||
await settle();
|
||||
expect(mocks.redisScanKeysBatch).toHaveBeenCalledTimes(2);
|
||||
expect(document.querySelector("[data-test-emit-key-renamed]")).toBeNull();
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe("order:*");
|
||||
expect(requiredElement<HTMLElement>(".redis-key-count").textContent).toBe("0 keys");
|
||||
expect(document.querySelector("[data-redis-batch-delete]")).toBeNull();
|
||||
});
|
||||
|
||||
it.each(["", "*"])("retains unscoped browsing when the default is %j", async (filter) => {
|
||||
mocks.redisKeyFilter = filter;
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [first, outside], total_keys: 1305 });
|
||||
mountBrowser();
|
||||
await settle();
|
||||
expect(requiredElement<HTMLInputElement>("[data-redis-search-input]").value).toBe("");
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[0]?.[3]).toBe("*");
|
||||
expect(groupRowOrUndefined("session")).toBeDefined();
|
||||
expect(groupRow("order").querySelector('button[title="redis.deleteGroup"]')).not.toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -30,6 +30,7 @@ const mocks = vi.hoisted(() => ({
|
||||
listRedisCompletionCommandDocs: vi.fn(),
|
||||
listRedisCompletionKeys: vi.fn(),
|
||||
redisScanPageSize: 100,
|
||||
redisKeyFilter: "",
|
||||
infiniteScroll: false,
|
||||
queryResultMaxRowsEnabled: true,
|
||||
queryResultMaxRows: 5000,
|
||||
@@ -60,7 +61,7 @@ vi.mock("@/lib/backend/api", () => ({
|
||||
vi.mock("@/stores/connectionStore", () => ({
|
||||
useConnectionStore: () => ({
|
||||
ensureConnected: vi.fn().mockResolvedValue(undefined),
|
||||
getConfig: () => ({ name: "Redis", redis_key_separator: ":", redis_scan_page_size: mocks.redisScanPageSize }),
|
||||
getConfig: () => ({ name: "Redis", redis_key_filter: mocks.redisKeyFilter, redis_key_separator: ":", redis_scan_page_size: mocks.redisScanPageSize }),
|
||||
updateRedisDbKeyStats: mocks.updateRedisDbKeyStats,
|
||||
listRedisCompletionCommandDocs: mocks.listRedisCompletionCommandDocs,
|
||||
listRedisCompletionKeys: mocks.listRedisCompletionKeys,
|
||||
@@ -300,6 +301,7 @@ function unmountBrowser(host: HTMLElement) {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mocks.redisKeyFilter = "";
|
||||
mocks.redisScanKeysBatch.mockResolvedValue({ cursor: 0, keys: [], total_keys: 0 });
|
||||
clearRedisKeyBrowserState("tab-redis-filter");
|
||||
clearRedisKeyBrowserState("tab-a");
|
||||
@@ -364,4 +366,23 @@ describe("RedisKeyBrowser tab state (tab switch persistence)", () => {
|
||||
const tabACalls = mocks.redisScanKeysBatch.mock.calls;
|
||||
expect(tabACalls[tabACalls.length - 1]![3]).toBe("alpha:*");
|
||||
});
|
||||
|
||||
it("snapshots the default scope per tab while keeping the user input separate", async () => {
|
||||
mocks.redisKeyFilter = "order:*";
|
||||
const hostA = mountBrowser("tab-a");
|
||||
await settle();
|
||||
expect((hostA.querySelector("[data-redis-search-input]") as HTMLInputElement).value).toBe("");
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe("order:*");
|
||||
unmountBrowser(hostA);
|
||||
mocks.redisKeyFilter = "session:*";
|
||||
const restoredA = mountBrowser("tab-a");
|
||||
await settle();
|
||||
expect((restoredA.querySelector("[data-redis-search-input]") as HTMLInputElement).value).toBe("");
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe("order:*");
|
||||
unmountBrowser(restoredA);
|
||||
const hostB = mountBrowser("tab-b");
|
||||
await settle();
|
||||
expect((hostB.querySelector("[data-redis-search-input]") as HTMLInputElement).value).toBe("");
|
||||
expect(mocks.redisScanKeysBatch.mock.calls[mocks.redisScanKeysBatch.mock.calls.length - 1]?.[3]).toBe("session:*");
|
||||
});
|
||||
});
|
||||
@@ -159,6 +159,9 @@ let redisKeyScrollRevision = 0;
|
||||
let latestRedisKeyScrollAnchor: RedisKeyViewportAnchor | null = null;
|
||||
const valueViewerRef = ref<{ focusSearch: () => boolean } | null>(null);
|
||||
const commandTerminalRef = ref<HTMLElement>();
|
||||
// Snapshot the default for this tab. Editing the connection must not replace a
|
||||
// user's active search or silently change its matching/display semantics.
|
||||
const defaultKeyFilter = ref(restoredRedisKeyBrowserState?.defaultKeyFilter ?? connectionStore.getConfig(props.connectionId)?.redis_key_filter?.trim() ?? "");
|
||||
const searchPattern = ref(restoredRedisKeyBrowserState?.searchPattern ?? "");
|
||||
const searchMode = ref<RedisSearchMode>(restoredRedisKeyBrowserState?.searchMode ?? "key");
|
||||
const fuzzyKeySearch = ref(restoredRedisKeyBrowserState?.fuzzyKeySearch ?? false);
|
||||
@@ -305,12 +308,30 @@ const effectivePattern = computed(() => (searchMode.value === "key" ? redisKeySe
|
||||
const isSearchMode = computed(() => (searchMode.value === "key" ? effectivePattern.value !== "*" : valueQuery.value !== ""));
|
||||
const localKeySearchActive = computed(() => fetchAllSnapshotComplete.value && searchMode.value === "key" && isSearchMode.value);
|
||||
const localKeyPatternMatcher = computed(() => createRedisKeyPatternMatcher(effectivePattern.value));
|
||||
// Keep regular glob search on the low-cost flat path. The explicit fuzzy mode
|
||||
// opts into the namespace hierarchy that users need for group selection.
|
||||
const isFuzzyKeySearch = computed(() => searchMode.value === "key" && isSearchMode.value && fuzzyKeySearch.value);
|
||||
const fuzzyTreeLimitReached = computed(() => isFuzzyKeySearch.value && !canBuildRedisFuzzyTree(flatKeys.value.length));
|
||||
const useFlatKeySearchRows = computed(() => showCustomGrouping.value || (searchMode.value === "key" && isSearchMode.value && !fuzzyKeySearch.value) || fuzzyTreeLimitReached.value);
|
||||
const isFuzzyHierarchyView = computed(() => isFuzzyKeySearch.value && !fuzzyTreeLimitReached.value);
|
||||
// The connection scope is independent of user input. Redis MATCH accepts one
|
||||
// pattern, so key searches scan the user's pattern and intersect it locally
|
||||
// with the scope using the same byte-safe matcher as cached key searches.
|
||||
const defaultScopePattern = computed(() => defaultKeyFilter.value || "*");
|
||||
const hasDefaultKeyScope = computed(() => defaultScopePattern.value !== "*");
|
||||
const defaultScopeMatcher = computed(() => createRedisKeyPatternMatcher(defaultScopePattern.value));
|
||||
const scanKeyPattern = computed(() => (effectivePattern.value !== "*" ? effectivePattern.value : defaultScopePattern.value));
|
||||
const hasFilteredKeyRange = computed(() => hasDefaultKeyScope.value || isSearchMode.value);
|
||||
const isKeyHierarchySearch = computed(() => (searchMode.value === "key" && isSearchMode.value ? fuzzyKeySearch.value : hasDefaultKeyScope.value));
|
||||
const searchTreeLimitReached = computed(() => isKeyHierarchySearch.value && !canBuildRedisFuzzyTree(flatKeys.value.length));
|
||||
function useFlatSearchResults(keyCount: number): boolean {
|
||||
return (searchMode.value === "key" && isSearchMode.value && !fuzzyKeySearch.value) || (isKeyHierarchySearch.value && !canBuildRedisFuzzyTree(keyCount));
|
||||
}
|
||||
const useFlatKeySearchRows = computed(() => showCustomGrouping.value || useFlatSearchResults(flatKeys.value.length));
|
||||
const isFilteredHierarchyView = computed(() => isKeyHierarchySearch.value && !searchTreeLimitReached.value);
|
||||
const canDeleteWholeGroup = computed(() => !hasDefaultKeyScope.value && !isFilteredHierarchyView.value);
|
||||
|
||||
function matchesDefaultKeyScope(key: Pick<RedisKeyInfo, "key_display" | "key_raw">): boolean {
|
||||
return !hasDefaultKeyScope.value || defaultScopeMatcher.value(key.key_display, key.key_raw);
|
||||
}
|
||||
|
||||
function filterScanResultToScope(result: RedisScanResult): RedisScanResult {
|
||||
return hasDefaultKeyScope.value ? { ...result, keys: result.keys.filter(matchesDefaultKeyScope) } : result;
|
||||
}
|
||||
/** True while a key-list mutation (delete or batch expiry) owns the visible result set. */
|
||||
const mutatingKeys = computed(() => deletingKeys.value || savingBatchExpiry.value);
|
||||
const selectionBusy = computed(() => mutatingKeys.value || loading.value || loadingMore.value || isFetchingAll.value || searchPending.value);
|
||||
@@ -353,7 +374,7 @@ watch(redisKeySeparator, () => {
|
||||
expandedGroupIds.value = new Set();
|
||||
return;
|
||||
}
|
||||
rebuildTree(false);
|
||||
rebuildTree();
|
||||
});
|
||||
const lastTotalKeys = ref(0);
|
||||
// “仅看无过期”过滤开关:开启后只保留 TTL 为 -1(永不过期)的已加载 key。
|
||||
@@ -363,6 +384,7 @@ const noExpiryOnly = ref(restoredRedisKeyBrowserState?.noExpiryOnly ?? false);
|
||||
function persistRedisKeyBrowserState() {
|
||||
if (!props.stateKey) return;
|
||||
saveRedisKeyBrowserState(props.stateKey, {
|
||||
defaultKeyFilter: defaultKeyFilter.value,
|
||||
searchPattern: searchPattern.value,
|
||||
searchMode: searchMode.value,
|
||||
fuzzyKeySearch: fuzzyKeySearch.value,
|
||||
@@ -370,7 +392,7 @@ function persistRedisKeyBrowserState() {
|
||||
});
|
||||
}
|
||||
|
||||
watch([searchPattern, searchMode, fuzzyKeySearch, noExpiryOnly], persistRedisKeyBrowserState);
|
||||
watch([searchPattern, searchMode, fuzzyKeySearch, noExpiryOnly, defaultKeyFilter], persistRedisKeyBrowserState, { immediate: true });
|
||||
const fetchAllFilteredKeyCount = ref<number | null>(null);
|
||||
// 过滤后的平铺 key 列表:未开启过滤时与 flatKeys 完全一致,避免额外开销
|
||||
const filteredFlatKeys = computed(() => {
|
||||
@@ -386,14 +408,22 @@ const filteredTreeKeys = computed(() => {
|
||||
if (!noExpiryOnly.value && !localKeySearchActive.value) return treeKeys.value;
|
||||
return buildRedisKeyTree(filteredFlatKeys.value, props.db, redisKeySeparator.value);
|
||||
});
|
||||
watch(effectivePattern, () => {
|
||||
if (!fetchAllSnapshotComplete.value || searchMode.value !== "key") return;
|
||||
if (localKeySearchActive.value && isFuzzyHierarchyView.value) expandedGroupIds.value = collectExpandedGroupIds(filteredTreeKeys.value);
|
||||
void nextTick(() => {
|
||||
redisKeyScroller()?.scrollToItem(0, { align: "start" });
|
||||
refreshRedisKeyScroller();
|
||||
});
|
||||
});
|
||||
watch(
|
||||
[effectivePattern, searchMode],
|
||||
() => {
|
||||
// A new search starts collapsed. Refreshing the same search preserves manual
|
||||
// expansion through the existing refresh snapshot, including later pages.
|
||||
legacyExpandedBeforeGrouping = new Set();
|
||||
expandedGroupIds.value = new Set();
|
||||
refreshExpandedGroupIds.clear();
|
||||
if (!fetchAllSnapshotComplete.value || searchMode.value !== "key") return;
|
||||
void nextTick(() => {
|
||||
redisKeyScroller()?.scrollToItem(0, { align: "start" });
|
||||
refreshRedisKeyScroller();
|
||||
});
|
||||
},
|
||||
{ flush: "sync" },
|
||||
);
|
||||
const displayedKeyCount = computed(() => {
|
||||
if (isFetchingAll.value) return fetchAllLoadedCount.value;
|
||||
if (localKeySearchActive.value) return filteredFlatKeys.value.length;
|
||||
@@ -403,17 +433,17 @@ const displayedKeyCount = computed(() => {
|
||||
});
|
||||
const fetchAllProgressText = computed(() => {
|
||||
if (!isFetchingAll.value) return "";
|
||||
if (lastTotalKeys.value > 0) {
|
||||
if (!hasFilteredKeyRange.value && lastTotalKeys.value > 0) {
|
||||
return t("redis.fetchAllProgress", { loaded: displayedKeyCount.value, total: lastTotalKeys.value });
|
||||
}
|
||||
return t("redis.fetchAllProgressUnknown", { loaded: displayedKeyCount.value });
|
||||
});
|
||||
const keyCountText = computed(() => {
|
||||
if (loading.value && flatKeys.value.length === 0) return loadingEmptyText.value;
|
||||
if (!isSearchMode.value && lastTotalKeys.value > 0) {
|
||||
if (!hasFilteredKeyRange.value && lastTotalKeys.value > 0) {
|
||||
return t("redis.loadedKeys", { loaded: displayedKeyCount.value, total: lastTotalKeys.value });
|
||||
}
|
||||
const count = isSearchMode.value && hasMore.value && !isFetchingAll.value ? `${displayedKeyCount.value}+` : displayedKeyCount.value;
|
||||
const count = hasFilteredKeyRange.value && hasMore.value ? `${displayedKeyCount.value}+` : displayedKeyCount.value;
|
||||
return t("redis.keys", { count });
|
||||
});
|
||||
const selectedKey = computed(() => {
|
||||
@@ -909,7 +939,7 @@ function onKeyPaneKeydown(event: KeyboardEvent) {
|
||||
else void selectAllKeys();
|
||||
}
|
||||
|
||||
function rebuildTree(expandAll = false) {
|
||||
function rebuildTree() {
|
||||
deactivateFetchAllVisibleRows();
|
||||
if (useFlatKeySearchRows.value) {
|
||||
treeKeys.value = [];
|
||||
@@ -924,12 +954,8 @@ function rebuildTree(expandAll = false) {
|
||||
|
||||
const nextExpanded = new Set<string>();
|
||||
const availableExpanded = collectExpandedGroupIds(nextTree);
|
||||
if (expandAll) {
|
||||
for (const id of availableExpanded) nextExpanded.add(id);
|
||||
} else {
|
||||
for (const id of expandedGroupIds.value) {
|
||||
if (availableExpanded.has(id)) nextExpanded.add(id);
|
||||
}
|
||||
for (const id of expandedGroupIds.value) {
|
||||
if (availableExpanded.has(id)) nextExpanded.add(id);
|
||||
}
|
||||
expandedGroupIds.value = nextExpanded;
|
||||
refreshSelectedGroupLeafCounts();
|
||||
@@ -943,10 +969,10 @@ function mergeTree(newKeys: RedisKeyInfo[]) {
|
||||
if (newKeys.length === 0) return;
|
||||
deactivateFetchAllVisibleRows();
|
||||
if (!treeIndex) {
|
||||
rebuildTree(isSearchMode.value);
|
||||
rebuildTree();
|
||||
return;
|
||||
}
|
||||
const { addedGroupIds } = appendRedisKeysToTreeIndex(treeIndex, newKeys, props.db, redisKeySeparator.value);
|
||||
appendRedisKeysToTreeIndex(treeIndex, newKeys, props.db, redisKeySeparator.value);
|
||||
// Trigger the shallow ref without proxying the whole namespace hierarchy.
|
||||
treeKeys.value = [...treeIndex.root];
|
||||
|
||||
@@ -958,9 +984,6 @@ function mergeTree(newKeys: RedisKeyInfo[]) {
|
||||
for (const id of refreshExpandedGroupIds) {
|
||||
if (treeIndex.groupById.has(id)) nextExpanded.add(id);
|
||||
}
|
||||
if (isFuzzyHierarchyView.value) {
|
||||
for (const id of addedGroupIds) nextExpanded.add(id);
|
||||
}
|
||||
expandedGroupIds.value = nextExpanded;
|
||||
// loadedLeafCount changed — re-evaluate parent checked/partial state in the UI.
|
||||
if (checkedKeys.value.size > 0) selectionEpoch.value++;
|
||||
@@ -993,8 +1016,8 @@ function isCurrentScanOperation(requestId: number, operationId?: number): boolea
|
||||
|
||||
async function fetchScanPage(requestId = searchRequestId, operationId?: number, iterationBudget?: ScanIterationBudget): Promise<RedisScanResult> {
|
||||
const pageSize = redisScanPageSize.value;
|
||||
if (isValueSearchMode.value) {
|
||||
return api.redisScanValues(props.connectionId, props.db, scanCursor.value, "*", valueQuery.value, pageSize, searchMode.value === "all");
|
||||
if (isValueSearchMode.value && valueQuery.value) {
|
||||
return filterScanResultToScope(await api.redisScanValues(props.connectionId, props.db, scanCursor.value, defaultScopePattern.value, valueQuery.value, pageSize, searchMode.value === "all"));
|
||||
}
|
||||
|
||||
// Keep each backend call small so a changed search can cancel between calls.
|
||||
@@ -1019,7 +1042,7 @@ async function fetchScanPage(requestId = searchRequestId, operationId?: number,
|
||||
if (!isCurrentScanOperation(requestId, operationId)) break;
|
||||
const iterations = Math.min(iterationsPerCall, maxIterations - completedIterations);
|
||||
if (iterationBudget) iterationBudget.remaining -= iterations;
|
||||
const result = await api.redisScanKeysBatch(props.connectionId, props.db, cursor, effectivePattern.value, pageSize, iterations, true);
|
||||
const result = filterScanResultToScope(await api.redisScanKeysBatch(props.connectionId, props.db, cursor, scanKeyPattern.value, pageSize, iterations, true));
|
||||
completedIterations += iterations;
|
||||
if (totalKeys === 0) totalKeys = result.total_keys;
|
||||
if (isFuzzyKeySearch && totalKeys > 0) {
|
||||
@@ -1042,11 +1065,11 @@ async function fetchScanPage(requestId = searchRequestId, operationId?: number,
|
||||
async function fetchScanBatchPage(maxIterations: number, options: { count?: number; includeTypes?: boolean } = {}): Promise<RedisScanResult> {
|
||||
// Value search cannot be batched because each key requires a GET.
|
||||
// Keep its configured COUNT independent of the key-only bulk override.
|
||||
if (isValueSearchMode.value) {
|
||||
return api.redisScanValues(props.connectionId, props.db, scanCursor.value, "*", valueQuery.value, redisScanPageSize.value, searchMode.value === "all");
|
||||
if (isValueSearchMode.value && valueQuery.value) {
|
||||
return filterScanResultToScope(await api.redisScanValues(props.connectionId, props.db, scanCursor.value, defaultScopePattern.value, valueQuery.value, redisScanPageSize.value, searchMode.value === "all"));
|
||||
}
|
||||
const pageSize = options.count ?? redisScanPageSize.value;
|
||||
return api.redisScanKeysBatch(props.connectionId, props.db, scanCursor.value, effectivePattern.value, pageSize, maxIterations, options.includeTypes ?? false);
|
||||
return filterScanResultToScope(await api.redisScanKeysBatch(props.connectionId, props.db, scanCursor.value, scanKeyPattern.value, pageSize, maxIterations, options.includeTypes ?? false));
|
||||
}
|
||||
|
||||
function appendScanResult(result: RedisScanResult, options: { updateTree?: boolean; buffer?: RedisKeyInfo[] } = {}): number {
|
||||
@@ -1065,7 +1088,7 @@ function appendScanResult(result: RedisScanResult, options: { updateTree?: boole
|
||||
// pages return total_keys=0. Preserve the previously-fetched total when
|
||||
// we get a zero from a continuation. A truly empty DB returns cursor==0
|
||||
// and keys==[] along with total_keys==0, which we do record.
|
||||
if (result.total_keys > 0 || (result.cursor === 0 && result.keys.length === 0)) {
|
||||
if (result.total_keys > 0 || (result.cursor === 0 && result.keys.length === 0 && !hasFilteredKeyRange.value)) {
|
||||
lastTotalKeys.value = result.total_keys;
|
||||
}
|
||||
|
||||
@@ -1075,7 +1098,7 @@ function appendScanResult(result: RedisScanResult, options: { updateTree?: boole
|
||||
treeIndex = null;
|
||||
expandedGroupIds.value = new Set();
|
||||
} else if (treeKeys.value.length === 0) {
|
||||
rebuildTree(isSearchMode.value);
|
||||
rebuildTree();
|
||||
} else {
|
||||
mergeTree(newKeys);
|
||||
}
|
||||
@@ -1085,8 +1108,8 @@ function appendScanResult(result: RedisScanResult, options: { updateTree?: boole
|
||||
if (!hasMore.value) refreshExpandedGroupIds.clear();
|
||||
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, {
|
||||
loaded: isSearchMode.value ? undefined : loadedCount,
|
||||
total: result.total_keys > 0 || (result.cursor === 0 && result.keys.length === 0) ? result.total_keys : undefined,
|
||||
loaded: hasFilteredKeyRange.value ? undefined : loadedCount,
|
||||
total: result.total_keys > 0 || (result.cursor === 0 && result.keys.length === 0 && !hasFilteredKeyRange.value) ? result.total_keys : undefined,
|
||||
});
|
||||
|
||||
return newKeys.length;
|
||||
@@ -1103,10 +1126,10 @@ function bufferFetchAllScanResult(result: RedisScanResult, buffer: RedisKeyInfo[
|
||||
}
|
||||
scanCursor.value = result.cursor;
|
||||
hasMore.value = result.cursor !== 0;
|
||||
if (result.total_keys > 0 || (result.cursor === 0 && result.keys.length === 0)) lastTotalKeys.value = result.total_keys;
|
||||
if (result.total_keys > 0 || (result.cursor === 0 && result.keys.length === 0 && !hasFilteredKeyRange.value)) lastTotalKeys.value = result.total_keys;
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, {
|
||||
loaded: isSearchMode.value ? undefined : flatKeys.value.length + buffer.length,
|
||||
total: result.total_keys > 0 || (result.cursor === 0 && result.keys.length === 0) ? result.total_keys : undefined,
|
||||
loaded: hasFilteredKeyRange.value ? undefined : flatKeys.value.length + buffer.length,
|
||||
total: result.total_keys > 0 || (result.cursor === 0 && result.keys.length === 0 && !hasFilteredKeyRange.value) ? result.total_keys : undefined,
|
||||
});
|
||||
return added;
|
||||
}
|
||||
@@ -1157,11 +1180,11 @@ async function loadKeys() {
|
||||
// separately and checked once we're clear of it.
|
||||
let succeeded = false;
|
||||
try {
|
||||
if (isValueSearchMode.value && !valueQuery.value) {
|
||||
if (isValueSearchMode.value && !valueQuery.value && !hasDefaultKeyScope.value) {
|
||||
hasMore.value = false;
|
||||
return;
|
||||
}
|
||||
const initialScanBudget = isFuzzyKeySearch.value ? autoLoadBudget : undefined;
|
||||
const initialScanBudget = isKeyHierarchySearch.value ? autoLoadBudget : undefined;
|
||||
const applied = await scanNextPage(requestId, undefined, initialScanBudget);
|
||||
succeeded = applied;
|
||||
} finally {
|
||||
@@ -1392,7 +1415,7 @@ async function publishFetchAllVisibleRows(rows: readonly RedisKeyTreeRow[], requ
|
||||
async function fetchAll(): Promise<boolean> {
|
||||
if (!hasMore.value || isFetchingAll.value) return false;
|
||||
const requestId = searchRequestId;
|
||||
const fetchAllIsFullKeyspace = searchMode.value === "key" && !isSearchMode.value;
|
||||
const fetchAllCoversScope = searchMode.value === "key" && !isSearchMode.value;
|
||||
const bufferedKeys: RedisKeyInfo[] = [];
|
||||
const bufferedKeyRaws = new Set<string>();
|
||||
const initialFlatKeys = flatKeys.value;
|
||||
@@ -1408,7 +1431,7 @@ async function fetchAll(): Promise<boolean> {
|
||||
db: props.db,
|
||||
separator: redisKeySeparator.value,
|
||||
flatRows: useFlatKeySearchRows.value,
|
||||
expandAll: isSearchMode.value,
|
||||
expandAll: false,
|
||||
expandedGroupIds: expandedGroupIds.value,
|
||||
noExpiryOnly: noExpiryOnly.value,
|
||||
};
|
||||
@@ -1447,8 +1470,8 @@ async function fetchAll(): Promise<boolean> {
|
||||
let published = !changed && !fetchAllStopRequested.value;
|
||||
try {
|
||||
if (changed) {
|
||||
snapshotConfig.flatRows = customGrouping.value.enabled || (searchMode.value === "key" && isSearchMode.value && !fuzzyKeySearch.value) || (isFuzzyKeySearch.value && !canBuildRedisFuzzyTree(initialFlatKeys.length + bufferedKeys.length));
|
||||
snapshotConfig.expandAll = isSearchMode.value;
|
||||
snapshotConfig.flatRows = customGrouping.value.enabled || useFlatSearchResults(initialFlatKeys.length + bufferedKeys.length);
|
||||
snapshotConfig.expandAll = false;
|
||||
snapshotConfig.expandedGroupIds = expandedGroupIds.value;
|
||||
snapshotConfig.noExpiryOnly = noExpiryOnly.value;
|
||||
activateFetchAllVisibleRows();
|
||||
@@ -1470,7 +1493,7 @@ async function fetchAll(): Promise<boolean> {
|
||||
} finally {
|
||||
publicationSucceeded = published;
|
||||
if (published) {
|
||||
fetchAllSnapshotComplete.value = fetchAllIsFullKeyspace;
|
||||
fetchAllSnapshotComplete.value = completed && fetchAllCoversScope;
|
||||
fetchAllPublicationRollback = null;
|
||||
if (!hasMore.value) refreshExpandedGroupIds.clear();
|
||||
}
|
||||
@@ -1486,7 +1509,7 @@ async function fetchAll(): Promise<boolean> {
|
||||
positiveTtlKeyRaws.delete(keyRaw);
|
||||
}
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, {
|
||||
loaded: isSearchMode.value ? undefined : initialFlatKeys.length,
|
||||
loaded: hasFilteredKeyRange.value ? undefined : initialFlatKeys.length,
|
||||
total: initialLastTotalKeys,
|
||||
});
|
||||
}
|
||||
@@ -1520,7 +1543,7 @@ const SUBTREE_FILL_MAX_NEW_KEYS = 500;
|
||||
const SUBTREE_FILL_MAX_SCAN_ITERATIONS = 50;
|
||||
|
||||
function shouldFillGroupSubtree(): boolean {
|
||||
return hasMore.value && !useFlatKeySearchRows.value && !isSearchMode.value && !isFetchingAll.value;
|
||||
return hasMore.value && !useFlatKeySearchRows.value && !hasFilteredKeyRange.value && !isFetchingAll.value;
|
||||
}
|
||||
|
||||
function mergeScannedKeys(newKeys: RedisKeyInfo[]) {
|
||||
@@ -1529,11 +1552,12 @@ function mergeScannedKeys(newKeys: RedisKeyInfo[]) {
|
||||
appendFlatKeyRecords(newKeys);
|
||||
mergeTree(newKeys);
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, {
|
||||
loaded: isSearchMode.value ? undefined : flatKeys.value.length,
|
||||
loaded: hasFilteredKeyRange.value ? undefined : flatKeys.value.length,
|
||||
});
|
||||
}
|
||||
|
||||
async function fillGroupSubtree(group: RedisKeyTreeGroupNode, requestId = searchRequestId) {
|
||||
if (hasDefaultKeyScope.value) return;
|
||||
if (subtreeFilledGroupIds.has(group.id)) return;
|
||||
if (subtreeFillOperations.has(group.id)) return;
|
||||
const operationId = ++subtreeFillOperationId;
|
||||
@@ -1646,6 +1670,7 @@ function onRowClick(node: RedisKeyTreeNode, event?: MouseEvent) {
|
||||
|
||||
function removeKnownKey(keyRaw: string) {
|
||||
if (!flatKeyByRaw.has(keyRaw)) return;
|
||||
const reloadSearch = localKeySearchActive.value;
|
||||
invalidateFetchAllForStructuralMutation();
|
||||
loadedKeyRaws.delete(keyRaw);
|
||||
ttlObservedAtByRaw.delete(keyRaw);
|
||||
@@ -1657,12 +1682,18 @@ function removeKnownKey(keyRaw: string) {
|
||||
treeIndex = null;
|
||||
refreshSelectedGroupLeafCounts();
|
||||
} else {
|
||||
rebuildTree(false);
|
||||
rebuildTree();
|
||||
}
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, {
|
||||
loaded: isSearchMode.value ? undefined : flatKeys.value.length,
|
||||
loaded: hasFilteredKeyRange.value ? undefined : flatKeys.value.length,
|
||||
totalDelta: -1,
|
||||
});
|
||||
// The remaining records still cover the old complete scope. Once that cache
|
||||
// is invalidated, reload the active query instead of displaying every record.
|
||||
if (reloadSearch) {
|
||||
if (redisBrowserIsActive) void loadKeys();
|
||||
else reloadKeysOnActivation = true;
|
||||
}
|
||||
}
|
||||
|
||||
function onKeyDeleted(keyRaw: string) {
|
||||
@@ -1671,15 +1702,17 @@ function onKeyDeleted(keyRaw: string) {
|
||||
|
||||
function onKeyRenamed(oldKeyRaw: string, newKeyRaw: string, newKeyDisplay: string) {
|
||||
connectionStore.invalidateCompletionCache(props.connectionId, String(props.db));
|
||||
if (isSearchMode.value) {
|
||||
void loadKeys();
|
||||
if (hasFilteredKeyRange.value) {
|
||||
if (redisBrowserIsActive) void loadKeys();
|
||||
else reloadKeysOnActivation = true;
|
||||
return;
|
||||
}
|
||||
|
||||
invalidateFetchAllForStructuralMutation();
|
||||
const previous = flatKeyByRaw.get(oldKeyRaw);
|
||||
if (!previous) {
|
||||
void loadKeys();
|
||||
if (redisBrowserIsActive) void loadKeys();
|
||||
else reloadKeysOnActivation = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1703,7 +1736,7 @@ function onKeyRenamed(oldKeyRaw: string, newKeyRaw: string, newKeyDisplay: strin
|
||||
treeIndex = null;
|
||||
refreshSelectedGroupLeafCounts();
|
||||
} else {
|
||||
rebuildTree(false);
|
||||
rebuildTree();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1748,14 +1781,14 @@ function requestBatchDelete() {
|
||||
kind: "delete-keys",
|
||||
title: t("redis.selectedKeys"),
|
||||
keyRaws: [...checkedKeys.value],
|
||||
loadedSearchResults: isFuzzyKeySearch.value,
|
||||
loadedSearchResults: hasFilteredKeyRange.value,
|
||||
};
|
||||
showDangerConfirm.value = true;
|
||||
}
|
||||
|
||||
function requestGroupDelete(node: RedisKeyTreeNode, event?: Event) {
|
||||
event?.stopPropagation();
|
||||
if (node.kind !== "group" || selectionBusy.value) return;
|
||||
if (node.kind !== "group" || selectionBusy.value || !canDeleteWholeGroup.value) return;
|
||||
// 一个分组是键名前缀:树里只持有已扫描到的那部分子键,按已加载行删除会
|
||||
// 留下一部分键(#10164)。这里改为删除该前缀下的全部键。
|
||||
const pattern = redisGroupSubtreePattern(node.pathSegments, redisKeySeparator.value);
|
||||
@@ -1805,9 +1838,9 @@ function redisKeyContextMenuItems(node: RedisKeyTreeNode): ContextMenuItem[] {
|
||||
action: () => copyRedisKeyName(groupPath),
|
||||
},
|
||||
];
|
||||
// Fuzzy hierarchy represents only the loaded matching subset. Keep its
|
||||
// A filtered hierarchy represents only the loaded matching subset. Keep its
|
||||
// destructive actions hidden, matching the inline group-delete button.
|
||||
if (!isFuzzyHierarchyView.value) {
|
||||
if (canDeleteWholeGroup.value) {
|
||||
items.push({
|
||||
label: t("redis.deleteGroupKeys"),
|
||||
icon: Trash2,
|
||||
@@ -1836,6 +1869,7 @@ function onRedisRowContextMenu(event: MouseEvent, node: RedisKeyTreeNode, openCo
|
||||
}
|
||||
|
||||
function resetLoadedKeys() {
|
||||
legacyExpandedBeforeGrouping = new Set();
|
||||
invalidateScanRequests();
|
||||
fetchAllSnapshotComplete.value = false;
|
||||
isFetchingAll.value = false;
|
||||
@@ -1856,7 +1890,7 @@ function resetLoadedKeys() {
|
||||
}
|
||||
|
||||
async function deleteGroupSubtree(pattern: string, groupId: string) {
|
||||
if (deletingKeys.value) return;
|
||||
if (deletingKeys.value || !canDeleteWholeGroup.value) return;
|
||||
|
||||
// Ignore a late SCAN page while an explicit mutation changes this result set.
|
||||
invalidateScanRequests();
|
||||
@@ -1881,9 +1915,9 @@ async function deleteGroupSubtree(pattern: string, groupId: string) {
|
||||
// 该子树已被整段删除,旧的补扫游标/已扫尽标记对新键不再成立
|
||||
subtreePendingGroupCursors.delete(groupId);
|
||||
subtreeFilledGroupIds.delete(groupId);
|
||||
rebuildTree(false);
|
||||
rebuildTree();
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, {
|
||||
loaded: isSearchMode.value ? undefined : flatKeys.value.length,
|
||||
loaded: hasFilteredKeyRange.value ? undefined : flatKeys.value.length,
|
||||
totalDelta: -deletedCount,
|
||||
});
|
||||
toast(t("redis.deleteGroupSubtreeSuccess", { count: deletedCount }), 3000);
|
||||
@@ -1927,10 +1961,10 @@ async function deleteKeyRaws(keys: string[]) {
|
||||
treeKeys.value = [];
|
||||
treeIndex = null;
|
||||
} else {
|
||||
rebuildTree(false);
|
||||
rebuildTree();
|
||||
}
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, {
|
||||
loaded: isSearchMode.value ? undefined : flatKeys.value.length,
|
||||
loaded: hasFilteredKeyRange.value ? undefined : flatKeys.value.length,
|
||||
totalDelta: -deletedCount,
|
||||
});
|
||||
} catch (error) {
|
||||
@@ -2253,8 +2287,21 @@ function upsertCreatedKey(value: RedisValue) {
|
||||
size: redisValueSize(value),
|
||||
value_preview: redisValuePreview(value),
|
||||
};
|
||||
invalidateFetchAllForStructuralMutation();
|
||||
const existing = flatKeyByRaw.get(keyInfo.key_raw);
|
||||
if (!matchesDefaultKeyScope(keyInfo)) {
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, { totalDelta: existing ? 0 : 1 });
|
||||
return;
|
||||
}
|
||||
// 范围外的写入不影响已加载的范围快照及其本地搜索。
|
||||
invalidateFetchAllForStructuralMutation();
|
||||
// A created/updated key may not match the active key or value query. Use the
|
||||
// normal scoped search path rather than inserting it into filtered results.
|
||||
if (isSearchMode.value) {
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, { totalDelta: existing ? 0 : 1 });
|
||||
if (redisBrowserIsActive) void loadKeys();
|
||||
else reloadKeysOnActivation = true;
|
||||
return;
|
||||
}
|
||||
// 新建 key 携带的 TTL 以当前时刻为观测起点
|
||||
recordKeyTtlObservedAt(keyInfo);
|
||||
if (existing) {
|
||||
@@ -2264,9 +2311,9 @@ function upsertCreatedKey(value: RedisValue) {
|
||||
}
|
||||
loadedKeyRaws.add(keyInfo.key_raw);
|
||||
selectedKeyRaw.value = keyInfo.key_raw;
|
||||
rebuildTree(isSearchMode.value);
|
||||
rebuildTree();
|
||||
connectionStore.updateRedisDbKeyStats(props.connectionId, props.db, {
|
||||
loaded: isSearchMode.value ? undefined : flatKeys.value.length,
|
||||
loaded: hasFilteredKeyRange.value ? undefined : flatKeys.value.length,
|
||||
totalDelta: existing ? 0 : 1,
|
||||
});
|
||||
}
|
||||
@@ -3173,7 +3220,14 @@ onUnmounted(() => {
|
||||
|
||||
watch(
|
||||
() => [props.connectionId, props.db] as const,
|
||||
async ([connectionId, db]) => {
|
||||
async ([connectionId, db], [previousConnectionId]) => {
|
||||
if (connectionId !== previousConnectionId) {
|
||||
defaultKeyFilter.value = connectionStore.getConfig(connectionId)?.redis_key_filter?.trim() ?? "";
|
||||
searchPattern.value = "";
|
||||
searchMode.value = "key";
|
||||
fuzzyKeySearch.value = false;
|
||||
noExpiryOnly.value = false;
|
||||
}
|
||||
// ContentArea remounts this browser for scope changes; keep embedded uses
|
||||
// in sync as well so an old scan cannot populate the new scope.
|
||||
commandDb.value = db;
|
||||
@@ -3226,7 +3280,7 @@ async function prepareLegacyGroupingView() {
|
||||
{
|
||||
db,
|
||||
separator: redisKeySeparator.value,
|
||||
flatRows: (searchMode.value === "key" && isSearchMode.value && !fuzzyKeySearch.value) || fuzzyTreeLimitReached.value,
|
||||
flatRows: useFlatSearchResults(keys.length),
|
||||
expandAll: false,
|
||||
expandedGroupIds: legacyExpandedBeforeGrouping,
|
||||
noExpiryOnly: noExpiryOnly.value,
|
||||
@@ -3295,7 +3349,7 @@ watch(
|
||||
legacyGroupingPublishing = false;
|
||||
if (!legacyGroupingPreparing.value) legacyExpandedBeforeGrouping = expandedGroupIds.value;
|
||||
legacyGroupingPreparing.value = false;
|
||||
rebuildTree(false);
|
||||
rebuildTree();
|
||||
} else if (previous) {
|
||||
void prepareLegacyGroupingView();
|
||||
}
|
||||
@@ -3498,7 +3552,7 @@ defineExpose({ focusSearch, insertCommand, executeCommand: executeAiCommand });
|
||||
:checked="checkedKeys"
|
||||
:busy="selectionBusy"
|
||||
:metadata-epoch="keyMetadataEpoch"
|
||||
:tree-allowed="!fuzzyTreeLimitReached"
|
||||
:tree-allowed="!searchTreeLimitReached"
|
||||
@request-list="saveGrouping({ ...customGrouping, inner_view: 'list' })"
|
||||
@scroll="onRedisKeyScroll"
|
||||
@resize="maybeAutoLoadMoreRedisKeys"
|
||||
@@ -3558,8 +3612,8 @@ defineExpose({ focusSearch, insertCommand, executeCommand: executeAiCommand });
|
||||
<component :is="expandedGroupIds.has(row.node.id) ? ChevronDown : ChevronRight" class="w-3 h-3 shrink-0 text-muted-foreground" />
|
||||
<component :is="expandedGroupIds.has(row.node.id) ? FolderOpen : FolderClosed" class="h-3.5 w-3.5 shrink-0 text-amber-500" />
|
||||
<span class="dbx-editor-font-family truncate">{{ row.node.label }}</span>
|
||||
<span class="text-muted-foreground ml-1" :title="isFuzzyHierarchyView ? t('redis.loadedMatchingKeys', { count: row.node.loadedLeafCount }) : hasMore ? t('redis.loadedGroupKeysPartial', { count: row.node.loadedLeafCount }) : undefined"
|
||||
>({{ row.node.loadedLeafCount }}{{ !isFuzzyHierarchyView && hasMore ? "+" : "" }})</span
|
||||
<span class="text-muted-foreground ml-1" :title="isFilteredHierarchyView ? t('redis.loadedMatchingKeys', { count: row.node.loadedLeafCount }) : hasMore ? t('redis.loadedGroupKeysPartial', { count: row.node.loadedLeafCount }) : undefined"
|
||||
>({{ row.node.loadedLeafCount }}{{ !isFilteredHierarchyView && hasMore ? "+" : "" }})</span
|
||||
>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -3588,7 +3642,7 @@ defineExpose({ focusSearch, insertCommand, executeCommand: executeAiCommand });
|
||||
:title="redisRowTtl(row.node) === -1 ? t('redis.noExpiry') : t('redis.ttlCountdownTitle')"
|
||||
>{{ redisTtlBadgeText(redisRowTtl(row.node), redisRowDisplayTtl(redisRowTtl(row.node), row.node.keyRaw)) }}</span
|
||||
>
|
||||
<Button v-if="row.node.kind === 'group' && !isFuzzyHierarchyView" variant="ghost" size="icon" class="h-5 w-5 shrink-0 text-destructive opacity-0 group-hover:opacity-100" :title="t('redis.deleteGroup')" :disabled="selectionBusy" @click="requestGroupDelete(row.node, $event)">
|
||||
<Button v-if="row.node.kind === 'group' && canDeleteWholeGroup" variant="ghost" size="icon" class="h-5 w-5 shrink-0 text-destructive opacity-0 group-hover:opacity-100" :title="t('redis.deleteGroup')" :disabled="selectionBusy" @click="requestGroupDelete(row.node, $event)">
|
||||
<Trash2 class="h-3 w-3" />
|
||||
</Button>
|
||||
<Button
|
||||
@@ -3608,7 +3662,7 @@ defineExpose({ focusSearch, insertCommand, executeCommand: executeAiCommand });
|
||||
</CustomContextMenu>
|
||||
</template>
|
||||
</RecycleScroller>
|
||||
<div v-if="fuzzyTreeLimitReached && !showCustomGrouping" class="shrink-0 border-t px-3 py-2 text-center text-xs text-muted-foreground">
|
||||
<div v-if="searchTreeLimitReached && !showCustomGrouping" class="shrink-0 border-t px-3 py-2 text-center text-xs text-muted-foreground">
|
||||
{{ t("redis.fuzzyTreeLimit", { count: flatKeys.length }) }}
|
||||
</div>
|
||||
<div v-if="hasMore && !isFetchingAll" class="shrink-0 border-t px-2 py-1.5 flex items-center gap-1.5">
|
||||
|
||||
@@ -807,6 +807,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "Sentinel parolu",
|
||||
redisSentinelTls: "Sentinel TLS",
|
||||
redisSentinelTlsHint: "Sentinel qovşaqları ilə əlaqə qurarkən TLS-dən istifadə et",
|
||||
redisKeyFilter: "Standart açar filtri",
|
||||
redisKeyFilterHint: "Redis glob şablonu, məsələn, order:*. Bütün açarları göstərmək üçün boş saxlayın. Yeni vərəqlər axtarış xanasını doldurmadan bu əhatə dairəsindən istifadə edir; axtarışlar bu dairədə aparılır. Mövcud vərəqlər öz əhatə dairəsini saxlayır.",
|
||||
redisKeySeparator: "Açar ad fəzasının ayırıcısı",
|
||||
redisKeyTemplates: "Açar axtarış şablonları",
|
||||
redisKeyTemplatesPlaceholder: "Nümunə:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -5333,7 +5335,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "Bu qovluqdakı {count} yüklənmiş açarı seç",
|
||||
loadedMatchingKeys: "{count} yüklənmiş uyğun açar",
|
||||
loadedGroupKeysPartial: "İndiyədək {count} açar yüklənib — bu qovluqda daha çox açar ola bilər",
|
||||
fuzzyTreeLimit: "Baxış pəncərəsinin çevik işləməsi üçün {count} təxmini uyğunluq düz siyahı kimi göstərilir. İyerarxiyaya baxmaq üçün axtarışı dəqiqləşdirin.",
|
||||
fuzzyTreeLimit: "{count} uyğun açar baxış pəncərəsinin çevik işləməsi üçün düz siyahı kimi göstərilir. İyerarxiyaya baxmaq üçün axtarışı daraldın.",
|
||||
deleteGroup: "Qrupu sil",
|
||||
deleteKey: "Açarı sil",
|
||||
deleteGroupDetails: "{target}\n{count} açar",
|
||||
|
||||
@@ -1121,6 +1121,8 @@ export default {
|
||||
redisSentinelPassword: "Sentinel Password",
|
||||
redisSentinelTls: "Sentinel TLS",
|
||||
redisSentinelTlsHint: "Use TLS when connecting to Sentinel nodes",
|
||||
redisKeyFilter: "Default Key filter",
|
||||
redisKeyFilterHint: "Redis glob pattern, e.g. order:*. Leave blank to show all keys. New tabs use this as their browsing scope without filling the search box; searches stay within this scope. Existing tabs keep their scope.",
|
||||
redisKeySeparator: "Key Namespace Separator",
|
||||
redisKeyTemplates: "Key search templates",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -6170,7 +6172,7 @@ export default {
|
||||
selectLoadedGroupKeys: "Select {count} loaded keys in this folder",
|
||||
loadedMatchingKeys: "{count} loaded matching keys",
|
||||
loadedGroupKeysPartial: "{count} keys loaded so far — this folder may contain more",
|
||||
fuzzyTreeLimit: "{count} fuzzy matches are shown as a flat list to keep the browser responsive. Refine the search to view the hierarchy.",
|
||||
fuzzyTreeLimit: "{count} matching keys are shown as a flat list to keep the browser responsive. Refine the search to view the hierarchy.",
|
||||
deleteGroup: "Delete group",
|
||||
deleteKey: "Delete key",
|
||||
deleteGroupDetails: "{target}\n{count} keys",
|
||||
|
||||
@@ -1093,6 +1093,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "Contraseña Sentinel",
|
||||
redisSentinelTls: "TLS Sentinel",
|
||||
redisSentinelTlsHint: "Usar TLS al conectar con nodos Sentinel",
|
||||
redisKeyFilter: "Filtro de claves predeterminado",
|
||||
redisKeyFilterHint: "Patrón glob de Redis, por ejemplo, order:*. Déjalo vacío para mostrar todas las claves. Las pestañas nuevas usan este ámbito sin rellenar el buscador; las búsquedas se limitan a él. Las pestañas existentes conservan su ámbito.",
|
||||
redisKeySeparator: "Separador de espacio de nombres de clave",
|
||||
redisKeyTemplates: "Plantillas de búsqueda de claves",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -5624,7 +5626,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "Seleccionar {count} claves coincidentes cargadas",
|
||||
loadedMatchingKeys: "{count} claves coincidentes cargadas",
|
||||
loadedGroupKeysPartial: "{count} claves cargadas hasta ahora — esta carpeta puede contener más",
|
||||
fuzzyTreeLimit: "Se muestran {count} coincidencias difusas como lista plana para mantener el navegador responsivo. Refina la búsqueda para ver la jerarquía.",
|
||||
fuzzyTreeLimit: "Se muestran {count} claves coincidentes como lista plana para mantener el navegador responsivo. Refina la búsqueda para ver la jerarquía.",
|
||||
deleteGroup: "Eliminar grupo",
|
||||
deleteKey: "Eliminar clave",
|
||||
deleteGroupDetails: "{target}\n{count} claves",
|
||||
|
||||
@@ -1037,6 +1037,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "Kata Sandi Sentinel",
|
||||
redisSentinelTls: "TLS Sentinel",
|
||||
redisSentinelTlsHint: "Gunakan TLS saat menghubungkan ke node Sentinel",
|
||||
redisKeyFilter: "Filter key default",
|
||||
redisKeyFilterHint: "Pola glob Redis, misalnya order:*. Kosongkan untuk menampilkan semua key. Tab baru menggunakan cakupan ini tanpa mengisi kotak pencarian; pencarian tetap di dalam cakupan ini. Tab yang sudah terbuka mempertahankan cakupannya.",
|
||||
redisKeySeparator: "Pemisah Namespace Key",
|
||||
redisKeyTemplates: "Template pencarian key",
|
||||
redisKeyTemplatesPlaceholder: "Contoh:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -5985,7 +5987,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "Pilih {count} key yang dimuat dalam folder ini",
|
||||
loadedMatchingKeys: "{count} key cocok yang dimuat",
|
||||
loadedGroupKeysPartial: "{count} key dimuat sejauh ini — folder ini mungkin berisi lebih banyak",
|
||||
fuzzyTreeLimit: "{count} kecocokan fuzzy ditampilkan sebagai daftar datar agar browser tetap responsif. Perhalus pencarian untuk melihat hierarkinya.",
|
||||
fuzzyTreeLimit: "{count} key yang cocok ditampilkan sebagai daftar datar agar browser tetap responsif. Persempit pencarian untuk melihat hierarkinya.",
|
||||
deleteGroup: "Hapus group",
|
||||
deleteKey: "Hapus key",
|
||||
deleteGroupDetails: "{target}\n{count} key",
|
||||
|
||||
@@ -1016,6 +1016,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "Password Sentinel",
|
||||
redisSentinelTls: "TLS Sentinel",
|
||||
redisSentinelTlsHint: "Usa TLS quando ti connetti ai nodi Sentinel",
|
||||
redisKeyFilter: "Filtro predefinito delle chiavi",
|
||||
redisKeyFilterHint: "Pattern glob di Redis, ad esempio order:*. Lascia vuoto per mostrare tutte le chiavi. Le nuove schede usano questo ambito senza compilare il campo di ricerca; le ricerche restano al suo interno. Le schede esistenti mantengono il proprio ambito.",
|
||||
redisKeySeparator: "Separatore namespace chiavi",
|
||||
redisKeyTemplates: "Modelli di ricerca chiavi",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -5437,7 +5439,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "Seleziona {count} chiavi corrispondenti caricate",
|
||||
loadedMatchingKeys: "{count} chiavi corrispondenti caricate",
|
||||
loadedGroupKeysPartial: "{count} chiavi caricate finora — questa cartella potrebbe contenerne altre",
|
||||
fuzzyTreeLimit: "{count} corrispondenze fuzzy sono mostrate come elenco piatto per mantenere il browser reattivo. Restringi la ricerca per vedere la gerarchia.",
|
||||
fuzzyTreeLimit: "{count} chiavi corrispondenti sono mostrate come elenco piatto per mantenere il browser reattivo. Restringi la ricerca per vedere la gerarchia.",
|
||||
deleteGroup: "Elimina gruppo",
|
||||
deleteKey: "Elimina chiave",
|
||||
deleteGroupDetails: "{target}\n{count} chiavi",
|
||||
|
||||
@@ -1016,6 +1016,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "センチネルパスワード",
|
||||
redisSentinelTls: "センチネルTLS",
|
||||
redisSentinelTlsHint: "センチネルノード接続時にTLSを使用する",
|
||||
redisKeyFilter: "デフォルトのキーフィルター",
|
||||
redisKeyFilterHint: "Redis の glob パターン(例:order:*)。空欄の場合はすべてのキーを表示します。新しいタブでは検索欄を空のまま、この範囲内を表示・検索します。既存のタブの範囲は変わりません。",
|
||||
redisKeySeparator: "キー名前空間セパレーター",
|
||||
redisKeyTemplates: "キー検索テンプレート",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -5465,7 +5467,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "読み込み済みの一致キー {count} 件を選択",
|
||||
loadedMatchingKeys: "読み込み済みの一致キー {count} 件",
|
||||
loadedGroupKeysPartial: "これまでに読み込まれたキー {count} 件 — このフォルダーにはさらにキーが存在する可能性があります",
|
||||
fuzzyTreeLimit: "ブラウザーの応答性を保つため、あいまい一致 {count} 件をフラットな一覧で表示しています。階層を表示するには検索条件を絞り込んでください。",
|
||||
fuzzyTreeLimit: "ブラウザーの応答性を保つため、一致するキー {count} 件をフラットな一覧で表示しています。階層を表示するには検索条件を絞り込んでください。",
|
||||
deleteGroup: "グループを削除",
|
||||
deleteKey: "キーを削除",
|
||||
deleteGroupDetails: "{target}\n{count}個のキー",
|
||||
|
||||
@@ -1051,6 +1051,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "센티널 비밀번호",
|
||||
redisSentinelTls: "센티널 TLS",
|
||||
redisSentinelTlsHint: "센티널 노드에 연결할 때 TLS 사용",
|
||||
redisKeyFilter: "기본 키 필터",
|
||||
redisKeyFilterHint: "Redis glob 패턴(예: order:*)입니다. 비워 두면 모든 키가 표시됩니다. 새 탭은 검색창을 채우지 않고 이 범위에서 탐색하며, 검색도 이 범위 안에서 수행됩니다. 기존 탭의 범위는 유지됩니다.",
|
||||
redisKeySeparator: "키 네임스페이스 구분자",
|
||||
redisKeyTemplates: "키 검색 템플릿",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -5151,7 +5153,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "로드된 {count}개 일치 키 선택",
|
||||
loadedMatchingKeys: "로드된 일치 키 {count}개",
|
||||
loadedGroupKeysPartial: "지금까지 로드된 {count}개 키 — 이 폴더에 더 많은 키가 있을 수 있습니다",
|
||||
fuzzyTreeLimit: "{count}개의 퍼지 일치가 브라우저 응답성을 유지하기 위해 평면 목록으로 표시됩니다. 계층 구조를 보려면 검색을 좁히세요.",
|
||||
fuzzyTreeLimit: "브라우저 응답성을 유지하기 위해 일치하는 키 {count}개를 평면 목록으로 표시합니다. 계층 구조를 보려면 검색 범위를 좁히세요.",
|
||||
deleteGroup: "그룹 삭제",
|
||||
deleteKey: "키 삭제",
|
||||
deleteGroupDetails: "{target}\n키 {count}개",
|
||||
|
||||
@@ -1017,6 +1017,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "Senha do Sentinel",
|
||||
redisSentinelTls: "TLS do Sentinel",
|
||||
redisSentinelTlsHint: "Usar TLS ao conectar aos nós Sentinel",
|
||||
redisKeyFilter: "Filtro padrão de chaves",
|
||||
redisKeyFilterHint: "Padrão glob do Redis, por exemplo, order:*. Deixe em branco para mostrar todas as chaves. Novas abas usam esse escopo sem preencher a caixa de pesquisa; as pesquisas ficam dentro dele. Abas existentes mantêm seu escopo.",
|
||||
redisKeySeparator: "Separador de namespace de chave",
|
||||
redisKeyTemplates: "Modelos de busca de chave",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -5439,7 +5441,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "Selecionar {count} chaves correspondentes carregadas",
|
||||
loadedMatchingKeys: "{count} chaves correspondentes carregadas",
|
||||
loadedGroupKeysPartial: "{count} chaves carregadas até agora — esta pasta pode conter mais",
|
||||
fuzzyTreeLimit: "{count} correspondências difusas são mostradas como uma lista plana para manter o navegador responsivo. Refine a busca para ver a hierarquia.",
|
||||
fuzzyTreeLimit: "{count} chaves correspondentes são mostradas como uma lista plana para manter o navegador responsivo. Refine a busca para ver a hierarquia.",
|
||||
deleteGroup: "Excluir grupo",
|
||||
deleteKey: "Excluir chave",
|
||||
deleteGroupDetails: "{target}\n{count} chaves",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const redisGroupingEn = {
|
||||
preparingLegacy: "Preparing the previous view; custom groups remain available…",
|
||||
fuzzyTreeUnavailable: "This fuzzy search exceeds the existing tree resource limit. Choose List to browse the loaded matches, or narrow the search to use Tree.",
|
||||
fuzzyTreeUnavailable: "This search exceeds the existing tree resource limit. Choose List to browse the loaded matches, or narrow the search to use Tree.",
|
||||
useList: "Use List",
|
||||
settings: "Grouping rules",
|
||||
toggle: "Custom groups",
|
||||
@@ -28,7 +28,7 @@ export const redisGroupingEn = {
|
||||
};
|
||||
export const redisGroupingZhCN = {
|
||||
preparingLegacy: "正在准备原有视图,期间仍可浏览自定义分组…",
|
||||
fuzzyTreeUnavailable: "当前模糊搜索超过已有树视图资源限制。请选择列表浏览已加载匹配项,或缩小搜索范围后使用前缀树。",
|
||||
fuzzyTreeUnavailable: "当前搜索超过已有树视图资源限制。请选择列表浏览已加载匹配项,或缩小搜索范围后使用前缀树。",
|
||||
useList: "使用列表",
|
||||
settings: "分组规则",
|
||||
toggle: "自定义分组",
|
||||
@@ -56,7 +56,7 @@ export const redisGroupingZhCN = {
|
||||
};
|
||||
export const redisGroupingZhTW = {
|
||||
preparingLegacy: "正在準備原有檢視,期間仍可瀏覽自訂分組…",
|
||||
fuzzyTreeUnavailable: "目前模糊搜尋超過既有樹狀檢視資源限制。請選擇列表瀏覽已載入匹配項,或縮小搜尋範圍後使用前綴樹。",
|
||||
fuzzyTreeUnavailable: "目前搜尋超過既有樹狀檢視資源限制。請選擇列表瀏覽已載入匹配項,或縮小搜尋範圍後使用前綴樹。",
|
||||
useList: "使用列表",
|
||||
settings: "分組規則",
|
||||
toggle: "自訂分組",
|
||||
@@ -85,7 +85,7 @@ export const redisGroupingZhTW = {
|
||||
|
||||
export const redisGroupingEs = {
|
||||
preparingLegacy: "Preparando la vista anterior; los grupos personalizados siguen disponibles…",
|
||||
fuzzyTreeUnavailable: "Esta búsqueda difusa supera el límite de recursos de la vista de árbol existente. Elige Lista para explorar las coincidencias cargadas o acota la búsqueda para usar Árbol.",
|
||||
fuzzyTreeUnavailable: "Esta búsqueda supera el límite de recursos de la vista de árbol existente. Elige Lista para explorar las coincidencias cargadas o acota la búsqueda para usar Árbol.",
|
||||
useList: "Usar lista",
|
||||
settings: "Reglas de agrupación",
|
||||
toggle: "Grupos personalizados",
|
||||
|
||||
@@ -75,7 +75,7 @@ export default withEnglishFallback({
|
||||
},
|
||||
redisGrouping: {
|
||||
preparingLegacy: "Подготовка предыдущего представления; пользовательские группы остаются доступными…",
|
||||
fuzzyTreeUnavailable: "Этот нечёткий поиск превышает лимит ресурсов существующего дерева. Выберите список для просмотра загруженных совпадений или уточните поиск, чтобы использовать дерево.",
|
||||
fuzzyTreeUnavailable: "Этот поиск превышает лимит ресурсов существующего дерева. Выберите список для просмотра загруженных совпадений или уточните поиск, чтобы использовать дерево.",
|
||||
useList: "Использовать список",
|
||||
settings: "Правила группировки",
|
||||
toggle: "Пользовательские группы",
|
||||
@@ -1032,6 +1032,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "Пароль Sentinel",
|
||||
redisSentinelTls: "TLS Sentinel",
|
||||
redisSentinelTlsHint: "Использовать TLS при подключении к узлам Sentinel",
|
||||
redisKeyFilter: "Фильтр ключей по умолчанию",
|
||||
redisKeyFilterHint: "Шаблон glob Redis, например order:*. Оставьте пустым, чтобы показать все ключи. Новые вкладки используют эту область без заполнения строки поиска; поиск выполняется только в ней. Область существующих вкладок не меняется.",
|
||||
redisKeySeparator: "Разделитель пространства имён ключей",
|
||||
redisKeyTemplates: "Шаблоны поиска ключей",
|
||||
redisKeyTemplatesPlaceholder: "Example:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -6476,7 +6478,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "Выбрать {count} загруженных ключей в этой папке",
|
||||
loadedMatchingKeys: "{count} загруженных совпадающих ключей",
|
||||
loadedGroupKeysPartial: "Пока загружено {count} ключей — в этой папке может быть больше",
|
||||
fuzzyTreeLimit: "{count} нечётких совпадений показаны плоским списком, чтобы браузер оставался отзывчивым. Уточните поиск, чтобы увидеть иерархию.",
|
||||
fuzzyTreeLimit: "{count} совпадающих ключей показаны плоским списком, чтобы браузер оставался отзывчивым. Уточните поиск, чтобы увидеть иерархию.",
|
||||
deleteGroup: "Удалить группу",
|
||||
deleteKey: "Удалить ключ",
|
||||
deleteGroupDetails: "{target}\n{count} ключей",
|
||||
|
||||
@@ -807,6 +807,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "Sentinel Parolası",
|
||||
redisSentinelTls: "Sentinel TLS",
|
||||
redisSentinelTlsHint: "Sentinel düğümlerine bağlanırken TLS kullan",
|
||||
redisKeyFilter: "Varsayılan anahtar filtresi",
|
||||
redisKeyFilterHint: "Redis glob deseni, örneğin order:*. Tüm anahtarları göstermek için boş bırakın. Yeni sekmeler arama kutusunu doldurmadan bu kapsamı kullanır; aramalar bu kapsam içinde yapılır. Mevcut sekmeler kapsamlarını korur.",
|
||||
redisKeySeparator: "Anahtar Ad Alanı Ayırıcısı",
|
||||
redisKeyTemplates: "Anahtar arama şablonları",
|
||||
redisKeyTemplatesPlaceholder: "Örnek:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -5227,7 +5229,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "Bu klasörde yüklenen {count} anahtarı seç",
|
||||
loadedMatchingKeys: "{count} yüklenmiş eşleşen anahtar",
|
||||
loadedGroupKeysPartial: "Şu ana kadar {count} anahtar yüklendi — bu klasörde daha fazlası olabilir",
|
||||
fuzzyTreeLimit: "Tarayıcının akıcı kalması için {count} bulanık eşleşme düz liste olarak gösteriliyor. Hiyerarşiyi görmek için aramayı daraltın.",
|
||||
fuzzyTreeLimit: "Tarayıcının akıcı kalması için eşleşen {count} anahtar düz liste olarak gösteriliyor. Hiyerarşiyi görmek için aramayı daraltın.",
|
||||
deleteGroup: "Grubu sil",
|
||||
deleteKey: "Anahtarı sil",
|
||||
deleteGroupDetails: "{target}\n{count} anahtar",
|
||||
|
||||
@@ -1057,6 +1057,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "哨兵密码",
|
||||
redisSentinelTls: "哨兵 TLS",
|
||||
redisSentinelTlsHint: "连接 Sentinel 节点时使用 TLS",
|
||||
redisKeyFilter: "默认 Key 过滤",
|
||||
redisKeyFilterHint: "使用 Redis glob 模式,例如 order:*;留空显示全部 Key。新标签页默认在此范围内浏览,搜索框保持空白,输入后仅在此范围内搜索。已有标签页保留原范围。",
|
||||
redisKeySeparator: "键名分隔符(可选)",
|
||||
redisKeyTemplates: "Key 搜索模板",
|
||||
redisKeyTemplatesPlaceholder: "例如:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -6162,7 +6164,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "选择该文件夹下已加载的 {count} 个 key",
|
||||
loadedMatchingKeys: "已加载的 {count} 个匹配 key",
|
||||
loadedGroupKeysPartial: "目前已加载 {count} 个 key —— 该文件夹下可能还有更多",
|
||||
fuzzyTreeLimit: "已加载 {count} 个模糊匹配 key。为保持浏览器响应,当前以扁平列表展示;请缩小搜索范围以查看层级。",
|
||||
fuzzyTreeLimit: "已加载 {count} 个匹配 key。为保持浏览器响应,当前以扁平列表展示;请缩小搜索范围以查看层级。",
|
||||
deleteGroup: "删除分组",
|
||||
deleteKey: "删除 key",
|
||||
deleteGroupDetails: "{target}\n{count} 个 key",
|
||||
|
||||
@@ -1021,6 +1021,8 @@ export default withEnglishFallback({
|
||||
redisSentinelPassword: "Sentinel 密碼",
|
||||
redisSentinelTls: "Sentinel TLS",
|
||||
redisSentinelTlsHint: "連線 Sentinel 節點時使用 TLS",
|
||||
redisKeyFilter: "預設 Key 過濾",
|
||||
redisKeyFilterHint: "使用 Redis glob 模式,例如 order:*;留空顯示全部 Key。新分頁預設在此範圍內瀏覽,搜尋框保持空白,輸入後僅在此範圍內搜尋。既有分頁保留原範圍。",
|
||||
redisKeySeparator: "鍵名分隔符(可選)",
|
||||
redisKeyTemplates: "Key 搜尋模板",
|
||||
redisKeyTemplatesPlaceholder: "例如:\nuser:{'{'}$userId{'}'}\nv3:adui:{'{'}$positionID{'}'}",
|
||||
@@ -4785,7 +4787,7 @@ export default withEnglishFallback({
|
||||
selectLoadedGroupKeys: "選取已載入的 {count} 個相符 key",
|
||||
loadedMatchingKeys: "已載入的 {count} 個相符 key",
|
||||
loadedGroupKeysPartial: "目前已載入 {count} 個 key —— 此資料夾下可能還有更多",
|
||||
fuzzyTreeLimit: "已載入 {count} 個模糊相符 key。為保持瀏覽器回應,目前以扁平清單顯示;請縮小搜尋範圍以查看層級。",
|
||||
fuzzyTreeLimit: "已載入 {count} 個相符 key。為保持瀏覽器回應,目前以扁平清單顯示;請縮小搜尋範圍以查看層級。",
|
||||
deleteGroup: "刪除群組",
|
||||
deleteKey: "刪除 key",
|
||||
deleteGroupDetails: "{target}\n{count} 個 key",
|
||||
|
||||
@@ -94,7 +94,7 @@ function fnv1a(value: string, seed: number): number {
|
||||
}
|
||||
|
||||
export function connectionConfigFingerprint(config: ConnectionConfig, sourceName = config.name): string {
|
||||
const { database_info: _databaseInfo, default_schema: _defaultSchema, note: _note, show_database_links: _showDatabaseLinks, sidebar_auto_load_all_tables: _sidebarAutoLoadAllTables, ...submittedConfig } = config;
|
||||
const { database_info: _databaseInfo, default_schema: _defaultSchema, note: _note, show_database_links: _showDatabaseLinks, sidebar_auto_load_all_tables: _sidebarAutoLoadAllTables, redis_key_filter: _redisKeyFilter, ...submittedConfig } = config;
|
||||
const serialized = JSON.stringify(stableValue({ config: submittedConfig, sourceName }));
|
||||
const first = fnv1a(serialized, 0x811c9dc5).toString(16).padStart(8, "0");
|
||||
const second = fnv1a(serialized, 0x9e3779b9).toString(16).padStart(8, "0");
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
export type RedisKeyBrowserSearchMode = "key" | "value" | "all";
|
||||
|
||||
export interface RedisKeyBrowserStateSnapshot {
|
||||
/** Key / value / all search input text. */
|
||||
/** Implicit key scope captured when this tab opened, independent of search input and later connection edits. */
|
||||
defaultKeyFilter?: string;
|
||||
/** User-entered Key / value / all search text; never prefilled from the connection scope. */
|
||||
searchPattern: string;
|
||||
/** Which Redis search mode the toolbar is in. */
|
||||
searchMode: RedisKeyBrowserSearchMode;
|
||||
|
||||
@@ -1735,6 +1735,7 @@ export const useConnectionStore = defineStore("connection", () => {
|
||||
idle_timeout_secs: config.idle_timeout_secs ?? 60,
|
||||
keepalive_interval_secs: config.keepalive_interval_secs ?? DEFAULT_KEEPALIVE_INTERVAL_SECS,
|
||||
redis_database_aliases: normalizeRedisDatabaseAliases(config.redis_database_aliases),
|
||||
redis_key_filter: dbType === "redis" && typeof config.redis_key_filter === "string" ? config.redis_key_filter.trim() || undefined : undefined,
|
||||
redis_key_templates: (() => {
|
||||
const templates = normalizeRedisKeyTemplates(config.redis_key_templates);
|
||||
return templates.length > 0 ? templates : undefined;
|
||||
|
||||
@@ -157,6 +157,8 @@ export interface ConnectionConfig {
|
||||
redis_database_aliases?: Record<string, string>;
|
||||
/** Key-search templates for the Redis browser. Non-empty overrides global settings. */
|
||||
redis_key_templates?: string[];
|
||||
/** Default Redis glob pattern applied when opening a new key-browser tab. */
|
||||
redis_key_filter?: string;
|
||||
redis_key_grouping?: import("@/lib/redis/redisKeyGrouping").RedisKeyGrouping;
|
||||
etcd_endpoints?: string;
|
||||
gbase_server?: string;
|
||||
|
||||
Reference in new issue
Block a user