Skip to content

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

fix(pam): restore connect in browser styling, fix hooks violation, remove PK/FK indicators from query tabs

bernie-g2568e3e8f7b7
diff --git a/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx b/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx
index 14f440a5cf..b98671df73 100644
--- a/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx
+++ b/frontend/src/pages/pam/PamAccountAccessPage/PamAccountAccessPage.tsx
@@ -7,31 +7,22 @@ import { PamDataExplorerPage } from "@app/pages/pam/PamDataExplorerPage/PamDataE
import { useWebAccessSession } from "./useWebAccessSession";
-const PageContent = () => {
- const params = useParams({
- strict: false
- }) as {
- accountId?: string;
- projectId?: string;
- orgId?: string;
- resourceType?: string;
- resourceId?: string;
- };
-
- const { accountId, projectId, orgId } = params;
-
+const TerminalContent = ({
+ accountId,
+ projectId,
+ orgId
+}: {
+ accountId: string;
+ projectId: string;
+ orgId: string;
+}) => {
const { data: account, isPending } = useGetPamAccountById(accountId);
-
- if (account?.resource.resourceType === PamResourceType.Postgres) {
- return <PamDataExplorerPage />;
- }
-
const [sessionEnded, setSessionEnded] = useState(false);
const { containerRef, isConnected, disconnect, reconnect } = useWebAccessSession({
- accountId: accountId!,
- projectId: projectId!,
- orgId: orgId!,
+ accountId,
+ projectId,
+ orgId,
resourceName: account?.resource.name ?? "",
accountName: account?.name ?? "",
resourceType: account?.resource.resourceType ?? "",
@@ -116,6 +107,41 @@ const PageContent = () => {
);
};
+const PageContent = () => {
+ const params = useParams({
+ strict: false
+ }) as {
+ accountId?: string;
+ projectId?: string;
+ orgId?: string;
+ resourceType?: string;
+ resourceId?: string;
+ };
+
+ const { accountId, projectId, orgId } = params;
+ const { data: account, isPending } = useGetPamAccountById(accountId);
+
+ if (isPending) {
+ return (
+ <div className="flex h-screen w-screen items-center justify-center bg-[#0d1117] text-mineshaft-300">
+ Loading...
+ </div>
+ );
+ }
+
+ if (account?.resource.resourceType === PamResourceType.Postgres) {
+ return <PamDataExplorerPage />;
+ }
+
+ return (
+ <TerminalContent
+ accountId={accountId!}
+ projectId={projectId!}
+ orgId={orgId!}
+ />
+ );
+};
+
export const PamAccountAccessPage = () => {
return (
<>
diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx
index 9e3d3aa688..84783c5175 100644
--- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx
+++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccessAccountModal.tsx
@@ -169,7 +169,7 @@ export const PamAccessAccountModal = ({ isOpen, onOpenChange, account, projectId
accountId: account.id
}}
target="_blank"
- className="flex w-full items-center justify-center gap-2 rounded-md border border-mineshaft-600 bg-mineshaft-700 px-4 py-2 text-sm font-medium text-mineshaft-200 transition-colors hover:bg-mineshaft-600"
+ className="flex w-full items-center justify-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-black transition-colors hover:bg-primary/80"
>
<FontAwesomeIcon icon={faTerminal} />
Connect in Browser
diff --git a/frontend/src/pages/pam/PamDataExplorerPage/PamDataExplorerPage.tsx b/frontend/src/pages/pam/PamDataExplorerPage/PamDataExplorerPage.tsx
index 3b2b2ae10e..789ef9cb00 100644
--- a/frontend/src/pages/pam/PamDataExplorerPage/PamDataExplorerPage.tsx
+++ b/frontend/src/pages/pam/PamDataExplorerPage/PamDataExplorerPage.tsx
@@ -506,7 +506,6 @@ export const PamDataExplorerPage = () => {
tab={tab}
executeQuery={executeQuery}
cancelQuery={cancelQuery}
- tableDetail={tableDetail}
isInTransaction={isInTransaction}
onSqlChange={(sql) => updateTabSql(tab.id, sql)}
onTransactionStateChange={setIsInTransaction}
diff --git a/frontend/src/pages/pam/PamDataExplorerPage/components/QueryPanel.tsx b/frontend/src/pages/pam/PamDataExplorerPage/components/QueryPanel.tsx
index bebd975908..95f06e7227 100644
--- a/frontend/src/pages/pam/PamDataExplorerPage/components/QueryPanel.tsx
+++ b/frontend/src/pages/pam/PamDataExplorerPage/components/QueryPanel.tsx
@@ -3,7 +3,7 @@ import { GripHorizontalIcon } from "lucide-react";
import { cn } from "@app/components/v3/utils";
-import type { FieldInfo, TableDetail } from "../data-explorer-types";
+import type { FieldInfo } from "../data-explorer-types";
import type { QueryTab } from "../use-query-tabs";
import { QueryResultsTable } from "./QueryResultsTable";
import { QueryToolbar } from "./QueryToolbar";
@@ -28,7 +28,6 @@ type Props = {
tab: QueryTab;
executeQuery: (sql: string) => Promise<QueryResult>;
cancelQuery: () => void;
- tableDetail: TableDetail | null;
isInTransaction: boolean;
onSqlChange: (sql: string) => void;
onTransactionStateChange: (open: boolean) => void;
@@ -38,7 +37,6 @@ export function QueryPanel({
tab,
executeQuery,
cancelQuery,
- tableDetail,
isInTransaction,
onSqlChange,
onTransactionStateChange
@@ -174,7 +172,6 @@ export function QueryPanel({
result={result}
error={error}
isRunning={isRunning}
- tableDetail={tableDetail}
/>
</div>
{!isRunning && result && !error && (
diff --git a/frontend/src/pages/pam/PamDataExplorerPage/components/QueryResultsTable.tsx b/frontend/src/pages/pam/PamDataExplorerPage/components/QueryResultsTable.tsx
index 9ed82f2db1..6b7c29e063 100644
--- a/frontend/src/pages/pam/PamDataExplorerPage/components/QueryResultsTable.tsx
+++ b/frontend/src/pages/pam/PamDataExplorerPage/components/QueryResultsTable.tsx
@@ -4,8 +4,7 @@ import type { ColumnDef } from "@tanstack/react-table";
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-utils";
+import type { FieldInfo } from "../data-explorer-types";
type QueryResult = {
rows: Record<string, unknown>[];
@@ -20,61 +19,29 @@ type Props = {
result: QueryResult | null;
error: string | null;
isRunning: boolean;
- tableDetail: TableDetail | null;
};
type RowData = Record<string, unknown>;
-function buildColumns(fields: FieldInfo[], tableDetail: TableDetail | null): ColumnDef<RowData>[] {
- const colTypeMap = new Map<string, string>();
- const primaryKeys: string[] = [];
- const fkMap = new Map<string, ForeignKeyInfo>();
-
- if (tableDetail) {
- tableDetail.columns.forEach((c) => colTypeMap.set(c.name, c.type));
- tableDetail.primaryKeys.forEach((pk) => primaryKeys.push(pk));
- tableDetail.foreignKeys.forEach((fk) => {
- fk.columns.forEach((c) => {
- if (!fkMap.has(c)) fkMap.set(c, fk);
- });
- });
- }
-
- return fields.map((f) => {
- const typeLabel = colTypeMap.get(f.name);
- const columnIndicator = tableDetail
- ? getColumnIndicator(f.name, primaryKeys, fkMap)
- : undefined;
- return {
- id: f.name,
- accessorKey: f.name,
- header: f.name,
- meta: {
- label: f.name,
- ...(typeLabel ? { typeLabel } : {}),
- ...(columnIndicator ? { columnIndicator } : {}),
- cell: { variant: "short-text" as const }
- },
- enableSorting: true,
- enablePinning: true,
- enableHiding: true
- };
- });
+function buildColumns(fields: FieldInfo[]): ColumnDef<RowData>[] {
+ return fields.map((f) => ({
+ id: f.name,
+ accessorKey: f.name,
+ header: f.name,
+ meta: {
+ label: f.name,
+ cell: { variant: "short-text" as const }
+ },
+ enableSorting: true,
+ enablePinning: true,
+ enableHiding: true
+ }));
}
-function ResultsGrid({
- result,
- tableDetail
-}: {
- result: QueryResult;
- tableDetail: TableDetail | null;
-}) {
+function ResultsGrid({ result }: { result: QueryResult }) {
const { isTruncated } = result;
- const columns = useMemo(
- () => buildColumns(result.fields, tableDetail),
- [result.fields, tableDetail]
- );
+ const columns = useMemo(() => buildColumns(result.fields), [result.fields]);
const getRowId = useCallback((_row: RowData, index: number) => String(index), []);
@@ -101,7 +68,7 @@ function ResultsGrid({
);
}
-export function QueryResultsTable({ result, error, isRunning, tableDetail }: Props) {
+export function QueryResultsTable({ result, error, isRunning }: Props) {
if (isRunning) {
return (
<div className="flex h-full items-center justify-center">
@@ -163,5 +130,5 @@ export function QueryResultsTable({ result, error, isRunning, tableDetail }: Pro
);
}
- return <ResultsGrid result={result} tableDetail={tableDetail} />;
+ return <ResultsGrid result={result} />;
}