mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 04:26:01 +00:00
SYNC: autocommit WIP
This commit is contained in:
committed by
Diflow
parent
9c7727b7f3
commit
191c25a26b
@@ -68,6 +68,22 @@
|
||||
testEnabled: () => getCurrentEditor()?.beginTransactionEnabled(),
|
||||
onClick: () => getCurrentEditor().beginTransaction(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'query.autocommitOffSwitch',
|
||||
category: 'Query',
|
||||
name: 'Autocommit: OFF',
|
||||
icon: 'icon transaction',
|
||||
testEnabled: () => getCurrentEditor()?.autocommitOffSwitchEnabled(),
|
||||
onClick: () => getCurrentEditor().autocommitOffSwitch(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'query.autocommitOnSwitch',
|
||||
category: 'Query',
|
||||
name: 'Autocommit: ON',
|
||||
icon: 'icon transaction',
|
||||
testEnabled: () => getCurrentEditor()?.autocommitOnSwitchEnabled(),
|
||||
onClick: () => getCurrentEditor().autocommitOnSwitch(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'query.commitTransaction',
|
||||
category: 'Query',
|
||||
@@ -178,6 +194,7 @@
|
||||
let isAiAssistantVisible = isProApp() && localStorage.getItem(`tabdata_isAiAssistantVisible_${tabid}`) == 'true';
|
||||
let domAiAssistant;
|
||||
let isInTransaction = false;
|
||||
let isAutocommit = false;
|
||||
|
||||
onMount(() => {
|
||||
intervalId = setInterval(() => {
|
||||
@@ -221,6 +238,7 @@
|
||||
busy;
|
||||
sessionId;
|
||||
isInTransaction;
|
||||
isAutocommit;
|
||||
invalidateCommands();
|
||||
}
|
||||
|
||||
@@ -415,13 +433,29 @@
|
||||
}
|
||||
|
||||
export function beginTransactionEnabled() {
|
||||
return driver?.supportsTransactions && !isInTransaction && !busy;
|
||||
return driver?.supportsTransactions && !driver?.implicitTransactions && !isInTransaction && !busy;
|
||||
}
|
||||
|
||||
export function autocommitOffSwitchEnabled() {
|
||||
return driver?.supportsTransactions && driver?.implicitTransactions && !isInTransaction && !busy && !isAutocommit;
|
||||
}
|
||||
|
||||
export function autocommitOnSwitchEnabled() {
|
||||
return driver?.supportsTransactions && driver?.implicitTransactions && !isInTransaction && !busy && isAutocommit;
|
||||
}
|
||||
|
||||
export function endTransactionEnabled() {
|
||||
return !!sessionId && driver?.supportsTransactions && isInTransaction && !busy;
|
||||
}
|
||||
|
||||
export function autocommitOffSwitch() {
|
||||
isAutocommit = true;
|
||||
}
|
||||
|
||||
export function autocommitOnSwitch() {
|
||||
isAutocommit = false;
|
||||
}
|
||||
|
||||
export function commitTransaction() {
|
||||
const dmp = driver.createDumper();
|
||||
dmp.commitTransaction();
|
||||
@@ -666,6 +700,12 @@
|
||||
data-testid="QueryTab_beginTransactionButton"
|
||||
hideDisabled
|
||||
/>
|
||||
<ToolStripCommandButton command="query.autocommitOnSwitch" data-testid="QueryTab_autocommitOnSwitch" hideDisabled />
|
||||
<ToolStripCommandButton
|
||||
command="query.autocommitOffSwitch"
|
||||
data-testid="QueryTab_autocommitOffSwitch"
|
||||
hideDisabled
|
||||
/>
|
||||
<ToolStripCommandButton
|
||||
command="query.commitTransaction"
|
||||
data-testid="QueryTab_commitTransactionButton"
|
||||
|
||||
Reference in New Issue
Block a user