-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
171 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
src/renderer/components/WorkspaceExploreBarMiscContext.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
<template> | ||
<BaseContextMenu | ||
:context-event="contextEvent" | ||
@close-context="closeContext" | ||
> | ||
<div | ||
v-if="selectedMisc.type === 'table'" | ||
class="context-element" | ||
@click="showEmptyModal" | ||
> | ||
<span class="d-flex"><i class="mdi mdi-18px mdi-table-off text-light pr-1" /> {{ $t('message.emptyTable') }}</span> | ||
</div> | ||
<div class="context-element" @click="showDeleteModal"> | ||
<span class="d-flex"><i class="mdi mdi-18px mdi-table-remove text-light pr-1" /> {{ $t('word.delete') }}</span> | ||
</div> | ||
<ConfirmModal | ||
v-if="isDeleteModal" | ||
@confirm="deleteMisc" | ||
@hide="hideDeleteModal" | ||
> | ||
<template slot="header"> | ||
<div class="d-flex"> | ||
<i class="mdi mdi-24px mdi-delete mr-1" /> {{ deleteMessage }} | ||
</div> | ||
</template> | ||
<div slot="body"> | ||
<div class="mb-2"> | ||
{{ $t('message.deleteCorfirm') }} "<b>{{ selectedMisc.name }}</b>"? | ||
</div> | ||
</div> | ||
</ConfirmModal> | ||
</BaseContextMenu> | ||
</template> | ||
|
||
<script> | ||
import { mapGetters, mapActions } from 'vuex'; | ||
import BaseContextMenu from '@/components/BaseContextMenu'; | ||
import ConfirmModal from '@/components/BaseConfirmModal'; | ||
import Triggers from '@/ipc-api/Triggers'; | ||
export default { | ||
name: 'WorkspaceExploreBarMiscContext', | ||
components: { | ||
BaseContextMenu, | ||
ConfirmModal | ||
}, | ||
props: { | ||
contextEvent: MouseEvent, | ||
selectedMisc: Object | ||
}, | ||
data () { | ||
return { | ||
isDeleteModal: false, | ||
isEmptyModal: false | ||
}; | ||
}, | ||
computed: { | ||
...mapGetters({ | ||
selectedWorkspace: 'workspaces/getSelected', | ||
getWorkspace: 'workspaces/getWorkspace' | ||
}), | ||
workspace () { | ||
return this.getWorkspace(this.selectedWorkspace); | ||
}, | ||
deleteMessage () { | ||
switch (this.selectedMisc.type) { | ||
case 'trigger': | ||
return this.$t('message.deleteTrigger'); | ||
default: | ||
return ''; | ||
} | ||
} | ||
}, | ||
methods: { | ||
...mapActions({ | ||
addNotification: 'notifications/addNotification', | ||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs' | ||
}), | ||
showCreateTableModal () { | ||
this.$emit('show-create-table-modal'); | ||
}, | ||
showDeleteModal () { | ||
this.isDeleteModal = true; | ||
}, | ||
hideDeleteModal () { | ||
this.isDeleteModal = false; | ||
}, | ||
showEmptyModal () { | ||
this.isEmptyModal = true; | ||
}, | ||
hideEmptyModal () { | ||
this.isEmptyModal = false; | ||
}, | ||
closeContext () { | ||
this.$emit('close-context'); | ||
}, | ||
async deleteMisc () { | ||
try { | ||
let res; | ||
switch (this.selectedMisc.type) { | ||
case 'trigger': | ||
res = await Triggers.dropTrigger({ | ||
uid: this.selectedWorkspace, | ||
trigger: this.selectedMisc.name | ||
}); | ||
break; | ||
// case 'procedure': | ||
// res = await Tables.dropProcedure({ | ||
// uid: this.selectedWorkspace, | ||
// procedure: this.selectedMisc.name | ||
// }); | ||
// break; | ||
// case 'schedules': | ||
// res = await Tables.dropScheduler({ | ||
// uid: this.selectedWorkspace, | ||
// scheduler: this.selectedMisc.name | ||
// }); | ||
// break; | ||
} | ||
const { status, response } = res; | ||
if (status === 'success') { | ||
this.changeBreadcrumbs({ [this.selectedMisc.type]: null }); | ||
this.closeContext(); | ||
this.$emit('reload'); | ||
} | ||
else | ||
this.addNotification({ status: 'error', message: response }); | ||
} | ||
catch (err) { | ||
this.addNotification({ status: 'error', message: err.stack }); | ||
} | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters