mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-17 12:10:39 +01:00
refactor: improvements in explorebar events on tables
This commit is contained in:
parent
3fd26a0523
commit
6115eb9409
@ -98,6 +98,8 @@
|
||||
:selected-schema="selectedSchema"
|
||||
:selected-table="selectedTable"
|
||||
:context-event="tableContextEvent"
|
||||
@delete-table="deleteTable"
|
||||
@duplicate-table="duplicateTable"
|
||||
@close-context="closeTableContext"
|
||||
@reload="refresh"
|
||||
/>
|
||||
@ -128,9 +130,8 @@
|
||||
<script>
|
||||
import { mapGetters, mapActions } from 'vuex';
|
||||
|
||||
// import Tables from '@/ipc-api/Tables';
|
||||
import Triggers from '@/ipc-api/Triggers';
|
||||
import Routines from '@/ipc-api/Routines';
|
||||
import Tables from '@/ipc-api/Tables';
|
||||
import Views from '@/ipc-api/Views';
|
||||
import Functions from '@/ipc-api/Functions';
|
||||
import Schedulers from '@/ipc-api/Schedulers';
|
||||
|
||||
@ -248,9 +249,12 @@ export default {
|
||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
||||
selectTab: 'workspaces/selectTab',
|
||||
newTab: 'workspaces/newTab',
|
||||
removeTabs: 'workspaces/removeTabs',
|
||||
setSearchTerm: 'workspaces/setSearchTerm',
|
||||
addNotification: 'notifications/addNotification',
|
||||
changeExplorebarSize: 'settings/changeExplorebarSize'
|
||||
changeExplorebarSize: 'settings/changeExplorebarSize',
|
||||
addLoadingElement: 'workspaces/addLoadingElement',
|
||||
removeLoadingElement: 'workspaces/removeLoadingElement'
|
||||
}),
|
||||
async refresh () {
|
||||
if (!this.isRefreshing) {
|
||||
@ -330,31 +334,6 @@ export default {
|
||||
hideCreateTriggerModal () {
|
||||
this.isNewTriggerModal = false;
|
||||
},
|
||||
async openCreateTriggerEditor (payload) {
|
||||
const params = {
|
||||
uid: this.connection.uid,
|
||||
schema: this.selectedSchema,
|
||||
...payload
|
||||
};
|
||||
|
||||
const { status, response } = await Triggers.createTrigger(params);
|
||||
|
||||
if (status === 'success') {
|
||||
await this.refresh();
|
||||
const triggerName = this.customizations.triggerTableInName ? `${payload.table}.${payload.name}` : payload.name;
|
||||
this.changeBreadcrumbs({ schema: this.selectedSchema, trigger: triggerName });
|
||||
|
||||
this.newTab({
|
||||
uid: this.workspace.uid,
|
||||
schema: this.selectedSchema,
|
||||
elementName: triggerName,
|
||||
elementType: 'trigger',
|
||||
type: 'trigger-props'
|
||||
});
|
||||
}
|
||||
else
|
||||
this.addNotification({ status: 'error', message: response });
|
||||
},
|
||||
showCreateRoutineModal () {
|
||||
this.closeDatabaseContext();
|
||||
this.closeMiscFolderContext();
|
||||
@ -363,30 +342,6 @@ export default {
|
||||
hideCreateRoutineModal () {
|
||||
this.isNewRoutineModal = false;
|
||||
},
|
||||
async openCreateRoutineEditor (payload) {
|
||||
const params = {
|
||||
uid: this.connection.uid,
|
||||
schema: this.selectedSchema,
|
||||
...payload
|
||||
};
|
||||
|
||||
const { status, response } = await Routines.createRoutine(params);
|
||||
|
||||
if (status === 'success') {
|
||||
await this.refresh();
|
||||
this.changeBreadcrumbs({ schema: this.selectedSchema, routine: payload.name });
|
||||
|
||||
this.newTab({
|
||||
uid: this.workspace.uid,
|
||||
schema: this.selectedSchema,
|
||||
elementName: payload.name,
|
||||
elementType: 'routine',
|
||||
type: 'routine-props'
|
||||
});
|
||||
}
|
||||
else
|
||||
this.addNotification({ status: 'error', message: response });
|
||||
},
|
||||
showCreateFunctionModal () {
|
||||
this.closeDatabaseContext();
|
||||
this.closeMiscFolderContext();
|
||||
@ -411,6 +366,89 @@ export default {
|
||||
hideCreateSchedulerModal () {
|
||||
this.isNewSchedulerModal = false;
|
||||
},
|
||||
async deleteTable (payload) {
|
||||
this.closeTableContext();
|
||||
|
||||
this.addLoadingElement({
|
||||
name: payload.table.name,
|
||||
schema: payload.schema,
|
||||
type: 'table'
|
||||
});
|
||||
|
||||
try {
|
||||
let res;
|
||||
|
||||
if (payload.table.type === 'table') {
|
||||
res = await Tables.dropTable({
|
||||
uid: this.connection.uid,
|
||||
table: payload.table.name,
|
||||
schema: payload.schema
|
||||
});
|
||||
}
|
||||
else if (payload.table.type === 'view') {
|
||||
res = await Views.dropView({
|
||||
uid: this.connection.uid,
|
||||
view: payload.table.name,
|
||||
schema: payload.schema
|
||||
});
|
||||
}
|
||||
|
||||
const { status, response } = res;
|
||||
|
||||
if (status === 'success') {
|
||||
this.refresh();
|
||||
|
||||
this.removeTabs({
|
||||
uid: this.connection.uid,
|
||||
elementName: payload.table.name,
|
||||
elementType: payload.table.type,
|
||||
schema: payload.schema
|
||||
});
|
||||
}
|
||||
else
|
||||
this.addNotification({ status: 'error', message: response });
|
||||
}
|
||||
catch (err) {
|
||||
this.addNotification({ status: 'error', message: err.stack });
|
||||
}
|
||||
|
||||
this.removeLoadingElement({
|
||||
name: payload.table.name,
|
||||
schema: payload.schema,
|
||||
type: 'table'
|
||||
});
|
||||
},
|
||||
async duplicateTable (payload) {
|
||||
this.closeTableContext();
|
||||
|
||||
this.addLoadingElement({
|
||||
name: payload.table.name,
|
||||
schema: payload.schema,
|
||||
type: 'table'
|
||||
});
|
||||
|
||||
try {
|
||||
const { status, response } = await Tables.duplicateTable({
|
||||
uid: this.connection.uid,
|
||||
table: payload.table.name,
|
||||
schema: payload.schema
|
||||
});
|
||||
|
||||
if (status === 'success')
|
||||
this.refresh();
|
||||
else
|
||||
this.addNotification({ status: 'error', message: response });
|
||||
}
|
||||
catch (err) {
|
||||
this.addNotification({ status: 'error', message: err.stack });
|
||||
}
|
||||
|
||||
this.removeLoadingElement({
|
||||
name: payload.table.name,
|
||||
schema: payload.schema,
|
||||
type: 'table'
|
||||
});
|
||||
},
|
||||
async openCreateFunctionEditor (payload) {
|
||||
const params = {
|
||||
uid: this.connection.uid,
|
||||
|
@ -76,7 +76,6 @@ import { mapGetters, mapActions } from 'vuex';
|
||||
import BaseContextMenu from '@/components/BaseContextMenu';
|
||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||
import Tables from '@/ipc-api/Tables';
|
||||
import Views from '@/ipc-api/Views';
|
||||
|
||||
export default {
|
||||
name: 'WorkspaceExploreBarTableContext',
|
||||
@ -163,36 +162,8 @@ export default {
|
||||
|
||||
this.closeContext();
|
||||
},
|
||||
async duplicateTable () {
|
||||
this.closeContext();
|
||||
|
||||
this.addLoadingElement({
|
||||
name: this.selectedTable.name,
|
||||
schema: this.selectedSchema,
|
||||
type: 'table'
|
||||
});
|
||||
|
||||
try {
|
||||
const { status, response } = await Tables.duplicateTable({
|
||||
uid: this.selectedWorkspace,
|
||||
table: this.selectedTable.name,
|
||||
schema: this.selectedSchema
|
||||
});
|
||||
|
||||
if (status === 'success')
|
||||
this.$emit('reload');
|
||||
else
|
||||
this.addNotification({ status: 'error', message: response });
|
||||
}
|
||||
catch (err) {
|
||||
this.addNotification({ status: 'error', message: err.stack });
|
||||
}
|
||||
|
||||
this.removeLoadingElement({
|
||||
name: this.selectedTable.name,
|
||||
schema: this.selectedSchema,
|
||||
type: 'table'
|
||||
});
|
||||
duplicateTable () {
|
||||
this.$emit('duplicate-table', { schema: this.selectedSchema, table: this.selectedTable });
|
||||
},
|
||||
async emptyTable () {
|
||||
this.closeContext();
|
||||
@ -225,57 +196,8 @@ export default {
|
||||
type: 'table'
|
||||
});
|
||||
},
|
||||
async deleteTable () {
|
||||
this.closeContext();
|
||||
|
||||
this.addLoadingElement({
|
||||
name: this.selectedTable.name,
|
||||
schema: this.selectedSchema,
|
||||
type: 'table'
|
||||
});
|
||||
|
||||
try {
|
||||
let res;
|
||||
|
||||
if (this.selectedTable.type === 'table') {
|
||||
res = await Tables.dropTable({
|
||||
uid: this.selectedWorkspace,
|
||||
table: this.selectedTable.name,
|
||||
schema: this.selectedSchema
|
||||
});
|
||||
}
|
||||
else if (this.selectedTable.type === 'view') {
|
||||
res = await Views.dropView({
|
||||
uid: this.selectedWorkspace,
|
||||
view: this.selectedTable.name,
|
||||
schema: this.selectedSchema
|
||||
});
|
||||
}
|
||||
|
||||
const { status, response } = res;
|
||||
|
||||
if (status === 'success') {
|
||||
this.removeTabs({
|
||||
uid: this.selectedWorkspace,
|
||||
elementName: this.selectedTable.name,
|
||||
elementType: this.selectedTable.type,
|
||||
schema: this.selectedSchema
|
||||
});
|
||||
|
||||
this.$emit('reload');
|
||||
}
|
||||
else
|
||||
this.addNotification({ status: 'error', message: response });
|
||||
}
|
||||
catch (err) {
|
||||
this.addNotification({ status: 'error', message: err.stack });
|
||||
}
|
||||
|
||||
this.removeLoadingElement({
|
||||
name: this.selectedTable.name,
|
||||
schema: this.selectedSchema,
|
||||
type: 'table'
|
||||
});
|
||||
deleteTable () {
|
||||
this.$emit('delete-table', { schema: this.selectedSchema, table: this.selectedTable });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -314,6 +314,7 @@ export default {
|
||||
});
|
||||
|
||||
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||
this.changeBreadcrumbs({ schema: this.schema, table: this.localOptions.name });
|
||||
}
|
||||
else
|
||||
this.addNotification({ status: 'error', message: response });
|
||||
|
@ -250,6 +250,7 @@ export default {
|
||||
});
|
||||
|
||||
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||
this.changeBreadcrumbs({ schema: this.schema, view: this.localView.name });
|
||||
}
|
||||
else
|
||||
this.addNotification({ status: 'error', message: response });
|
||||
|
Loading…
x
Reference in New Issue
Block a user