From 0252a064d99df09b01c020c7d10c76dd43d4ede8 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Fri, 9 Jul 2021 15:12:16 +0200 Subject: [PATCH] feat(UI): contextual menu shortcuts to create new elements on folders --- .../components/WorkspaceExploreBar.vue | 30 ++++++ .../WorkspaceExploreBarMiscFolderContext.vue | 97 +++++++++++++++++++ .../components/WorkspaceExploreBarSchema.vue | 35 ++++++- 3 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 src/renderer/components/WorkspaceExploreBarMiscFolderContext.vue diff --git a/src/renderer/components/WorkspaceExploreBar.vue b/src/renderer/components/WorkspaceExploreBar.vue index e45c3587..f7424f99 100644 --- a/src/renderer/components/WorkspaceExploreBar.vue +++ b/src/renderer/components/WorkspaceExploreBar.vue @@ -47,6 +47,7 @@ @show-schema-context="openSchemaContext" @show-table-context="openTableContext" @show-misc-context="openMiscContext" + @show-misc-folder-context="openMiscFolderContext" /> @@ -125,6 +126,18 @@ @close-context="closeMiscContext" @reload="refresh" /> + @@ -142,6 +155,7 @@ import WorkspaceExploreBarSchema from '@/components/WorkspaceExploreBarSchema'; import DatabaseContext from '@/components/WorkspaceExploreBarSchemaContext'; import TableContext from '@/components/WorkspaceExploreBarTableContext'; import MiscContext from '@/components/WorkspaceExploreBarMiscContext'; +import MiscFolderContext from '@/components/WorkspaceExploreBarMiscFolderContext'; import ModalNewSchema from '@/components/ModalNewSchema'; import ModalNewTable from '@/components/ModalNewTable'; import ModalNewView from '@/components/ModalNewView'; @@ -158,6 +172,7 @@ export default { DatabaseContext, TableContext, MiscContext, + MiscFolderContext, ModalNewSchema, ModalNewTable, ModalNewView, @@ -190,6 +205,7 @@ export default { isDatabaseContext: false, isTableContext: false, isMiscContext: false, + isMiscFolderContext: false, databaseContextEvent: null, tableContextEvent: null, @@ -326,11 +342,20 @@ export default { this.miscContextEvent = payload.event; this.isMiscContext = true; }, + openMiscFolderContext (payload) { + this.selectedMisc = payload.type; + this.miscContextEvent = payload.event; + this.isMiscFolderContext = true; + }, closeMiscContext () { this.isMiscContext = false; }, + closeMiscFolderContext () { + this.isMiscFolderContext = false; + }, showCreateViewModal () { this.closeDatabaseContext(); + this.closeMiscFolderContext(); this.isNewViewModal = true; }, hideCreateViewModal () { @@ -354,6 +379,7 @@ export default { }, showCreateTriggerModal () { this.closeDatabaseContext(); + this.closeMiscFolderContext(); this.isNewTriggerModal = true; }, hideCreateTriggerModal () { @@ -378,6 +404,7 @@ export default { }, showCreateRoutineModal () { this.closeDatabaseContext(); + this.closeMiscFolderContext(); this.isNewRoutineModal = true; }, hideCreateRoutineModal () { @@ -401,6 +428,7 @@ export default { }, showCreateFunctionModal () { this.closeDatabaseContext(); + this.closeMiscFolderContext(); this.isNewFunctionModal = true; }, hideCreateFunctionModal () { @@ -408,6 +436,7 @@ export default { }, showCreateTriggerFunctionModal () { this.closeDatabaseContext(); + this.closeMiscFolderContext(); this.isNewTriggerFunctionModal = true; }, hideCreateTriggerFunctionModal () { @@ -415,6 +444,7 @@ export default { }, showCreateSchedulerModal () { this.closeDatabaseContext(); + this.closeMiscFolderContext(); this.isNewSchedulerModal = true; }, hideCreateSchedulerModal () { diff --git a/src/renderer/components/WorkspaceExploreBarMiscFolderContext.vue b/src/renderer/components/WorkspaceExploreBarMiscFolderContext.vue new file mode 100644 index 00000000..dfc05c4d --- /dev/null +++ b/src/renderer/components/WorkspaceExploreBarMiscFolderContext.vue @@ -0,0 +1,97 @@ + + + diff --git a/src/renderer/components/WorkspaceExploreBarSchema.vue b/src/renderer/components/WorkspaceExploreBarSchema.vue index b470b565..fec7022b 100644 --- a/src/renderer/components/WorkspaceExploreBarSchema.vue +++ b/src/renderer/components/WorkspaceExploreBarSchema.vue @@ -39,7 +39,11 @@
- + {{ $tc('word.trigger', 2) }} @@ -67,7 +71,11 @@
- + {{ $tc('word.storedRoutine', 2) }} @@ -95,7 +103,11 @@
- + {{ $tc('word.triggerFunction', 2) }} @@ -123,7 +135,11 @@
- + {{ $tc('word.function', 2) }} @@ -151,7 +167,11 @@
- + {{ $tc('word.scheduler', 2) }} @@ -271,6 +291,11 @@ export default { this.setBreadcrumbs({ schema: this.database.name, [misc.type]: misc.name }); this.$emit('show-misc-context', { event, misc }); }, + showMiscFolderContext (event, type) { + this.selectSchema(this.database.name); + this.setBreadcrumbs({ schema: this.database.name, type }); + this.$emit('show-misc-folder-context', { event, type }); + }, piePercentage (val) { const perc = val / this.maxSize * 100; if (this.applicationTheme === 'dark')