1 parent
278429ab07
commit
4c6c3142c0
18 files changed
+456
-7
No files matched your search
@@ -51,6 +51,7 @@ import { Switch } from "@/components/ui/switch";
|
||||
import { cancelPendingSidebarDataOpen, runSidebarDataOpenImmediately, type SidebarDataOpenRequest } from "@/lib/sidebar/sidebarDataOpenCoordinator";
|
||||
import CustomContextMenu, { type ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { codeMirrorSqlDialect } from "@/lib/database/jdbcDialect";
|
||||
import { sqlFormatDialectForDbType } from "@/lib/sql/sqlFormatter";
|
||||
@@ -1460,6 +1461,13 @@ function updateSidebarDangerDialogOption(event: Event) {
|
||||
void option.onChange?.(option.checked);
|
||||
}
|
||||
|
||||
function updateSidebarDangerDialogTextInput(value: string | number) {
|
||||
const input = sidebarDangerDialogRequest.value?.textInput;
|
||||
if (!input) return;
|
||||
input.value = String(value);
|
||||
void input.onInput?.(input.value);
|
||||
}
|
||||
|
||||
function updateSidebarTreeItemDialogController(controller: Record<string, any> | null) {
|
||||
sidebarTreeItemDialogController.value = controller;
|
||||
}
|
||||
@@ -2287,6 +2295,10 @@ defineExpose({ focusSearch, createNewGroup, collapseAllTreeNodes });
|
||||
<span class="text-xs leading-5 text-muted-foreground">{{ sidebarDangerDialogRequest.option.hint }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label v-if="sidebarDangerDialogRequest.textInput" class="mb-3 grid gap-1.5 rounded-md border bg-muted/20 px-3 py-2 text-sm">
|
||||
<span class="font-medium text-foreground">{{ sidebarDangerDialogRequest.textInput.label }}</span>
|
||||
<Input :model-value="sidebarDangerDialogRequest.textInput.value" :inputmode="sidebarDangerDialogRequest.textInput.inputMode" :placeholder="sidebarDangerDialogRequest.textInput.placeholder" @update:model-value="updateSidebarDangerDialogTextInput" />
|
||||
</label>
|
||||
</template>
|
||||
</SidebarDangerConfirmDialog>
|
||||
<SidebarTreeItemDialogs v-if="sidebarTreeItemDialogController" :key="sidebarTreeItemDialogController.node?.id" :controller="sidebarTreeItemDialogController" @closed="sidebarTreeItemDialogController = null" />
|
||||
|
||||
@@ -190,6 +190,7 @@ import {
|
||||
isLoadingStructurePreview,
|
||||
showEmptyTableConfirm,
|
||||
showTruncateTableConfirm,
|
||||
showMysqlAutoIncrementConfirm,
|
||||
showRenameObjectDialog,
|
||||
renameObjectName,
|
||||
renameObjectError,
|
||||
@@ -200,6 +201,8 @@ import {
|
||||
emptyTablePreviewSql,
|
||||
truncateTablePreviewSql,
|
||||
truncateTableCascade,
|
||||
mysqlAutoIncrementValue,
|
||||
mysqlAutoIncrementPreviewSql,
|
||||
dropObjectPreviewSql,
|
||||
showDropObjectConfirm,
|
||||
dropTableChildObjectPreviewSql,
|
||||
@@ -462,7 +465,7 @@ const {
|
||||
confirmDropAllMongoIndexes,
|
||||
} = useSidebarDatabaseSpecificMutationRuntime({ activeNode, connectionStore });
|
||||
|
||||
const { isTableNotView, supportsTruncate, canDropTableCascade, canTruncateTableCascade, refreshDropTablePreviewSql, refreshTruncateTablePreviewSql, dropTable, refreshTableList, confirmDropTable, emptyTable, confirmEmptyTable, truncateTable, confirmTruncateTable } = useSidebarTableMutationRuntime({
|
||||
const { isTableNotView, supportsTruncate, supportsMysqlAutoIncrement, canDropTableCascade, canTruncateTableCascade, refreshDropTablePreviewSql, refreshTruncateTablePreviewSql, dropTable, refreshTableList, confirmDropTable, emptyTable, confirmEmptyTable, truncateTable, confirmTruncateTable, mysqlAutoIncrement, refreshMysqlAutoIncrementPreviewSql, confirmMysqlAutoIncrement } = useSidebarTableMutationRuntime({
|
||||
activeNode,
|
||||
releaseActiveNodeReference,
|
||||
connectionStore,
|
||||
@@ -3777,6 +3780,13 @@ function dangerRequest(request: Omit<SidebarDangerDialogRequest, "target">): Sid
|
||||
await onChange(checked);
|
||||
};
|
||||
}
|
||||
if (request.textInput?.onInput) {
|
||||
const onInput = request.textInput.onInput;
|
||||
request.textInput.onInput = async (value) => {
|
||||
activateActionTarget(target);
|
||||
await onInput(value);
|
||||
};
|
||||
}
|
||||
routedRequest.target = target;
|
||||
sidebarDangerTarget.value = routedRequest.target;
|
||||
return routedRequest;
|
||||
@@ -3872,6 +3882,30 @@ routeDangerDialog(showTruncateTableConfirm, () =>
|
||||
}),
|
||||
);
|
||||
|
||||
routeDangerDialog(showMysqlAutoIncrementConfirm, () =>
|
||||
dangerRequest({
|
||||
title: t("contextMenu.mysqlAutoIncrementTitle"),
|
||||
message: t("contextMenu.mysqlAutoIncrementMessage", { name: activeNode.value.label }),
|
||||
detailsText: t("contextMenu.mysqlAutoIncrementNonemptyHint"),
|
||||
get sql() {
|
||||
return mysqlAutoIncrementPreviewSql.value;
|
||||
},
|
||||
confirmLabel: t("contextMenu.mysqlAutoIncrement"),
|
||||
textInput: {
|
||||
value: mysqlAutoIncrementValue.value,
|
||||
label: t("contextMenu.mysqlAutoIncrementValue"),
|
||||
placeholder: "1",
|
||||
inputMode: "numeric",
|
||||
async onInput(value) {
|
||||
mysqlAutoIncrementValue.value = value;
|
||||
if (sidebarDangerTarget.value) activateActionTarget(sidebarDangerTarget.value);
|
||||
await refreshMysqlAutoIncrementPreviewSql();
|
||||
},
|
||||
},
|
||||
confirm: confirmMysqlAutoIncrement,
|
||||
}),
|
||||
);
|
||||
|
||||
routeDangerDialog(showDropObjectConfirm, () =>
|
||||
dangerRequest({
|
||||
title: dropObjectConfirmTitle(),
|
||||
@@ -4898,6 +4932,9 @@ function buildObjectSidebarMenu(context: SidebarMenuFactoryContext): boolean {
|
||||
items.push({ label: t("contextMenu.duplicateStructure"), action: duplicateStructure, icon: CopyPlus });
|
||||
// Keep menu copy aligned with keyboard copy so frozen multi-selection and single-row fallback stay compatible.
|
||||
items.push(...treeTableClipboardMenuItems(node));
|
||||
if (supportsMysqlAutoIncrement.value) {
|
||||
items.push({ label: t("contextMenu.mysqlAutoIncrement"), action: mysqlAutoIncrement, icon: Gauge });
|
||||
}
|
||||
if (supportsTruncate.value) {
|
||||
destructiveActions.push({
|
||||
label: truncateMenuLabel(t("contextMenu.truncateTable")),
|
||||
|
||||
@@ -32,6 +32,7 @@ export const structureDocCopyTitle = ref("");
|
||||
export const isLoadingStructurePreview = ref(false);
|
||||
export const showEmptyTableConfirm = ref(false);
|
||||
export const showTruncateTableConfirm = ref(false);
|
||||
export const showMysqlAutoIncrementConfirm = ref(false);
|
||||
export const showRenameObjectDialog = ref(false);
|
||||
export const renameObjectName = ref("");
|
||||
export const renameObjectError = ref("");
|
||||
@@ -42,6 +43,9 @@ export const batchDropCascade = ref(false);
|
||||
export const emptyTablePreviewSql = ref("");
|
||||
export const truncateTablePreviewSql = ref("");
|
||||
export const truncateTableCascade = ref(false);
|
||||
export const mysqlAutoIncrementValue = ref("1");
|
||||
export const mysqlAutoIncrementPreviewSql = ref("");
|
||||
export const mysqlAutoIncrementPreviewKey = ref("");
|
||||
export const dropObjectPreviewSql = ref("");
|
||||
export const showDropObjectConfirm = ref(false);
|
||||
export const dropTableChildObjectPreviewSql = ref("");
|
||||
@@ -145,6 +149,7 @@ const openFlags = [
|
||||
showStructureDocCopyDialog,
|
||||
showEmptyTableConfirm,
|
||||
showTruncateTableConfirm,
|
||||
showMysqlAutoIncrementConfirm,
|
||||
showDropObjectConfirm,
|
||||
showRenameObjectDialog,
|
||||
showDuplicateDialog,
|
||||
|
||||
Reference in new issue
Block a user