Skip to content

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

fix(pam): disable new query tab button when tab limit is reached

bernie-g2045b4039b22
diff --git a/frontend/src/pages/pam/PamDataExplorerPage/PamDataExplorerPage.tsx b/frontend/src/pages/pam/PamDataExplorerPage/PamDataExplorerPage.tsx
index 9984d3716d..d75e606168 100644
--- a/frontend/src/pages/pam/PamDataExplorerPage/PamDataExplorerPage.tsx
+++ b/frontend/src/pages/pam/PamDataExplorerPage/PamDataExplorerPage.tsx
@@ -61,7 +61,7 @@ export const PamDataExplorerPage = () => {
const [approvalJustification, setApprovalJustification] = useState("");
- const { tabs, activeTabId, addTab, closeTab, setActiveTab, updateTabSql } = useQueryTabs();
+ const { tabs, activeTabId, atTabLimit, addTab, closeTab, setActiveTab, updateTabSql } = useQueryTabs();
const {
isConnected,
@@ -457,7 +457,8 @@ export const PamDataExplorerPage = () => {
<button
type="button"
onClick={addTab}
- className="ml-1 flex shrink-0 items-center gap-1.5 rounded border border-mineshaft-600 px-2 py-1 text-xs text-mineshaft-300 transition-colors hover:border-mineshaft-500 hover:text-mineshaft-100"
+ disabled={atTabLimit}
+ className="ml-1 flex shrink-0 items-center gap-1.5 rounded border border-mineshaft-600 px-2 py-1 text-xs text-mineshaft-300 transition-colors hover:border-mineshaft-500 hover:text-mineshaft-100 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-mineshaft-600 disabled:hover:text-mineshaft-300"
aria-label="New query tab"
>
<PlusIcon className="size-3" />
diff --git a/frontend/src/pages/pam/PamDataExplorerPage/use-query-tabs.ts b/frontend/src/pages/pam/PamDataExplorerPage/use-query-tabs.ts
index dd2afa5c2e..878cb968a3 100644
--- a/frontend/src/pages/pam/PamDataExplorerPage/use-query-tabs.ts
+++ b/frontend/src/pages/pam/PamDataExplorerPage/use-query-tabs.ts
@@ -60,6 +60,7 @@ export function useQueryTabs() {
return {
tabs: state.tabs,
activeTabId: state.activeTabId,
+ atTabLimit: state.tabs.length >= MAX_QUERY_TABS,
addTab,
closeTab,
setActiveTab,