2020-10-01 15:08:35 +02:00
|
|
|
<template>
|
|
|
|
<BaseContextMenu
|
|
|
|
:context-event="contextEvent"
|
|
|
|
@close-context="closeContext"
|
|
|
|
>
|
2020-11-16 17:16:39 +01:00
|
|
|
<div class="context-element">
|
2020-10-01 15:08:35 +02:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-plus text-light pr-1" /> {{ $t('word.add') }}</span>
|
|
|
|
<i class="mdi mdi-18px mdi-chevron-right text-light pl-1" />
|
2020-12-01 16:48:20 +01:00
|
|
|
<div class="context-submenu">
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.tableAdd"
|
|
|
|
class="context-element"
|
2021-08-13 16:50:59 +02:00
|
|
|
@click="openCreateTableTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2020-12-01 16:48:20 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table text-light pr-1" /> {{ $t('word.table') }}</span>
|
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.viewAdd"
|
|
|
|
class="context-element"
|
2021-08-18 17:28:41 +02:00
|
|
|
@click="openCreateViewTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2020-12-26 15:37:34 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table-eye text-light pr-1" /> {{ $t('word.view') }}</span>
|
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.triggerAdd"
|
|
|
|
class="context-element"
|
2021-09-02 18:08:23 +02:00
|
|
|
@click="openCreateTriggerTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2020-12-31 19:55:02 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-table-cog text-light pr-1" /> {{ $tc('word.trigger', 1) }}</span>
|
2020-12-26 15:37:34 +01:00
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.routineAdd"
|
|
|
|
class="context-element"
|
2021-09-06 17:29:34 +02:00
|
|
|
@click="openCreateRoutineTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2021-01-05 17:25:18 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-sync-circle pr-1" /> {{ $tc('word.storedRoutine', 1) }}</span>
|
2020-12-26 15:37:34 +01:00
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.functionAdd"
|
|
|
|
class="context-element"
|
2021-09-07 18:20:45 +02:00
|
|
|
@click="openCreateFunctionTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2021-01-05 17:25:18 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-arrow-right-bold-box pr-1" /> {{ $tc('word.function', 1) }}</span>
|
|
|
|
</div>
|
2021-07-03 11:29:14 +02:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.triggerFunctionAdd"
|
|
|
|
class="context-element"
|
2021-09-11 10:24:21 +02:00
|
|
|
@click="openCreateTriggerFunctionTab"
|
2021-07-03 11:29:14 +02:00
|
|
|
>
|
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-cog-clockwise pr-1" /> {{ $tc('word.triggerFunction', 1) }}</span>
|
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.schedulerAdd"
|
|
|
|
class="context-element"
|
2021-09-10 18:23:32 +02:00
|
|
|
@click="openCreateSchedulerTab"
|
2021-03-16 18:42:03 +01:00
|
|
|
>
|
2020-12-31 19:55:02 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-calendar-clock text-light pr-1" /> {{ $tc('word.scheduler', 1) }}</span>
|
2020-12-26 15:37:34 +01:00
|
|
|
</div>
|
2020-12-01 16:48:20 +01:00
|
|
|
</div>
|
2020-11-16 17:16:39 +01:00
|
|
|
</div>
|
2021-10-29 12:58:37 +02:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.schemaExport"
|
|
|
|
class="context-element"
|
|
|
|
@click="showExportSchemaModal"
|
|
|
|
>
|
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-database-arrow-down text-light pr-1" /> {{ $t('word.export') }}</span>
|
|
|
|
</div>
|
2021-03-16 18:42:03 +01:00
|
|
|
<div
|
|
|
|
v-if="workspace.customizations.schemaEdit"
|
|
|
|
class="context-element"
|
|
|
|
@click="showEditModal"
|
|
|
|
>
|
2020-12-03 16:15:10 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-database-edit text-light pr-1" /> {{ $t('word.edit') }}</span>
|
2020-10-01 15:08:35 +02:00
|
|
|
</div>
|
2020-10-03 12:11:42 +02:00
|
|
|
<div class="context-element" @click="showDeleteModal">
|
2020-12-03 16:15:10 +01:00
|
|
|
<span class="d-flex"><i class="mdi mdi-18px mdi-database-remove text-light pr-1" /> {{ $t('word.delete') }}</span>
|
2020-10-01 15:08:35 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<ConfirmModal
|
2020-10-03 12:11:42 +02:00
|
|
|
v-if="isDeleteModal"
|
2021-03-16 18:42:03 +01:00
|
|
|
@confirm="deleteSchema"
|
2020-10-03 12:11:42 +02:00
|
|
|
@hide="hideDeleteModal"
|
2020-10-01 15:08:35 +02:00
|
|
|
>
|
|
|
|
<template slot="header">
|
|
|
|
<div class="d-flex">
|
2021-06-13 11:16:21 +02:00
|
|
|
<i class="mdi mdi-24px mdi-database-remove mr-1" />
|
|
|
|
<span class="cut-text">{{ $t('message.deleteSchema') }}</span>
|
2020-10-01 15:08:35 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div slot="body">
|
|
|
|
<div class="mb-2">
|
2021-07-14 18:15:13 +02:00
|
|
|
{{ $t('message.deleteCorfirm') }} "<b>{{ selectedSchema }}</b>"?
|
2020-10-01 15:08:35 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ConfirmModal>
|
2021-03-17 11:15:14 +01:00
|
|
|
<ModalEditSchema
|
2020-10-03 12:11:42 +02:00
|
|
|
v-if="isEditModal"
|
2021-07-14 18:15:13 +02:00
|
|
|
:selected-schema="selectedSchema"
|
2020-10-03 12:11:42 +02:00
|
|
|
@close="hideEditModal"
|
|
|
|
/>
|
2021-10-29 12:58:37 +02:00
|
|
|
<ModalExportSchema
|
|
|
|
v-if="isExportSchemaModal"
|
|
|
|
:selected-schema="selectedSchema"
|
|
|
|
@close="hideExportSchemaModal"
|
|
|
|
/>
|
2020-10-01 15:08:35 +02:00
|
|
|
</BaseContextMenu>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { mapGetters, mapActions } from 'vuex';
|
|
|
|
import BaseContextMenu from '@/components/BaseContextMenu';
|
|
|
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
2021-03-17 11:15:14 +01:00
|
|
|
import ModalEditSchema from '@/components/ModalEditSchema';
|
2021-10-29 12:58:37 +02:00
|
|
|
import ModalExportSchema from '@/components/ModalExportSchema';
|
2021-03-17 11:15:14 +01:00
|
|
|
import Schema from '@/ipc-api/Schema';
|
2020-10-01 15:08:35 +02:00
|
|
|
|
|
|
|
export default {
|
2021-03-17 11:15:14 +01:00
|
|
|
name: 'WorkspaceExploreBarSchemaContext',
|
2020-10-01 15:08:35 +02:00
|
|
|
components: {
|
|
|
|
BaseContextMenu,
|
2020-10-03 12:11:42 +02:00
|
|
|
ConfirmModal,
|
2021-10-29 12:58:37 +02:00
|
|
|
ModalEditSchema,
|
|
|
|
ModalExportSchema
|
2020-10-01 15:08:35 +02:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
contextEvent: MouseEvent,
|
2021-07-14 18:15:13 +02:00
|
|
|
selectedSchema: String
|
2020-10-01 15:08:35 +02:00
|
|
|
},
|
|
|
|
data () {
|
|
|
|
return {
|
2020-10-03 12:11:42 +02:00
|
|
|
isDeleteModal: false,
|
2021-10-29 12:58:37 +02:00
|
|
|
isEditModal: false,
|
|
|
|
isExportSchemaModal: false
|
2020-10-01 15:08:35 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
2020-12-03 16:15:10 +01:00
|
|
|
selectedWorkspace: 'workspaces/getSelected',
|
|
|
|
getWorkspace: 'workspaces/getWorkspace'
|
|
|
|
}),
|
|
|
|
workspace () {
|
|
|
|
return this.getWorkspace(this.selectedWorkspace);
|
|
|
|
}
|
2020-10-01 15:08:35 +02:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions({
|
2020-12-03 16:15:10 +01:00
|
|
|
addNotification: 'notifications/addNotification',
|
|
|
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
2020-10-01 15:08:35 +02:00
|
|
|
}),
|
2021-08-13 16:50:59 +02:00
|
|
|
openCreateTableTab () {
|
|
|
|
this.$emit('open-create-table-tab');
|
2020-12-03 13:00:54 +01:00
|
|
|
},
|
2021-08-18 17:28:41 +02:00
|
|
|
openCreateViewTab () {
|
|
|
|
this.$emit('open-create-view-tab');
|
2020-12-27 16:16:48 +01:00
|
|
|
},
|
2021-09-02 18:08:23 +02:00
|
|
|
openCreateTriggerTab () {
|
|
|
|
this.$emit('open-create-trigger-tab');
|
2021-01-02 15:27:02 +01:00
|
|
|
},
|
2021-09-06 17:29:34 +02:00
|
|
|
openCreateRoutineTab () {
|
|
|
|
this.$emit('open-create-routine-tab');
|
2021-01-06 11:57:49 +01:00
|
|
|
},
|
2021-09-07 18:20:45 +02:00
|
|
|
openCreateFunctionTab () {
|
|
|
|
this.$emit('open-create-function-tab');
|
2021-01-11 09:55:13 +01:00
|
|
|
},
|
2021-09-11 10:24:21 +02:00
|
|
|
openCreateTriggerFunctionTab () {
|
|
|
|
this.$emit('open-create-trigger-function-tab');
|
2021-07-03 11:29:14 +02:00
|
|
|
},
|
2021-09-10 18:23:32 +02:00
|
|
|
openCreateSchedulerTab () {
|
|
|
|
this.$emit('open-create-scheduler-tab');
|
2021-01-16 11:32:42 +01:00
|
|
|
},
|
2020-10-03 12:11:42 +02:00
|
|
|
showDeleteModal () {
|
|
|
|
this.isDeleteModal = true;
|
2020-10-01 15:08:35 +02:00
|
|
|
},
|
2020-10-03 12:11:42 +02:00
|
|
|
hideDeleteModal () {
|
|
|
|
this.isDeleteModal = false;
|
|
|
|
},
|
|
|
|
showEditModal () {
|
|
|
|
this.isEditModal = true;
|
|
|
|
},
|
|
|
|
hideEditModal () {
|
|
|
|
this.isEditModal = false;
|
|
|
|
this.closeContext();
|
2020-10-01 15:08:35 +02:00
|
|
|
},
|
2021-10-29 12:58:37 +02:00
|
|
|
showExportSchemaModal () {
|
|
|
|
this.isExportSchemaModal = true;
|
|
|
|
},
|
|
|
|
hideExportSchemaModal () {
|
|
|
|
this.isExportSchemaModal = false;
|
|
|
|
},
|
2020-10-01 15:08:35 +02:00
|
|
|
closeContext () {
|
|
|
|
this.$emit('close-context');
|
|
|
|
},
|
2021-03-16 18:42:03 +01:00
|
|
|
async deleteSchema () {
|
2020-10-01 15:08:35 +02:00
|
|
|
try {
|
2021-03-17 11:15:14 +01:00
|
|
|
const { status, response } = await Schema.deleteSchema({
|
2020-10-01 15:08:35 +02:00
|
|
|
uid: this.selectedWorkspace,
|
2021-07-14 18:15:13 +02:00
|
|
|
database: this.selectedSchema
|
2020-10-01 15:08:35 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if (status === 'success') {
|
2021-07-14 18:15:13 +02:00
|
|
|
if (this.selectedSchema === this.workspace.breadcrumbs.schema)
|
2020-12-03 16:15:10 +01:00
|
|
|
this.changeBreadcrumbs({ schema: null });
|
|
|
|
|
2020-10-01 15:08:35 +02:00
|
|
|
this.closeContext();
|
|
|
|
this.$emit('reload');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
this.addNotification({ status: 'error', message: response });
|
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
this.addNotification({ status: 'error', message: err.stack });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
2020-12-26 15:37:34 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.context-submenu {
|
|
|
|
min-width: 150px !important;
|
|
|
|
}
|
|
|
|
</style>
|