fix(mysql): open editor when creating a new event
This commit is contained in:
1 parent
c24e4352e8
commit
508369ee39
9 files changed
+368
-18
No files matched your search
@@ -1504,15 +1504,19 @@ async function confirmDeleteSavedSqlFile() {
|
||||
releaseActiveNodeReference([node.id]);
|
||||
}
|
||||
|
||||
async function openObjectBrowser(eventReadOnly = false, openEventEditor = false) {
|
||||
async function openObjectBrowser(eventReadOnly = false, openEventEditor: boolean | "create" = false) {
|
||||
const node = activeNode.value;
|
||||
if (!node.connectionId) return;
|
||||
try {
|
||||
await connectionStore.ensureConnected(node.connectionId);
|
||||
connectionStore.activeConnectionId = node.connectionId;
|
||||
|
||||
const eventName = openEventEditor === true && node.type === "event" ? node.objectName || node.label : undefined;
|
||||
const eventCreateRequestId = openEventEditor === "create" && node.type === "group-events" ? ++mysqlEventCreateRequestSeq : undefined;
|
||||
const objectFilter = node.type === "event" || node.type === "group-events" ? "events" : undefined;
|
||||
|
||||
if (hasTreeNodeDatabaseContext(node)) {
|
||||
queryStore.openObjectBrowser(node.connectionId, node.database, node.schema, node.catalog, openEventEditor && node.type === "event" ? node.objectName || node.label : undefined, eventReadOnly, node.type === "event" || node.type === "group-events" ? "events" : undefined);
|
||||
queryStore.openObjectBrowser(node.connectionId, node.database, node.schema, node.catalog, eventName, eventReadOnly, objectFilter, eventCreateRequestId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1521,7 +1525,7 @@ async function openObjectBrowser(eventReadOnly = false, openEventEditor = false)
|
||||
const options = await getDatabaseOptions(node.connectionId);
|
||||
const database = resolveDefaultDatabase(connection, options);
|
||||
if (database) {
|
||||
queryStore.openObjectBrowser(node.connectionId, database, undefined, undefined, openEventEditor && node.type === "event" ? node.objectName || node.label : undefined, eventReadOnly, node.type === "event" || node.type === "group-events" ? "events" : undefined);
|
||||
queryStore.openObjectBrowser(node.connectionId, database, undefined, undefined, eventName, eventReadOnly, objectFilter, eventCreateRequestId);
|
||||
} else {
|
||||
await toggle();
|
||||
}
|
||||
@@ -1531,6 +1535,14 @@ async function openObjectBrowser(eventReadOnly = false, openEventEditor = false)
|
||||
}
|
||||
}
|
||||
|
||||
// 每次"新建事件"菜单点击都会分配一个单调递增的请求号,保证同一个
|
||||
// ObjectBrowser tab 被复用时也能重新进入 MySQL Event 的 CREATE 编辑器。
|
||||
let mysqlEventCreateRequestSeq = 0;
|
||||
|
||||
function openMysqlEventCreateEditor() {
|
||||
void openObjectBrowser(false, "create");
|
||||
}
|
||||
|
||||
async function openDatabaseBrowser() {
|
||||
const node = activeNode.value;
|
||||
if (node.type !== "connection" || !node.connectionId) return;
|
||||
@@ -5705,7 +5717,7 @@ function buildObjectGroupSidebarMenu(context: SidebarMenuFactoryContext): boolea
|
||||
items.push({ label: t("contextMenu.createView"), action: createView, icon: Plus });
|
||||
}
|
||||
if (node.type === "group-events" && node.connectionId && node.database) {
|
||||
items.push({ label: t("contextMenu.createEvent"), action: openObjectBrowser, icon: Plus });
|
||||
items.push({ label: t("contextMenu.createEvent"), action: openMysqlEventCreateEditor, icon: Plus });
|
||||
}
|
||||
if (mysqlObjectTemplate) {
|
||||
items.push({ label: t(mysqlObjectTemplate.titleKey), action: createMysqlObjectTemplate, icon: Plus });
|
||||
|
||||
Reference in new issue
Block a user