fix(mysql): prevalidate routine saves and support procedure refresh
This commit is contained in:
1 parent
0023c03520
commit
4ac2c5dc40
16 files changed
+173
-20
No files matched your search
@@ -1385,6 +1385,10 @@ async function fetchTableConstraints(force = false) {
|
||||
}
|
||||
|
||||
async function refreshActiveTableInfo() {
|
||||
if (sidePanelMode.value === "source") {
|
||||
await refreshActiveSource();
|
||||
return;
|
||||
}
|
||||
if (sidePanelMode.value !== "table-info" || !sidePanelRow.value) return;
|
||||
sidePanelGuard.bump();
|
||||
|
||||
@@ -1502,9 +1506,14 @@ async function openSource(row: ObjectBrowserRow) {
|
||||
closeSidePanel();
|
||||
return;
|
||||
}
|
||||
await loadSourcePanel(row);
|
||||
}
|
||||
|
||||
async function loadSourcePanel(row: ObjectBrowserRow, options?: { preserveEditing?: boolean }) {
|
||||
// Starting a different object must invalidate slower source requests before
|
||||
// any state is reset, otherwise an old response can populate the new row.
|
||||
const epoch = sidePanelGuard.start();
|
||||
const preserveEditing = options?.preserveEditing === true && sourceEditing.value;
|
||||
sidePanelRow.value = row;
|
||||
sidePanelMode.value = "source";
|
||||
sourceRow.value = row;
|
||||
@@ -1538,7 +1547,9 @@ async function openSource(row: ObjectBrowserRow) {
|
||||
sourceEditableText.value = editable;
|
||||
sourceContent.value = row.type === "SEQUENCE" ? result.source : editable;
|
||||
sourceDraft.value = editable;
|
||||
sourceEditing.value = sourceCanEdit.value && row.type !== "SEQUENCE";
|
||||
// Fresh open always enters edit when allowed; refresh preserves prior edit mode.
|
||||
const enterEditing = sourceCanEdit.value && row.type !== "SEQUENCE" && (options?.preserveEditing ? preserveEditing : true);
|
||||
sourceEditing.value = enterEditing;
|
||||
if (!sourceCanEdit.value && row.type !== "SEQUENCE") {
|
||||
toast(t("objects.sourceReadOnly"), 3000);
|
||||
}
|
||||
@@ -1550,6 +1561,13 @@ async function openSource(row: ObjectBrowserRow) {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshActiveSource() {
|
||||
const row = sourceRow.value || (sidePanelMode.value === "source" ? sidePanelRow.value : null);
|
||||
if (!row || sidePanelMode.value !== "source") return;
|
||||
if (sourceEditing.value && !window.confirm(t("objects.refreshDiscardConfirm"))) return;
|
||||
await loadSourcePanel(row, { preserveEditing: true });
|
||||
}
|
||||
|
||||
function openEventEditor(row: ObjectBrowserRow) {
|
||||
sidePanelGuard.start();
|
||||
sidePanelRow.value = row;
|
||||
@@ -4039,6 +4057,9 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {
|
||||
<Button v-if="!sourceEditing && sourceCanEdit" variant="ghost" size="icon" class="h-5 w-5" :disabled="!sourceContent" @click="editSource">
|
||||
<PencilLine class="h-3 w-3" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" class="h-5 w-5" :disabled="sourceLoading || sourceSaving" :title="t('structureEditor.refresh')" :aria-label="t('structureEditor.refresh')" @click="refreshActiveSource">
|
||||
<RefreshCw class="h-3 w-3" :class="{ 'animate-spin': sourceLoading }" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" class="h-5 w-5" @click="closeSource">
|
||||
<X class="h-3 w-3" />
|
||||
</Button>
|
||||
|
||||
@@ -156,6 +156,12 @@ function cancelEditSource() {
|
||||
saveError.value = "";
|
||||
}
|
||||
|
||||
async function refreshSource() {
|
||||
if (loading.value || saving.value) return;
|
||||
if (editing.value && !window.confirm(t("objects.refreshDiscardConfirm"))) return;
|
||||
await loadSource(editing.value && canEdit.value);
|
||||
}
|
||||
|
||||
async function saveSource() {
|
||||
if (saving.value || loading.value || !props.open) return;
|
||||
if (!canEdit.value) {
|
||||
@@ -271,6 +277,10 @@ function closeDialog() {
|
||||
|
||||
<DialogFooter>
|
||||
<Button variant="outline" @click="closeDialog">{{ t("common.close") }}</Button>
|
||||
<Button variant="outline" :disabled="loading || saving" :title="t('structureEditor.refresh')" @click="refreshSource">
|
||||
<RefreshCw class="h-4 w-4" />
|
||||
{{ t("structureEditor.refresh") }}
|
||||
</Button>
|
||||
<Button v-if="!editing" variant="outline" :disabled="!content" @click="copySource">
|
||||
<Clipboard class="h-4 w-4" />
|
||||
{{ t("grid.copy") }}
|
||||
|
||||
Reference in new issue
Block a user