Skip to content

Commit 14aeebe

Browse files
committed
feat(UI): new context menu and some minor improvements to query tabs, closes #867
1 parent 7969294 commit 14aeebe

File tree

7 files changed

+105
-19
lines changed

7 files changed

+105
-19
lines changed

src/renderer/App.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,11 @@ onMounted(() => {
141141
142142
while (node) {
143143
if (node.nodeName.match(/^(input|textarea)$/i) || node.isContentEditable) {
144-
InputMenu.popup({ window: getCurrentWindow() });
145-
break;
144+
if (!node.parentNode.className.split(' ').includes('editor-query')) {
145+
InputMenu.popup({ window: getCurrentWindow() });
146+
console.log(node.parentNode.className);
147+
break;
148+
}
146149
}
147150
node = node.parentNode;
148151
}

src/renderer/components/ModalSettings.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ const otherContributors = computed(() => {
612612
return contributors
613613
.split(',')
614614
.filter(c => !c.includes(appAuthor))
615-
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
615+
.sort((a, b) => a.toLowerCase().trim().localeCompare(b.toLowerCase()));
616616
});
617617
618618
const selectTab = (tab: string) => {

src/renderer/components/QueryEditor.vue

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<div
44
:id="`editor-${id}`"
55
class="editor"
6+
:class="editorClasses"
67
:style="{height: `${height}px`}"
78
/>
89
</div>
@@ -54,7 +55,8 @@ const props = defineProps({
5455
schema: { type: String, default: '' },
5556
autoFocus: { type: Boolean, default: false },
5657
readOnly: { type: Boolean, default: false },
57-
height: { type: Number, default: 200 }
58+
height: { type: Number, default: 200 },
59+
editorClasses: { type: String, default: '' }
5860
});
5961
6062
const emit = defineEmits(['update:modelValue']);
@@ -405,18 +407,17 @@ defineExpose({ editor });
405407
406408
.ace_gutter-cell.ace_breakpoint {
407409
&::before {
408-
content: '\F0403';
410+
content: '';
409411
position: absolute;
410-
left: 3px;
411-
top: 2px;
412-
color: var(--primary-color);
412+
left: 0px;
413+
top: 8px;
413414
display: inline-block;
414-
font: normal normal normal 24px/1 "Material Design Icons", sans-serif;
415-
font-size: inherit;
416-
text-rendering: auto;
417-
line-height: inherit;
418-
-webkit-font-smoothing: antialiased;
419-
-moz-osx-font-smoothing: grayscale;
415+
width: 0;
416+
height: 0;
417+
border-left: 8px solid transparent;
418+
border-top: 8px solid transparent;
419+
border-right: 8px solid var(--primary-color);
420+
transform: rotate(-45deg);
420421
}
421422
}
422423
</style>

src/renderer/components/WorkspaceTabQuery.vue

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
:schema="breadcrumbsSchema"
1616
:is-selected="isSelected"
1717
:height="editorHeight"
18+
editor-classes="editor-query"
1819
/>
1920
<div ref="resizer" class="query-area-resizer" />
2021
<div ref="queryAreaFooter" class="workspace-query-runner-footer">
@@ -273,6 +274,7 @@
273274
</template>
274275

275276
<script setup lang="ts">
277+
import { getCurrentWindow, Menu } from '@electron/remote';
276278
import { Ace } from 'ace-builds';
277279
import { ConnectionParams } from 'common/interfaces/antares';
278280
import { uidGen } from 'common/libs/uidGen';
@@ -475,6 +477,8 @@ const runQuery = async (query: string) => {
475477
saveHistory(params);
476478
if (!autocommit.value)
477479
setUnsavedChanges({ uid: props.connection.uid, tUid: props.tabUid, isChanged: true });
480+
481+
queryEditor.value.editor.focus();
478482
}
479483
else
480484
addNotification({ status: 'error', message: response });
@@ -739,7 +743,11 @@ const openFile = async () => {
739743
740744
const saveFileAs = async () => {
741745
// eslint-disable-next-line @typescript-eslint/no-explicit-any
742-
const result: any = await Application.showSaveDialog({ filters: [{ name: 'SQL', extensions: ['sql'] }], defaultPath: `${queryName.value || 'query'}.sql` });
746+
const result: any = await Application.showSaveDialog({
747+
filters: [{ name: 'SQL', extensions: ['sql'] }],
748+
defaultPath: (!queryName.value.includes('.sql') ? `${queryName.value}.sql` :queryName.value) || 'query.sql'
749+
});
750+
743751
if (result && !result.canceled) {
744752
await Application.writeFile(result.filePath, query.value);
745753
addNotification({ status: 'success', message: t('general.actionSuccessful', { action: t('application.saveFile') }) });
@@ -750,9 +758,13 @@ const saveFileAs = async () => {
750758
};
751759
752760
const saveFile = async () => {
753-
await Application.writeFile(filePath.value, query.value);
754-
addNotification({ status: 'success', message: t('general.actionSuccessful', { action: t('application.saveFile') }) });
755-
lastSavedQuery.value = toRaw(query.value);
761+
if (filePath.value) {
762+
await Application.writeFile(filePath.value, query.value);
763+
addNotification({ status: 'success', message: t('general.actionSuccessful', { action: t('application.saveFile') }) });
764+
lastSavedQuery.value = toRaw(query.value);
765+
}
766+
else
767+
saveFileAs();
756768
};
757769
758770
const loadFileContent = async (file: string) => {
@@ -785,6 +797,67 @@ onMounted(() => {
785797
786798
if (props.tab.filePath)
787799
loadFileContent(props.tab.filePath);
800+
801+
queryEditor.value.editor.container.addEventListener('contextmenu', (e) => {
802+
const InputMenu = Menu.buildFromTemplate([
803+
{
804+
label: t('general.run'),
805+
click: () => runQuery(query.value)
806+
},
807+
{
808+
label: t('general.clear'),
809+
click: () => clear()
810+
},
811+
{
812+
type: 'separator'
813+
},
814+
{
815+
label: t('application.saveFile'),
816+
click: () => saveFile()
817+
},
818+
{
819+
label: t('application.saveFileAs'),
820+
click: () => saveFileAs()
821+
},
822+
{
823+
label: t('application.openFile'),
824+
click: () => openFile()
825+
},
826+
{
827+
type: 'separator'
828+
},
829+
{
830+
label: t('general.cut'),
831+
role: 'cut'
832+
},
833+
{
834+
label: t('general.copy'),
835+
role: 'copy'
836+
},
837+
{
838+
label: t('general.paste'),
839+
role: 'paste'
840+
},
841+
{
842+
type: 'separator'
843+
},
844+
{
845+
label: t('general.selectAll'),
846+
role: 'selectAll'
847+
}
848+
]);
849+
e.preventDefault();
850+
851+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
852+
let node: any = e.target;
853+
while (node) {
854+
if (node.nodeName.match(/^(input|textarea)$/i) || node.isContentEditable) {
855+
InputMenu.popup({ window: getCurrentWindow() });
856+
break;
857+
}
858+
node = node.parentNode;
859+
}
860+
});
788861
});
789862
790863
onBeforeUnmount(() => {

src/renderer/i18n/supported-locales.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const localesNames: Record<string, string> = {
99
'vi-VN': 'Tiếng Việt',
1010
'ja-JP': '日本語',
1111
'zh-CN': '简体中文',
12-
'zh-TW': '繁體中文',
12+
'zh-TW': '正體中文',
1313
'ru-RU': 'Русский',
1414
'id-ID': 'Bahasa Indonesia',
1515
'ko-KR': '한국어',

src/renderer/scss/main.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,10 @@ option:checked {
256256
}
257257

258258
&.active {
259+
a {
260+
border-bottom-color: transparent;
261+
}
262+
259263
.tab-link {
260264
border-color: transparent;
261265
}

src/renderer/scss/themes/dark-theme.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@
255255
}
256256
}
257257

258+
259+
&.result-tabs .tab-item {
260+
background: transparent;
261+
}
262+
258263
.workspace-query-runner .workspace-query-runner-footer .workspace-query-buttons .btn {
259264
color: $body-font-color-dark;
260265
}

0 commit comments

Comments
 (0)