antares/src/renderer/components/WorkspaceExploreBarDatabase...

118 lines
3.5 KiB
Vue
Raw Normal View History

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">
<div class="context-element">
<span class="d-flex"><i class="mdi mdi-18px mdi-table text-light pr-1" /> {{ $t('word.table') }}</span>
</div>
</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-10-01 15:08:35 +02:00
<span class="d-flex"><i class="mdi mdi-18px mdi-pencil text-light pr-1" /> {{ $t('word.edit') }}</span>
</div>
2020-10-03 12:11:42 +02:00
<div class="context-element" @click="showDeleteModal">
2020-10-01 15:08:35 +02:00
<span class="d-flex"><i class="mdi mdi-18px mdi-delete text-light pr-1" /> {{ $t('word.delete') }}</span>
</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({
selectedWorkspace: 'workspaces/getSelected'
})
},
methods: {
...mapActions({
deleteConnection: 'connections/deleteConnection',
showEditModal: 'application/showEditConnModal',
addNotification: 'notifications/addNotification'
}),
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') {
this.closeContext();
this.$emit('reload');
}
else
this.addNotification({ status: 'error', message: response });
}
catch (err) {
this.addNotification({ status: 'error', message: err.stack });
}
}
}
};
</script>