canSaveSqlTab (tabs/sqlTabSaveTarget.ts)

dbx · apps/desktop/src/lib/tabs/sqlTabSaveTarget.ts · typescript · Apache-2.0
database, tag:embed-classified

Utility to determine if a SQL tab can be persisted based on its fields.

// Source: https://github.com/t8y2/dbx | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import type { QueryTab } from "@/types/database";

/** Tab fields that decide whether its SQL can be persisted. */
export type SqlTabSaveTarget = Pick<QueryTab, "externalSqlPath" | "savedSqlId" | "sql" | "objectSource">;

/**
 * Whether the tab's SQL can be saved at all.
 *
 * A tab that already has a persistence target — an external `.sql` file or a
 * saved-SQL library entry — stays saveable after its content is emptied.
 * Deleting everything is a legitimate edit that must reach the target, and the
 * emptied state is also the only state in which the user can observe the guard.
 *
 * A brand-

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key