1
1
mirror of https://github.com/Fabio286/antares.git synced 2025-04-25 15:28:41 +02:00

perf(UI): hide edit/delete functions in readonly mode

This commit is contained in:
Fabio Di Stasio 2024-09-18 16:42:21 +02:00
parent 4df4c6197d
commit 37d44c95ee
3 changed files with 28 additions and 10 deletions

View File

@ -16,7 +16,7 @@
/> {{ t('general.run') }}</span> /> {{ t('general.run') }}</span>
</div> </div>
<div <div
v-if="selectedMisc.type === 'trigger' && customizations.triggerEnableDisable" v-if="selectedMisc.type === 'trigger' && customizations.triggerEnableDisable && !connection.readonly"
class="context-element" class="context-element"
@click="toggleTrigger" @click="toggleTrigger"
> >
@ -36,7 +36,7 @@
</span> </span>
</div> </div>
<div <div
v-if="selectedMisc.type === 'scheduler'" v-if="selectedMisc.type === 'scheduler' && !connection.readonly"
class="context-element" class="context-element"
@click="toggleScheduler" @click="toggleScheduler"
> >
@ -63,7 +63,11 @@
:size="18" :size="18"
/> {{ t('general.copyName') }}</span> /> {{ t('general.copyName') }}</span>
</div> </div>
<div class="context-element" @click="showDeleteModal"> <div
v-if="!connection.readonly"
class="context-element"
@click="showDeleteModal"
>
<span class="d-flex"> <span class="d-flex">
<BaseIcon <BaseIcon
class="text-light mt-1 mr-1" class="text-light mt-1 mr-1"
@ -117,6 +121,7 @@ import Routines from '@/ipc-api/Routines';
import Schedulers from '@/ipc-api/Schedulers'; import Schedulers from '@/ipc-api/Schedulers';
import Triggers from '@/ipc-api/Triggers'; import Triggers from '@/ipc-api/Triggers';
import { copyText } from '@/libs/copyText'; import { copyText } from '@/libs/copyText';
import { useConnectionsStore } from '@/stores/connections';
import { useNotificationsStore } from '@/stores/notifications'; import { useNotificationsStore } from '@/stores/notifications';
import { useWorkspacesStore } from '@/stores/workspaces'; import { useWorkspacesStore } from '@/stores/workspaces';
@ -132,6 +137,7 @@ const emit = defineEmits(['close-context', 'reload']);
const { addNotification } = useNotificationsStore(); const { addNotification } = useNotificationsStore();
const workspacesStore = useWorkspacesStore(); const workspacesStore = useWorkspacesStore();
const { getConnectionByUid } = useConnectionsStore();
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore); const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
@ -154,6 +160,7 @@ const workspace = computed(() => {
const customizations = computed(() => { const customizations = computed(() => {
return getWorkspace(selectedWorkspace.value).customizations; return getWorkspace(selectedWorkspace.value).customizations;
}); });
const connection = computed(() => getConnectionByUid(selectedWorkspace.value));
const deleteMessage = computed(() => { const deleteMessage = computed(() => {
switch (props.selectedMisc.type) { switch (props.selectedMisc.type) {

View File

@ -3,7 +3,7 @@
:context-event="contextEvent" :context-event="contextEvent"
@close-context="closeContext" @close-context="closeContext"
> >
<div class="context-element"> <div v-if="!connection.readonly" class="context-element">
<span class="d-flex"> <span class="d-flex">
<BaseIcon <BaseIcon
class="text-light mt-1 mr-1" class="text-light mt-1 mr-1"
@ -135,7 +135,7 @@
/> {{ t('database.export') }}</span> /> {{ t('database.export') }}</span>
</div> </div>
<div <div
v-if="workspace.customizations.schemaImport" v-if="workspace.customizations.schemaImport && !connection.readonly"
class="context-element" class="context-element"
@click="initImport" @click="initImport"
> >
@ -147,7 +147,7 @@
/> {{ t('database.import') }}</span> /> {{ t('database.import') }}</span>
</div> </div>
<div <div
v-if="workspace.customizations.schemaEdit" v-if="workspace.customizations.schemaEdit && !connection.readonly"
class="context-element" class="context-element"
@click="showEditModal" @click="showEditModal"
> >
@ -159,7 +159,7 @@
/> {{ t('database.editSchema') }}</span> /> {{ t('database.editSchema') }}</span>
</div> </div>
<div <div
v-if="workspace.customizations.schemaDrop" v-if="workspace.customizations.schemaDrop && !connection.readonly"
class="context-element" class="context-element"
@click="showDeleteModal" @click="showDeleteModal"
> >
@ -219,6 +219,7 @@ import ModalImportSchema from '@/components/ModalImportSchema.vue';
import Application from '@/ipc-api/Application'; import Application from '@/ipc-api/Application';
import Schema from '@/ipc-api/Schema'; import Schema from '@/ipc-api/Schema';
import { copyText } from '@/libs/copyText'; import { copyText } from '@/libs/copyText';
import { useConnectionsStore } from '@/stores/connections';
import { useNotificationsStore } from '@/stores/notifications'; import { useNotificationsStore } from '@/stores/notifications';
import { useSchemaExportStore } from '@/stores/schemaExport'; import { useSchemaExportStore } from '@/stores/schemaExport';
import { useWorkspacesStore } from '@/stores/workspaces'; import { useWorkspacesStore } from '@/stores/workspaces';
@ -248,7 +249,9 @@ const workspacesStore = useWorkspacesStore();
const schemaExportStore = useSchemaExportStore(); const schemaExportStore = useSchemaExportStore();
const { showExportModal } = schemaExportStore; const { showExportModal } = schemaExportStore;
const connectionsStore = useConnectionsStore();
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore); const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
const { getConnectionByUid } = connectionsStore;
const { const {
getWorkspace, getWorkspace,
@ -261,6 +264,7 @@ const isEditModal = ref(false);
const isImportSchemaModal = ref(false); const isImportSchemaModal = ref(false);
const workspace = computed(() => getWorkspace(selectedWorkspace.value)); const workspace = computed(() => getWorkspace(selectedWorkspace.value));
const connection = computed(() => getConnectionByUid(selectedWorkspace.value));
const openCreateTableTab = () => { const openCreateTableTab = () => {
emit('open-create-table-tab'); emit('open-create-table-tab');

View File

@ -60,7 +60,7 @@
/> {{ t('application.settings') }}</span> /> {{ t('application.settings') }}</span>
</div> </div>
<div <div
v-if="selectedTable && selectedTable.type === 'table' && customizations.tableDuplicate" v-if="selectedTable && selectedTable.type === 'table' && customizations.tableDuplicate && !connection.readonly"
class="context-element" class="context-element"
@click="duplicateTable" @click="duplicateTable"
> >
@ -72,7 +72,7 @@
/> {{ t('database.duplicateTable') }}</span> /> {{ t('database.duplicateTable') }}</span>
</div> </div>
<div <div
v-if="selectedTable && selectedTable.type === 'table'" v-if="selectedTable && selectedTable.type === 'table' && !connection.readonly"
class="context-element" class="context-element"
@click="showEmptyModal" @click="showEmptyModal"
> >
@ -83,7 +83,11 @@
:size="18" :size="18"
/> {{ t('database.emptyTable') }}</span> /> {{ t('database.emptyTable') }}</span>
</div> </div>
<div class="context-element" @click="showDeleteModal"> <div
v-if="!connection.readonly"
class="context-element"
@click="showDeleteModal"
>
<span class="d-flex"> <span class="d-flex">
<BaseIcon <BaseIcon
class="text-light mt-1 mr-1" class="text-light mt-1 mr-1"
@ -151,6 +155,7 @@ import BaseContextMenu from '@/components/BaseContextMenu.vue';
import BaseIcon from '@/components/BaseIcon.vue'; import BaseIcon from '@/components/BaseIcon.vue';
import Tables from '@/ipc-api/Tables'; import Tables from '@/ipc-api/Tables';
import { copyText } from '@/libs/copyText'; import { copyText } from '@/libs/copyText';
import { useConnectionsStore } from '@/stores/connections';
import { useNotificationsStore } from '@/stores/notifications'; import { useNotificationsStore } from '@/stores/notifications';
import { useSchemaExportStore } from '@/stores/schemaExport'; import { useSchemaExportStore } from '@/stores/schemaExport';
import { useWorkspacesStore } from '@/stores/workspaces'; import { useWorkspacesStore } from '@/stores/workspaces';
@ -168,6 +173,7 @@ const emit = defineEmits(['close-context', 'duplicate-table', 'reload', 'delete-
const { addNotification } = useNotificationsStore(); const { addNotification } = useNotificationsStore();
const workspacesStore = useWorkspacesStore(); const workspacesStore = useWorkspacesStore();
const { showExportModal } = useSchemaExportStore(); const { showExportModal } = useSchemaExportStore();
const { getConnectionByUid } = useConnectionsStore();
const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore); const { getSelected: selectedWorkspace } = storeToRefs(workspacesStore);
@ -185,6 +191,7 @@ const forceTruncate = ref(false);
const workspace = computed(() => getWorkspace(selectedWorkspace.value)); const workspace = computed(() => getWorkspace(selectedWorkspace.value));
const customizations = computed(() => workspace.value && workspace.value.customizations ? workspace.value.customizations : null); const customizations = computed(() => workspace.value && workspace.value.customizations ? workspace.value.customizations : null);
const connection = computed(() => getConnectionByUid(selectedWorkspace.value));
const showTableExportModal = () => { const showTableExportModal = () => {
showExportModal(props.selectedSchema, props.selectedTable.name); showExportModal(props.selectedSchema, props.selectedTable.name);