From a87079cd179033cebb6fd228ad7f1b991f3b6c46 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Mon, 12 Jul 2021 19:18:29 +0200 Subject: [PATCH] feat(UI): temporary table data tabs --- src/renderer/components/Workspace.vue | 127 ++++++++++-------- .../WorkspaceExploreBarMiscContext.vue | 2 +- .../components/WorkspaceExploreBarSchema.vue | 8 +- .../components/WorkspacePropsTabFunction.vue | 2 +- .../components/WorkspacePropsTabRoutine.vue | 2 +- .../WorkspacePropsTabTriggerFunction.vue | 2 +- src/renderer/components/WorkspaceQueryTab.vue | 2 +- src/renderer/components/WorkspaceTableTab.vue | 2 +- .../store/modules/workspaces.store.js | 28 ++-- 9 files changed, 104 insertions(+), 71 deletions(-) diff --git a/src/renderer/components/Workspace.vue b/src/renderer/components/Workspace.vue index 626ce6d0..5244d7ac 100644 --- a/src/renderer/components/Workspace.vue +++ b/src/renderer/components/Workspace.vue @@ -48,7 +48,7 @@ -
  • {{ $t('word.data').toUpperCase() }}: {{ schemaChild }} -
  • + -->
  • - + Query #{{ tab.index }} @@ -90,18 +90,22 @@ /> + + + {{ tab.table }} +
  • - - - --> +
    + class="column col-12" + > + + +
    tab.uid === this.workspace.selected_tab) || - ['data', 'prop'].includes(this.workspace.selected_tab) - ? this.workspace.selected_tab - : this.queryTabs[0].uid; + // return this.queryTabs.find(tab => tab.uid === this.workspace.selected_tab) || + // ['data', 'prop'].includes(this.workspace.selected_tab) + // ? this.workspace.selected_tab + // : this.queryTabs[0].uid; + + return this.workspace.selected_tab; }, queryTabs () { return this.workspace.tabs.filter(tab => tab.type === 'query'); @@ -286,8 +301,8 @@ export default { newTab: 'workspaces/newTab', removeTab: 'workspaces/removeTab' }), - addTab () { - this.newTab({ uid: this.connection.uid }); + addQueryTab () { + this.newTab({ uid: this.connection.uid, type: 'query' }); if (!this.hasWheelEvent) { this.$refs.tabWrap.addEventListener('wheel', e => { diff --git a/src/renderer/components/WorkspaceExploreBarMiscContext.vue b/src/renderer/components/WorkspaceExploreBarMiscContext.vue index 819a27b4..89f5321f 100644 --- a/src/renderer/components/WorkspaceExploreBarMiscContext.vue +++ b/src/renderer/components/WorkspaceExploreBarMiscContext.vue @@ -218,7 +218,7 @@ export default { sql = `CALL \`${this.localElement.name}\`(${params.join(',')})`; } - this.newTab({ uid: this.workspace.uid, content: sql, autorun: true }); + this.newTab({ uid: this.workspace.uid, content: sql, type: 'query', autorun: true }); this.closeContext(); }, async runFunctionCheck () { diff --git a/src/renderer/components/WorkspaceExploreBarSchema.vue b/src/renderer/components/WorkspaceExploreBarSchema.vue index fec7022b..75714882 100644 --- a/src/renderer/components/WorkspaceExploreBarSchema.vue +++ b/src/renderer/components/WorkspaceExploreBarSchema.vue @@ -19,7 +19,7 @@ :key="table.name" class="menu-item" :class="{'text-bold': breadcrumbs.schema === database.name && [breadcrumbs.table, breadcrumbs.view].includes(table.name)}" - @click="setBreadcrumbs({schema: database.name, [table.type]: table.name})" + @click="selectTable({schema: database.name, table})" @contextmenu.prevent="showTableContext($event, table)" > @@ -267,6 +267,7 @@ export default { methods: { ...mapActions({ changeBreadcrumbs: 'workspaces/changeBreadcrumbs', + newTab: 'workspaces/newTab', refreshSchema: 'workspaces/refreshSchema' }), formatBytes, @@ -279,6 +280,11 @@ export default { this.changeBreadcrumbs({ schema, table: null }); }, + selectTable ({ schema, table }) { + this.setBreadcrumbs({ schema, [table.type]: table.name }); + // TODO: open only if not present + this.newTab({ uid: this.connection.uid, table: table.name, schema: this.database.name, type: 'temp-data' }); + }, showSchemaContext (event, schema) { this.selectSchema(schema); this.$emit('show-schema-context', { event, schema }); diff --git a/src/renderer/components/WorkspacePropsTabFunction.vue b/src/renderer/components/WorkspacePropsTabFunction.vue index eb92e48f..74ada258 100644 --- a/src/renderer/components/WorkspacePropsTabFunction.vue +++ b/src/renderer/components/WorkspacePropsTabFunction.vue @@ -303,7 +303,7 @@ export default { sql = `SELECT \`${this.originalFunction.name}\` (${params.join(',')})`; } - this.newTab({ uid: this.connection.uid, content: sql, autorun: true }); + this.newTab({ uid: this.connection.uid, content: sql, type: 'query', autorun: true }); }, showOptionsModal () { this.isOptionsModal = true; diff --git a/src/renderer/components/WorkspacePropsTabRoutine.vue b/src/renderer/components/WorkspacePropsTabRoutine.vue index 0964e54c..b9ba1099 100644 --- a/src/renderer/components/WorkspacePropsTabRoutine.vue +++ b/src/renderer/components/WorkspacePropsTabRoutine.vue @@ -299,7 +299,7 @@ export default { sql = `CALL \`${this.originalRoutine.name}\`(${params.join(',')})`; } - this.newTab({ uid: this.connection.uid, content: sql, autorun: true }); + this.newTab({ uid: this.connection.uid, content: sql, type: 'query', autorun: true }); }, showOptionsModal () { this.isOptionsModal = true; diff --git a/src/renderer/components/WorkspacePropsTabTriggerFunction.vue b/src/renderer/components/WorkspacePropsTabTriggerFunction.vue index 718ca9f3..2cffae33 100644 --- a/src/renderer/components/WorkspacePropsTabTriggerFunction.vue +++ b/src/renderer/components/WorkspacePropsTabTriggerFunction.vue @@ -281,7 +281,7 @@ export default { sql = `SELECT \`${this.originalFunction.name}\` (${params.join(',')})`; } - this.newTab({ uid: this.connection.uid, content: sql, autorun: true }); + this.newTab({ uid: this.connection.uid, content: sql, type: 'query', autorun: true }); }, showOptionsModal () { this.isOptionsModal = true; diff --git a/src/renderer/components/WorkspaceQueryTab.vue b/src/renderer/components/WorkspaceQueryTab.vue index 0c4a1b04..4e3d3d0d 100644 --- a/src/renderer/components/WorkspaceQueryTab.vue +++ b/src/renderer/components/WorkspaceQueryTab.vue @@ -1,7 +1,7 @@