feat(editor): add ignore action to sql parameter dialog

This commit is contained in:
zipg
2026-09-04 09:50:46 +08:00
committed by GitHub
parent 97f5a37ba8
commit d7941572b8
10 changed files with 58 additions and 0 deletions
@@ -96,6 +96,11 @@ function clearParameterValues() {
values.value = next;
}
function ignoreParameters() {
open.value = false;
emit("execute", props.sql);
}
function updateValue(name: string, value: string) {
const matchedHistory = histories.value[name]?.find((entry) => entry.value === value);
values.value[name] = { ...(values.value[name] ?? { kind: "string" }), ...(matchedHistory ? { kind: matchedHistory.kind } : {}), value };
@@ -226,6 +231,9 @@ async function copyResolvedSql() {
</div>
<DialogFooter>
<Button type="button" variant="outline" data-testid="sql-parameters-ignore" @click="ignoreParameters">
{{ t("sqlParameters.ignore") }}
</Button>
<Button variant="outline" @click="open = false">{{ t("dangerDialog.cancel") }}</Button>
<Button variant="outline" @click="copyResolvedSql">
<Copy class="mr-1.5 h-4 w-4" />
@@ -86,6 +86,10 @@ function clearActionButton(): HTMLButtonElement | null {
return document.body.querySelector('[data-testid="sql-parameters-clear-values"]');
}
function ignoreActionButton(): HTMLButtonElement | null {
return document.body.querySelector('[data-testid="sql-parameters-ignore"]');
}
function clickRawAction() {
const button = actionButton();
expect(button).not.toBeNull();
@@ -98,6 +102,12 @@ function clickClearAction() {
button!.click();
}
function clickIgnoreAction() {
const button = ignoreActionButton();
expect(button).not.toBeNull();
button!.click();
}
function buttonWithText(text: string): HTMLButtonElement | undefined {
return Array.from(document.body.querySelectorAll("button")).find((button) => button.textContent?.trim() === text);
}
@@ -183,6 +193,38 @@ describe("SqlParameterDialog raw parameter action", () => {
});
});
describe("SqlParameterDialog ignore parameter action", () => {
it("closes the dialog and emits the original SQL without remembering or mutating values", async () => {
const { state, onExecute } = await mountDialog();
clickIgnoreAction();
await nextTick();
expect(state.open).toBe(false);
expect(onExecute).toHaveBeenCalledOnce();
expect(onExecute).toHaveBeenCalledWith(SQL);
expect(historyMocks.remember).not.toHaveBeenCalled();
expect(parameterInputs().map((input) => input.value)).toEqual(PARAMETERS.map((parameter) => MIXED_VALUES[parameter.key]?.value ?? ""));
});
it("does not apply current parameter edits when ignoring", async () => {
const { state, onExecute } = await mountDialog();
const firstInput = parameterInputs()[0];
expect(firstInput).not.toBeUndefined();
firstInput!.value = "changed";
firstInput!.dispatchEvent(new Event("input", { bubbles: true }));
await nextTick();
clickIgnoreAction();
await nextTick();
expect(state.open).toBe(false);
expect(onExecute).toHaveBeenCalledWith(SQL);
expect(historyMocks.remember).not.toHaveBeenCalled();
});
});
describe("SqlParameterDialog clear parameter values action", () => {
it("clears every displayed value while preserving kinds and updating the preview", async () => {
const { state, onExecute } = await mountDialog();
+1
View File
@@ -5377,6 +5377,7 @@ export default {
execute: "Execute",
clearValues: "Clear Values",
useRawForAll: "Use Raw SQL for All",
ignore: "Ignore",
kind: {
string: "String",
number: "Number",
+1
View File
@@ -5105,6 +5105,7 @@ export default withEnglishFallback({
execute: "Ejecutar",
clearValues: "Borrar valores",
useRawForAll: "Usar SQL sin procesar para todos",
ignore: "Ignorar",
kind: {
string: "Cadena",
number: "Número",
+1
View File
@@ -5103,6 +5103,7 @@ export default withEnglishFallback({
execute: "Esegui",
clearValues: "Cancella valori",
useRawForAll: "Usa SQL non elaborato per tutti",
ignore: "Ignora",
kind: {
string: "Stringa",
number: "Numero",
+1
View File
@@ -5132,6 +5132,7 @@ export default withEnglishFallback({
execute: "実行",
clearValues: "値をクリア",
useRawForAll: "すべてを生の SQL に設定",
ignore: "無視",
kind: {
string: "文字列",
number: "数値",
+1
View File
@@ -4797,6 +4797,7 @@ export default withEnglishFallback({
execute: "실행",
clearValues: "값 지우기",
useRawForAll: "모두 원시 SQL로 설정",
ignore: "무시",
kind: {
string: "문자열",
number: "숫자",
+1
View File
@@ -5105,6 +5105,7 @@ export default withEnglishFallback({
execute: "Executar",
clearValues: "Limpar valores",
useRawForAll: "Usar SQL bruto para todos",
ignore: "Ignorar",
kind: {
string: "Texto",
number: "Número",
+1
View File
@@ -5361,6 +5361,7 @@ export default withEnglishFallback({
execute: "执行",
clearValues: "清空参数值",
useRawForAll: "全部使用原始 SQL",
ignore: "忽略",
kind: {
string: "字符串",
number: "数字",
+1
View File
@@ -4428,6 +4428,7 @@ export default withEnglishFallback({
execute: "執行",
clearValues: "清空參數值",
useRawForAll: "全部使用原始 SQL",
ignore: "忽略",
kind: {
string: "字串",
number: "數字",