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">
|
2020-12-03 13:00:54 +01:00
|
|
|
<div class="context-element" @click="showCreateTableModal">
|
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>
|
2020-12-27 16:16:48 +01:00
|
|
|
<div 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-01-02 15:27:02 +01:00
|
|
|
<div 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-01-06 11:57:49 +01:00
|
|
|
<div 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-01-11 09:55:13 +01:00
|
|
|
<div 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-01-16 11:32:42 +01:00
|
|
|
<div 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>
|
2020-10-03 12:11:42 +02:00
|
|
|
<div 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"
|
2020-10-01 15:08:35 +02:00
|
|
|
@confirm="deleteDatabase"
|
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">
|
|
|
|
<i class="mdi mdi-24px mdi-database-remove mr-1" /> {{ $t('message.deleteDatabase') }}
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div slot="body">
|
|
|
|
<div class="mb-2">
|
|
|
|
{{ $t('message.deleteCorfirm') }} "<b>{{ selectedDatabase }}</b>"?
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ConfirmModal>
|
2020-10-03 12:11:42 +02:00
|
|
|
<ModalEditDatabase
|
|
|
|
v-if="isEditModal"
|
|
|
|
:selected-database="selectedDatabase"
|
|
|
|
@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';
|
2020-10-03 12:11:42 +02:00
|
|
|
import ModalEditDatabase from '@/components/ModalEditDatabase';
|
2020-10-01 15:08:35 +02:00
|
|
|
import Database from '@/ipc-api/Database';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'WorkspaceExploreBarDatabaseContext',
|
|
|
|
components: {
|
|
|
|
BaseContextMenu,
|
2020-10-03 12:11:42 +02:00
|
|
|
ConfirmModal,
|
|
|
|
ModalEditDatabase
|
2020-10-01 15:08:35 +02:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
contextEvent: MouseEvent,
|
|
|
|
selectedDatabase: String
|
|
|
|
},
|
|
|
|
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
|
|
|
}),
|
2020-12-03 13:00:54 +01:00
|
|
|
showCreateTableModal () {
|
|
|
|
this.$emit('show-create-table-modal');
|
|
|
|
},
|
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-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');
|
|
|
|
},
|
|
|
|
async deleteDatabase () {
|
|
|
|
try {
|
|
|
|
const { status, response } = await Database.deleteDatabase({
|
|
|
|
uid: this.selectedWorkspace,
|
|
|
|
database: this.selectedDatabase
|
|
|
|
});
|
|
|
|
|
|
|
|
if (status === 'success') {
|
2020-12-03 16:15:10 +01:00
|
|
|
if (this.selectedDatabase === this.workspace.breadcrumbs.schema)
|
|
|
|
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>
|