Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
import { Button } from "@/components/ui/button";
import { Tooltip } from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";
import { useConnectionOfCurrentSQLEditorTab } from "@/modules/sql-editor/hooks/useSQLEditorState";
import { useSQLEditorTabState } from "@/modules/sql-editor/store/tab";
import { extractDatabaseResourceName } from "@/utils";
import type { AvailableAction } from "../SchemaPane/actions";
import { useSchemaPaneActions } from "../SchemaPane/actions";
type Props = {
readonly action: AvailableAction;
readonly disabled?: boolean;
};
/**
* One vertical-rail button per panel view. Active state lights up when
* the current tab's `viewState.view` equals the action's view. Click
* opens (or focuses) a tab for that view via
* `useSchemaPaneActions().openNewTab`.
*
* The label rides in a right-aligned tooltip.
*/
export function ActionBarTabItem({ action, disabled }: Props) {
const { database } = useConnectionOfCurrentSQLEditorTab();
const { openNewTab } = useSchemaPaneActions();
const active = useSQLEditorTabState(
(s) => s.tabsById.get(s.currentTabId)?.viewState?.view === action.view
);
const handleClick = () => {
openNewTab({
title: `[${
extractDatabaseResourceName(database.name).databaseName
}] ${action.title}`,
view: action.view,
});
};
return (
<Tooltip side="right" content={action.title} delayDuration={300}>
<Button
type="button"
appearance="secondary"
size="sm"
disabled={disabled}
onClick={handleClick}
className={cn(
"w-9 px-1 flex items-center justify-center",
active && "bg-accent/10 text-accent hover:bg-accent/15"
)}
>
{/*
Several schema icons (`FunctionIcon`, `ProcedureIcon`,
`ViewIcon`, `SequenceIcon`, `PackageIcon`) hardcode `text-gray-400`
/ `text-gray-500` on themselves — and in `ViewIcon`'s case on a
nested `<Table>` — to look de-emphasized inside the schema tree.
In the ActionBar rail those same icons read as a navigation
control, not as disabled. The `[&_*]:!text-current` selector
forces every descendant element to inherit this span's color
(`text-main` when inactive, the button's `text-accent` when
active), beating the icons' hardcoded gray.
*/}
<span
className={cn(
"size-4 inline-flex items-center justify-center [&_*]:!text-current",
!active && "text-main"
)}
>
{action.icon}
</span>
</Button>
</Tooltip>
);
}