Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor(pam): move getColumnIndicator to data-explorer-utils

Bernie Gandinffdbac9699d1
diff --git a/frontend/src/pages/pam/PamDataExplorerPage/components/DataExplorerGrid.tsx b/frontend/src/pages/pam/PamDataExplorerPage/components/DataExplorerGrid.tsx
index ee024ed5c0..68beb9d70a 100644
--- a/frontend/src/pages/pam/PamDataExplorerPage/components/DataExplorerGrid.tsx
+++ b/frontend/src/pages/pam/PamDataExplorerPage/components/DataExplorerGrid.tsx
@@ -11,7 +11,7 @@ import { DataGrid, useDataGrid } from "@app/components/v3/generic/DataGrid";
import { Skeleton } from "@app/components/v3/generic/Skeleton";
import type { ColumnInfo, FieldInfo, ForeignKeyInfo, TableDetail } from "../data-explorer-types";
-import { getColumnIndicator } from "../data-explorer-types";
+import { getColumnIndicator } from "../data-explorer-utils";
import type { FilterCondition, SortCondition } from "../sql-generation";
import {
buildCountQuery,
diff --git a/frontend/src/pages/pam/PamDataExplorerPage/components/QueryResultsTable.tsx b/frontend/src/pages/pam/PamDataExplorerPage/components/QueryResultsTable.tsx
index 158bce5007..f23dc5a441 100644
--- a/frontend/src/pages/pam/PamDataExplorerPage/components/QueryResultsTable.tsx
+++ b/frontend/src/pages/pam/PamDataExplorerPage/components/QueryResultsTable.tsx
@@ -5,7 +5,7 @@ import { Spinner } from "@app/components/v2";
import { DataGrid, useDataGrid } from "@app/components/v3/generic/DataGrid";
import type { FieldInfo, ForeignKeyInfo, TableDetail } from "../data-explorer-types";
-import { getColumnIndicator } from "../data-explorer-types";
+import { getColumnIndicator } from "../data-explorer-utils";
const MAX_ROWS = 500;
diff --git a/frontend/src/pages/pam/PamDataExplorerPage/data-explorer-types.ts b/frontend/src/pages/pam/PamDataExplorerPage/data-explorer-types.ts
index 5b0a6f4b39..435da716ec 100644
--- a/frontend/src/pages/pam/PamDataExplorerPage/data-explorer-types.ts
+++ b/frontend/src/pages/pam/PamDataExplorerPage/data-explorer-types.ts
@@ -57,17 +57,3 @@ export type TableDetail = {
export type FieldInfo = {
name: string;
};
-
-export function getColumnIndicator(
- colName: string,
- primaryKeys: string[],
- fkMap: Map<string, ForeignKeyInfo>
-): { type: "pk" | "fk"; tooltip?: string } | undefined {
- if (primaryKeys.includes(colName)) return { type: "pk" };
- const fk = fkMap.get(colName);
- if (fk) {
- const targetCol = fk.targetColumns[fk.columns.indexOf(colName)] ?? fk.targetColumns[0];
- return { type: "fk", tooltip: `\u2192 ${fk.targetSchema}.${fk.targetTable}(${targetCol})` };
- }
- return undefined;
-}
diff --git a/frontend/src/pages/pam/PamDataExplorerPage/data-explorer-utils.ts b/frontend/src/pages/pam/PamDataExplorerPage/data-explorer-utils.ts
new file mode 100644
index 0000000000..a00fc9540a
--- /dev/null
+++ b/frontend/src/pages/pam/PamDataExplorerPage/data-explorer-utils.ts
@@ -0,0 +1,15 @@
+import type { ForeignKeyInfo } from "./data-explorer-types";
+
+export function getColumnIndicator(
+ colName: string,
+ primaryKeys: string[],
+ fkMap: Map<string, ForeignKeyInfo>
+): { type: "pk" | "fk"; tooltip?: string } | undefined {
+ if (primaryKeys.includes(colName)) return { type: "pk" };
+ const fk = fkMap.get(colName);
+ if (fk) {
+ const targetCol = fk.targetColumns[fk.columns.indexOf(colName)] ?? fk.targetColumns[0];
+ return { type: "fk", tooltip: `\u2192 ${fk.targetSchema}.${fk.targetTable}(${targetCol})` };
+ }
+ return undefined;
+}