execute command disabled, when query has not connection

This commit is contained in:
Jan Prochazka
2021-05-06 09:43:32 +02:00
parent cd7edcb443
commit 0b8add848a
2 changed files with 10 additions and 1 deletions

View File

@@ -241,6 +241,7 @@ export function registerFileCommands({
toggleComment = false,
findReplace = false,
undoRedo = false,
executeAdditionalCondition = null,
}) {
if (save) {
registerCommand({
@@ -274,7 +275,10 @@ export function registerFileCommands({
toolbar: true,
isRelatedToTab: true,
keyText: 'F5 | Ctrl+Enter',
testEnabled: () => getCurrentEditor() != null && !getCurrentEditor()?.isBusy(),
testEnabled: () =>
getCurrentEditor() != null &&
!getCurrentEditor()?.isBusy() &&
(executeAdditionalCondition == null || executeAdditionalCondition()),
onClick: () => getCurrentEditor().execute(),
});
registerCommand({

View File

@@ -27,6 +27,7 @@
execute: true,
toggleComment: true,
findReplace: true,
executeAdditionalCondition: () => getCurrentEditor()?.hasConnection(),
});
</script>
@@ -121,6 +122,10 @@
return tabid;
}
export function hasConnection() {
return !!conid;
}
export async function execute() {
if (busy) return;
executeNumber++;