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
@@ -155,6 +155,7 @@ import { loadObjectMetadataFacet } from "@/lib/metadata/objectMetadataCache";
|
||||
import { invalidateObjectMetadataCache } from "@/lib/metadata/objectMetadataCache";
|
||||
import { invalidateObjectDdl } from "@/lib/metadata/objectDdlCache";
|
||||
import { invalidateObjectBrowserRowsCache } from "@/lib/table/objectBrowserRowsCache";
|
||||
import { resolveInitialEventEditorRequest } from "@/lib/table/eventEditorRequest";
|
||||
|
||||
type ObjectFilter = ObjectBrowserFilter;
|
||||
type ObjectBrowserColumnKey = "select" | "name" | "type" | "estimatedRows" | "totalBytes" | "created_at" | "updated_at" | "comment";
|
||||
@@ -167,6 +168,8 @@ const props = defineProps<{
|
||||
initialEventName?: string;
|
||||
initialEventReadOnly?: boolean;
|
||||
initialEventOpenRequestId?: number;
|
||||
/** 显式"新建事件"请求号:每次菜单点击递增,用于打开/重新进入 CREATE 编辑器 */
|
||||
initialEventCreateRequestId?: number;
|
||||
initialObjectFilter?: "tables" | "events";
|
||||
viewport?: ObjectBrowserViewport;
|
||||
}>();
|
||||
@@ -2711,18 +2714,33 @@ function applyObjectBrowserRows(nextRows: ObjectBrowserRow[]) {
|
||||
}
|
||||
|
||||
function openInitialEventIfNeeded() {
|
||||
const name = props.initialEventName?.trim();
|
||||
const requestKey = `${props.initialEventOpenRequestId ?? 0}:${name}`;
|
||||
if (!name || openedInitialEvent.value === requestKey || loadingObjects.value) return;
|
||||
const name = props.initialEventName?.trim() ?? "";
|
||||
const decision = resolveInitialEventEditorRequest({
|
||||
eventCreateRequestId: props.initialEventCreateRequestId,
|
||||
eventName: props.initialEventName,
|
||||
eventOpenRequestId: props.initialEventOpenRequestId,
|
||||
openedRequestKey: openedInitialEvent.value,
|
||||
hasEventRow: rows.value.some((candidate) => candidate.type === "EVENT" && candidate.name === name),
|
||||
loadingObjects: loadingObjects.value,
|
||||
});
|
||||
if (decision.type === "ignore") return;
|
||||
openedInitialEvent.value = decision.requestKey;
|
||||
if (decision.type === "create") {
|
||||
// 新建事件:不依赖对象列表中的 EVENT row,直接进入 CREATE 编辑器。
|
||||
// MySqlEventEditor 收到空 name 时会以 CREATE 模式渲染。
|
||||
sidePanelGuard.start();
|
||||
sidePanelRow.value = null;
|
||||
sourceRow.value = null;
|
||||
sidePanelMode.value = "event-editor";
|
||||
return;
|
||||
}
|
||||
const row = rows.value.find((candidate) => candidate.type === "EVENT" && candidate.name === name);
|
||||
if (!row) return;
|
||||
openedInitialEvent.value = requestKey;
|
||||
openEventEditor(row);
|
||||
if (row) openEventEditor(row);
|
||||
}
|
||||
|
||||
function finishObjectBrowserRowsLoad() {
|
||||
loadingObjects.value = false;
|
||||
const preferredFilter = props.initialObjectFilter ?? (props.initialEventName ? "events" : "tables");
|
||||
const preferredFilter = props.initialObjectFilter ?? (props.initialEventName || props.initialEventCreateRequestId !== undefined ? "events" : "tables");
|
||||
if (!userHasSelectedFilter.value && objectCounts.value[preferredFilter] > 0) {
|
||||
// The default table filter is a presentation choice, not a user query
|
||||
// change, so preserve the tab's saved scroll offset across remounts.
|
||||
@@ -2733,8 +2751,8 @@ function finishObjectBrowserRowsLoad() {
|
||||
restoreObjectBrowserViewport();
|
||||
}
|
||||
|
||||
watch([() => props.initialEventName, () => props.initialEventOpenRequestId], ([name, requestId], [previousName, previousRequestId]) => {
|
||||
if (name !== previousName || requestId !== previousRequestId) openedInitialEvent.value = "";
|
||||
watch([() => props.initialEventName, () => props.initialEventOpenRequestId, () => props.initialEventCreateRequestId], ([name, requestId, createRequestId], [previousName, previousRequestId, previousCreateRequestId]) => {
|
||||
if (name !== previousName || requestId !== previousRequestId || createRequestId !== previousCreateRequestId) openedInitialEvent.value = "";
|
||||
openInitialEventIfNeeded();
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user