feat(connection): persist manually selected default schema
This commit is contained in:
53 files changed
+284
-9
No files matched your search
@@ -347,6 +347,8 @@ const emit = defineEmits<{
|
||||
const {
|
||||
setNodeAsDefaultDatabase,
|
||||
clearNodeDefaultDatabase,
|
||||
setNodeAsDefaultSchema,
|
||||
clearNodeDefaultSchema,
|
||||
connectionDeleteMenuLabel,
|
||||
connectionDuplicateMenuLabel,
|
||||
connectionDeleteConfirmMessage,
|
||||
@@ -364,6 +366,7 @@ const {
|
||||
closeDatabaseConnection,
|
||||
isPinned,
|
||||
isNodeDefaultDatabase,
|
||||
isNodeDefaultSchema,
|
||||
isConnected,
|
||||
isConnecting,
|
||||
canCloseDatabaseConnection,
|
||||
@@ -1248,7 +1251,7 @@ async function newQuery() {
|
||||
const connection = connectionStore.getConfig(node.connectionId);
|
||||
if (!connection) return;
|
||||
const options = await getDatabaseOptions(node.connectionId);
|
||||
queryStore.createTab(node.connectionId, resolveDefaultDatabase(connection, options), undefined, "query");
|
||||
queryStore.createTab(node.connectionId, resolveDefaultDatabase(connection, options), undefined, "query", connection.default_schema);
|
||||
} catch (e: any) {
|
||||
toast(t("connection.connectFailed", { message: translateBackendError(t, e) }), 5000);
|
||||
openDriverStoreForInstallError(e?.message || String(e));
|
||||
@@ -4179,6 +4182,13 @@ function buildDatabaseSidebarMenu(context: SidebarMenuFactoryContext): boolean {
|
||||
items.push({ label: t("contextMenu.clearDefaultDatabase"), action: clearNodeDefaultDatabase, icon: Database });
|
||||
}
|
||||
}
|
||||
if (node.type === "schema") {
|
||||
if (!isNodeDefaultSchema.value) {
|
||||
items.push({ label: t("contextMenu.setDefaultSchema"), action: setNodeAsDefaultSchema, icon: Database });
|
||||
} else {
|
||||
items.push({ label: t("contextMenu.clearDefaultSchema"), action: clearNodeDefaultSchema, icon: Database });
|
||||
}
|
||||
}
|
||||
if (canEditDatabaseProperties.value) {
|
||||
items.push({ label: t("contextMenu.editDatabaseProperties"), action: openEditDatabasePropertiesDialog, icon: SquarePen });
|
||||
}
|
||||
|
||||
@@ -566,6 +566,9 @@ const isNodeDefaultDatabase = computed(
|
||||
typeof activeNode.value.database === "string" &&
|
||||
connectionStore.isDefaultDatabase(activeNode.value.connectionId, activeNode.value.database),
|
||||
);
|
||||
function isNodeDefaultSchema(): boolean {
|
||||
return activeNode.value.type === "schema" && !!activeNode.value.connectionId && !!activeNode.value.schema && connectionStore.isDefaultSchema(activeNode.value.connectionId, activeNode.value.schema);
|
||||
}
|
||||
|
||||
const trailingComment = computed(() => {
|
||||
if (!settingsStore.editorSettings.sidebarObjectInfoMode.startsWith("comment-")) return null;
|
||||
@@ -1212,6 +1215,9 @@ function onKeydown(event: KeyboardEvent) {
|
||||
<Badge v-if="isNodeDefaultDatabase" variant="secondary" class="h-4 px-1.5 text-[10px]">
|
||||
{{ t("editor.defaultDatabase") }}
|
||||
</Badge>
|
||||
<Badge v-if="isNodeDefaultSchema()" variant="secondary" class="h-4 px-1.5 text-[10px]">
|
||||
{{ t("editor.defaultSchema") }}
|
||||
</Badge>
|
||||
</div>
|
||||
<span v-if="trailingComment && !isRightAlignedComment()" class="sidebar-object-comment ml-4 min-w-0 flex-1 truncate text-left" :class="{ 'sidebar-object-comment--windows': useWindowsSidebarCommentFont }">{{ trailingComment }}</span>
|
||||
<span v-if="isRightAlignedComment() && trailingCommentMaxWidth > 0" class="min-w-0 flex-1" aria-hidden="true" />
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ const connectionStore = {
|
||||
connections: [],
|
||||
getConfig: () => ({ id: "connection-1", db_type: "sqlserver" }),
|
||||
isDefaultDatabase: () => false,
|
||||
isDefaultSchema: () => false,
|
||||
isPinnedTreeNodeReorderTarget: () => false,
|
||||
isTreeNodeChildrenLoaded: () => false,
|
||||
isTreeNodePinned: () => false,
|
||||
|
||||
+1
@@ -16,6 +16,7 @@ const connectionStore = {
|
||||
connections: [],
|
||||
getConfig: () => ({ id: "connection-1", db_type: "sqlite" }),
|
||||
isDefaultDatabase: () => false,
|
||||
isDefaultSchema: () => false,
|
||||
isPinnedTreeNodeReorderTarget: () => false,
|
||||
isTreeNodeChildrenLoaded: () => false,
|
||||
isTreeNodePinned: () => false,
|
||||
|
||||
+1
@@ -40,6 +40,7 @@ const connectionStore = {
|
||||
getSidebarVisibleFilterSummary: () => state.summary,
|
||||
clearConnectionError: vi.fn(),
|
||||
isDefaultDatabase: () => false,
|
||||
isDefaultSchema: () => false,
|
||||
isPinnedTreeNodeReorderTarget: () => false,
|
||||
isTreeNodeChildrenLoaded: () => false,
|
||||
isTreeNodePinned: () => false,
|
||||
|
||||
Reference in new issue
Block a user