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"
|
|
|
|
@click="showCreateViewModal"
|
|
|
|
>
|
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"
|
|
|
|
@click="showCreateTriggerModal"
|
|
|
|
>
|
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"
|
|
|
|
@click="showCreateRoutineModal"
|
|
|
|
>
|
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"
|
|
|
|
@click="showCreateFunctionModal"
|
|
|
|
>
|
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"
|
|
|
|
@click="showCreateTriggerFunctionModal"
|
|
|
|
>
|
|
|
|
<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"
|
|
|
|
@click="showCreateSchedulerModal"
|
|
|
|
>
|
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-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"
|
|
|
|
/>
|
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';
|
|
|
|
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-03-17 11:15:14 +01:00
|
|
|
ModalEditSchema
|
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,
|
|
|
|
isEditModal: 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
|
|
|
},
|
2020-12-27 16:16:48 +01:00
|
|
|
showCreateViewModal () {
|
|
|
|
this.$emit('show-create-view-modal');
|
|
|
|
},
|
2021-01-02 15:27:02 +01:00
|
|
|
showCreateTriggerModal () {
|
|
|
|
this.$emit('show-create-trigger-modal');
|
|
|
|
},
|
2021-01-06 11:57:49 +01:00
|
|
|
showCreateRoutineModal () {
|
|
|
|
this.$emit('show-create-routine-modal');
|
|
|
|
},
|
2021-01-11 09:55:13 +01:00
|
|
|
showCreateFunctionModal () {
|
|
|
|
this.$emit('show-create-function-modal');
|
|
|
|
},
|
2021-07-03 11:29:14 +02:00
|
|
|
showCreateTriggerFunctionModal () {
|
|
|
|
this.$emit('show-create-trigger-function-modal');
|
|
|
|
},
|
2021-01-16 11:32:42 +01:00
|
|
|
showCreateSchedulerModal () {
|
|
|
|
this.$emit('show-create-scheduler-modal');
|
|
|
|
},
|
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
|
|
|
},
|
|
|
|
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>
|