mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-02 02:34:42 +08:00
fix(gbase8s): show locale/charset picker in routed create-db dialog
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, watch, onBeforeUnmount, inject, reactive, ref, shallowRef } from "vue";
|
||||
import { createRoutedSidebarDialogController } from "./sidebarDialogControllerRouting";
|
||||
import { createRoutedSidebarDialogController, routedCanSetCreateDatabaseCharset } from "./sidebarDialogControllerRouting";
|
||||
import { useSqlHighlighter } from "@/composables/useSqlHighlighter";
|
||||
import { useSidebarDataOpenRuntime } from "@/composables/useSidebarDataOpenRuntime";
|
||||
import { useSidebarConnectionMutationRuntime } from "@/composables/useSidebarConnectionMutationRuntime";
|
||||
@@ -680,7 +680,7 @@ function routeTreeItemDialogController() {
|
||||
},
|
||||
});
|
||||
routedController.pasteTableDataCopySupported = pasteTableDataCopySupported.value;
|
||||
routedController.canSetCreateDatabaseCharset = canSetCreateDatabaseCharset.value;
|
||||
routedController.canSetCreateDatabaseCharset = routedCanSetCreateDatabaseCharset(canSetCreateDatabaseCharset.value, canSetCreateDatabaseLocale.value);
|
||||
routedController.canEditDatabaseCharsetCollation = canEditDatabaseCharsetCollation.value;
|
||||
routedController.canEditDatabaseComment = canEditDatabaseComment.value;
|
||||
emit("open-dialog-controller", routedController);
|
||||
@@ -5280,7 +5280,7 @@ function databaseDialogCapabilities() {
|
||||
return {
|
||||
showCreateDatabaseDialog,
|
||||
createDatabaseName,
|
||||
canSetCreateDatabaseCharset: canSetCreateDatabaseCharset.value || canSetCreateDatabaseLocale.value,
|
||||
canSetCreateDatabaseCharset: routedCanSetCreateDatabaseCharset(canSetCreateDatabaseCharset.value, canSetCreateDatabaseLocale.value),
|
||||
createDatabaseCharset,
|
||||
createDatabaseCharsetOptions,
|
||||
createDatabaseCharsetLoading,
|
||||
|
||||
+18
-1
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { reactive, ref, toRefs } from "vue";
|
||||
import { createRoutedSidebarDialogController } from "@/components/sidebar/sidebarDialogControllerRouting";
|
||||
import { createRoutedSidebarDialogController, routedCanSetCreateDatabaseCharset } from "@/components/sidebar/sidebarDialogControllerRouting";
|
||||
|
||||
describe("createRoutedSidebarDialogController", () => {
|
||||
it("keeps dialog open flags linked to the shared module refs", () => {
|
||||
@@ -61,3 +61,20 @@ describe("createRoutedSidebarDialogController", () => {
|
||||
expect(showCreateDatabaseDialog.value).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("routedCanSetCreateDatabaseCharset", () => {
|
||||
it("exposes the picker for locale-only dialects like GBase 8s (charset flag alone is false)", () => {
|
||||
// Regression: the routed controller used to assign the raw charset-only value, hiding the
|
||||
// create-database locale picker for GBase 8s / Informix even though the DB_LOCALE directive
|
||||
// was still emitted.
|
||||
expect(routedCanSetCreateDatabaseCharset(false, true)).toBe(true);
|
||||
});
|
||||
|
||||
it("exposes the picker for charset-capable dialects like MySQL", () => {
|
||||
expect(routedCanSetCreateDatabaseCharset(true, false)).toBe(true);
|
||||
});
|
||||
|
||||
it("hides the picker when neither charset nor locale applies", () => {
|
||||
expect(routedCanSetCreateDatabaseCharset(false, false)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,3 +27,16 @@ export function createRoutedSidebarDialogController(
|
||||
routedController.node = options.node;
|
||||
return routedController;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the create-database dialog should expose its charset/locale picker.
|
||||
*
|
||||
* For MySQL-family dialects this is a charset+collation control gated by
|
||||
* `canSetCreateDatabaseCharset`; for Informix-family dialects (GBase 8s) the same control is a
|
||||
* locale selector gated by `canSetCreateDatabaseLocale`. Both the routed controller and
|
||||
* `databaseDialogCapabilities()` must derive the flag from this single source, otherwise the two
|
||||
* paths drift and the picker silently disappears for locale-only dialects.
|
||||
*/
|
||||
export function routedCanSetCreateDatabaseCharset(canSetCreateDatabaseCharset: boolean, canSetCreateDatabaseLocale: boolean): boolean {
|
||||
return canSetCreateDatabaseCharset || canSetCreateDatabaseLocale;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user