feat(elasticsearch): show index aliases on sidebar rows
This commit is contained in:
1 parent
6299d62125
commit
61bd3cdf62
22 files changed
+432
-51
No files matched your search
@@ -3863,7 +3863,7 @@ export async function mongoCloneCollection(connectionId: string, database: strin
|
||||
|
||||
export async function elasticsearchListIndices(connectionId: string): Promise<string[]> {
|
||||
const collections = await documentListCollections(connectionId, "default");
|
||||
return collections.map((c) => c.name);
|
||||
return [...new Set(collections.flatMap((collection) => [collection.name, ...(collection.aliases ?? [])].filter((name) => name.trim())))];
|
||||
}
|
||||
|
||||
/** Lists every Meilisearch index visible to the current connection credentials. */
|
||||
|
||||
@@ -3951,7 +3951,7 @@ export async function vectorRenameCollection(connectionId: string, database: str
|
||||
|
||||
export async function elasticsearchListIndices(connectionId: string): Promise<string[]> {
|
||||
const collections = await documentListCollections(connectionId, "default");
|
||||
return collections.map((c) => c.name);
|
||||
return [...new Set(collections.flatMap((collection) => [collection.name, ...(collection.aliases ?? [])].filter((name) => name.trim())))];
|
||||
}
|
||||
|
||||
/** Lists every Meilisearch index visible to the current connection credentials. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { elasticsearchClearIndexPreview, isElasticsearchClearConfirmed, isElasticsearchIndexPattern, isElasticsearchProtocolIndex, isPartialElasticsearchClear, matchesElasticsearchIndexPattern } from "@/lib/sidebar/elasticsearchIndexActions";
|
||||
import { elasticsearchClearIndexPreview, elasticsearchIndexAliasLabel, isElasticsearchClearConfirmed, isElasticsearchIndexPattern, isElasticsearchProtocolIndex, isPartialElasticsearchClear, matchesElasticsearchIndexPattern } from "@/lib/sidebar/elasticsearchIndexActions";
|
||||
import type { ElasticsearchDeleteByQueryResult } from "@/lib/backend/tauri";
|
||||
|
||||
function clearResult(overrides: Partial<ElasticsearchDeleteByQueryResult> = {}): ElasticsearchDeleteByQueryResult {
|
||||
@@ -16,6 +16,12 @@ describe("Elasticsearch index actions", () => {
|
||||
expect(isElasticsearchProtocolIndex("elasticsearch-index", undefined)).toBe(false);
|
||||
});
|
||||
|
||||
it("renders aliases on the same row as the index name", () => {
|
||||
expect(elasticsearchIndexAliasLabel({ searchAliases: ["orders-write", "orders-read"] })).toBe("orders-write, orders-read");
|
||||
expect(elasticsearchIndexAliasLabel({ searchAliases: ["", " "] })).toBeUndefined();
|
||||
expect(elasticsearchIndexAliasLabel({})).toBeUndefined();
|
||||
});
|
||||
|
||||
it("previews the exact request the clear action sends", () => {
|
||||
const preview = elasticsearchClearIndexPreview("logs-2026.08");
|
||||
expect(preview).toContain("POST /logs-2026.08/_delete_by_query?conflicts=proceed&refresh=true");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { DatabaseType } from "@/types/database";
|
||||
import type { DatabaseType, TreeNode } from "@/types/database";
|
||||
import type { ElasticsearchDeleteByQueryResult } from "@/lib/backend/tauri";
|
||||
|
||||
/**
|
||||
@@ -10,6 +10,11 @@ export function isElasticsearchProtocolIndex(nodeType: string, dbType: DatabaseT
|
||||
return nodeType === "elasticsearch-index" && (dbType === "elasticsearch" || dbType === "easysearch");
|
||||
}
|
||||
|
||||
export function elasticsearchIndexAliasLabel(node: Pick<TreeNode, "searchAliases">): string | undefined {
|
||||
const aliases = node.searchAliases?.filter((alias) => alias.trim()) ?? [];
|
||||
return aliases.length ? aliases.join(", ") : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* With an `index_grouping` regex configured, a sidebar index node is a collapsed
|
||||
* pattern (`logs-2026.08.*`) rather than one index, and clearing it hits every
|
||||
|
||||
Reference in new issue
Block a user