mirror of
https://github.com/Fabio286/antares.git
synced 2025-03-15 10:50:04 +01:00
feat: dynamic shortcut suggestions on empty query tabs
This commit is contained in:
parent
c05be8304f
commit
4df14c3693
@ -1,19 +1,19 @@
|
||||
export const shortcutEvents: { [key: string]: { l18n: string; l18nParam?: string | number; context?: 'tab' }} = {
|
||||
'run-or-reload': { l18n: 'message.runOrReload', context: 'tab' },
|
||||
'open-new-tab': { l18n: 'message.openNewTab', context: 'tab' },
|
||||
'close-tab': { l18n: 'message.closeTab', context: 'tab' },
|
||||
'next-tab': { l18n: 'message.nextTab', context: 'tab' },
|
||||
'prev-tab': { l18n: 'message.previousTab', context: 'tab' },
|
||||
'format-query': { l18n: 'message.formatQuery', context: 'tab' },
|
||||
'kill-query': { l18n: 'message.killQuery', context: 'tab' },
|
||||
'query-history': { l18n: 'message.queryHistory', context: 'tab' },
|
||||
'clear-query': { l18n: 'message.clearQuery', context: 'tab' },
|
||||
'next-tab': { l18n: 'message.nextTab' },
|
||||
'prev-tab': { l18n: 'message.previousTab' },
|
||||
'open-all-connections': { l18n: 'message.openAllConnections' },
|
||||
'open-filter': { l18n: 'message.openFilter' },
|
||||
'next-page': { l18n: 'message.nextResultsPage' },
|
||||
'prev-page': { l18n: 'message.previousResultsPage' },
|
||||
'toggle-console': { l18n: 'message.toggleConsole' },
|
||||
'save-content': { l18n: 'message.saveContent' },
|
||||
'run-or-reload': { l18n: 'message.runOrReload' },
|
||||
'create-connection': { l18n: 'message.createNewConnection' },
|
||||
'open-settings': { l18n: 'message.openSettings' },
|
||||
'open-scratchpad': { l18n: 'message.openScratchpad' }
|
||||
|
@ -172,6 +172,9 @@ import { shortcutEvents, ShortcutRecord } from 'common/shortcuts';
|
||||
import ConfirmModal from '@/components/BaseConfirmModal.vue';
|
||||
import BaseSelect from '@/components/BaseSelect.vue';
|
||||
import { computed } from '@vue/reactivity';
|
||||
import { useFilters } from '@/composables/useFilters';
|
||||
|
||||
const { parseKeys } = useFilters();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@ -202,17 +205,6 @@ const eventOptions = computed(() => {
|
||||
});
|
||||
});
|
||||
|
||||
const parseKeys = (keys: {[key: number]: string}[]) => {
|
||||
return (keys as string[]).map(k => (
|
||||
k.split('+')
|
||||
.map(sk => (
|
||||
`<code class="text-bold">${sk}</code>`
|
||||
)))
|
||||
.join('+')
|
||||
.replaceAll('CommandOrControl', isMacOS ? 'Command' : 'Control')
|
||||
).join(', ');
|
||||
};
|
||||
|
||||
const restoreDefaults = () => {
|
||||
isConfirmRestoreModal.value = false;
|
||||
return Application.restoreDefaultShortcuts();
|
||||
|
@ -2,49 +2,21 @@
|
||||
<div class="container">
|
||||
<div class="columns">
|
||||
<div class="column col-16 text-right">
|
||||
<div class="mb-4">
|
||||
{{ t('message.runQuery') }}
|
||||
</div>
|
||||
<div v-if="customizations.cancelQueries" class="mb-4">
|
||||
{{ t('message.killQuery') }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
{{ t('word.format') }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
{{ t('word.clear') }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
{{ t('word.history') }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
{{ t('message.openNewTab') }}
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
{{ t('message.closeTab') }}
|
||||
<div
|
||||
v-for="(shortcut, i) in tabShortcuts"
|
||||
:key="i"
|
||||
class="mb-4"
|
||||
>
|
||||
{{ t(shortcutEvents[shortcut.event].l18n, {param: shortcutEvents[shortcut.event].l18nParam}) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="column col-16">
|
||||
<div class="mb-4">
|
||||
<code>F5</code>
|
||||
</div>
|
||||
<div v-if="customizations.cancelQueries" class="mb-4">
|
||||
<code>CTRL</code> + <code>K</code>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<code>CTRL</code> + <code>B</code>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<code>CTRL</code> + <code>ALT</code> + <code>W</code>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<code>CTRL</code> + <code>G</code>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<code>CTRL</code> + <code>T</code>
|
||||
</div>
|
||||
<div class="mb-4">
|
||||
<code>CTRL</code> + <code>W</code>
|
||||
<div
|
||||
v-for="(shortcut, i) in tabShortcuts"
|
||||
:key="i"
|
||||
class="mb-4"
|
||||
>
|
||||
<span v-html="parseKeys(shortcut.keys)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -52,12 +24,22 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useSettingsStore } from '@/stores/settings';
|
||||
import { shortcutEvents } from 'common/shortcuts';
|
||||
import { useFilters } from '@/composables/useFilters';
|
||||
|
||||
const { parseKeys } = useFilters();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
defineProps({
|
||||
customizations: Object
|
||||
const settingsStore = useSettingsStore();
|
||||
const { shortcuts } = storeToRefs(settingsStore);
|
||||
|
||||
const tabShortcuts = computed(() => {
|
||||
return shortcuts.value.filter(s => shortcutEvents[s.event].context === 'tab');
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -28,11 +28,24 @@ export function useFilters () {
|
||||
return `(${num})`;
|
||||
};
|
||||
|
||||
const parseKeys = (keys: {[key: number]: string}[]) => {
|
||||
const isMacOS = process.platform === 'darwin';
|
||||
return (keys as string[]).map(k => (
|
||||
k.split('+')
|
||||
.map(sk => (
|
||||
`<code class="text-bold">${sk}</code>`
|
||||
)))
|
||||
.join('+')
|
||||
.replaceAll('CommandOrControl', isMacOS ? 'Command' : 'Control')
|
||||
).join(', ');
|
||||
};
|
||||
|
||||
return {
|
||||
cutText,
|
||||
formatDate,
|
||||
wrapNumber,
|
||||
lastPart,
|
||||
localeString
|
||||
localeString,
|
||||
parseKeys
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user