mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
refactor: improvements in explorebar events on tables
This commit is contained in:
@ -98,6 +98,8 @@
|
|||||||
:selected-schema="selectedSchema"
|
:selected-schema="selectedSchema"
|
||||||
:selected-table="selectedTable"
|
:selected-table="selectedTable"
|
||||||
:context-event="tableContextEvent"
|
:context-event="tableContextEvent"
|
||||||
|
@delete-table="deleteTable"
|
||||||
|
@duplicate-table="duplicateTable"
|
||||||
@close-context="closeTableContext"
|
@close-context="closeTableContext"
|
||||||
@reload="refresh"
|
@reload="refresh"
|
||||||
/>
|
/>
|
||||||
@ -128,9 +130,8 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions } from 'vuex';
|
import { mapGetters, mapActions } from 'vuex';
|
||||||
|
|
||||||
// import Tables from '@/ipc-api/Tables';
|
import Tables from '@/ipc-api/Tables';
|
||||||
import Triggers from '@/ipc-api/Triggers';
|
import Views from '@/ipc-api/Views';
|
||||||
import Routines from '@/ipc-api/Routines';
|
|
||||||
import Functions from '@/ipc-api/Functions';
|
import Functions from '@/ipc-api/Functions';
|
||||||
import Schedulers from '@/ipc-api/Schedulers';
|
import Schedulers from '@/ipc-api/Schedulers';
|
||||||
|
|
||||||
@ -248,9 +249,12 @@ export default {
|
|||||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs',
|
||||||
selectTab: 'workspaces/selectTab',
|
selectTab: 'workspaces/selectTab',
|
||||||
newTab: 'workspaces/newTab',
|
newTab: 'workspaces/newTab',
|
||||||
|
removeTabs: 'workspaces/removeTabs',
|
||||||
setSearchTerm: 'workspaces/setSearchTerm',
|
setSearchTerm: 'workspaces/setSearchTerm',
|
||||||
addNotification: 'notifications/addNotification',
|
addNotification: 'notifications/addNotification',
|
||||||
changeExplorebarSize: 'settings/changeExplorebarSize'
|
changeExplorebarSize: 'settings/changeExplorebarSize',
|
||||||
|
addLoadingElement: 'workspaces/addLoadingElement',
|
||||||
|
removeLoadingElement: 'workspaces/removeLoadingElement'
|
||||||
}),
|
}),
|
||||||
async refresh () {
|
async refresh () {
|
||||||
if (!this.isRefreshing) {
|
if (!this.isRefreshing) {
|
||||||
@ -330,31 +334,6 @@ export default {
|
|||||||
hideCreateTriggerModal () {
|
hideCreateTriggerModal () {
|
||||||
this.isNewTriggerModal = false;
|
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 () {
|
showCreateRoutineModal () {
|
||||||
this.closeDatabaseContext();
|
this.closeDatabaseContext();
|
||||||
this.closeMiscFolderContext();
|
this.closeMiscFolderContext();
|
||||||
@ -363,30 +342,6 @@ export default {
|
|||||||
hideCreateRoutineModal () {
|
hideCreateRoutineModal () {
|
||||||
this.isNewRoutineModal = false;
|
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 () {
|
showCreateFunctionModal () {
|
||||||
this.closeDatabaseContext();
|
this.closeDatabaseContext();
|
||||||
this.closeMiscFolderContext();
|
this.closeMiscFolderContext();
|
||||||
@ -411,6 +366,89 @@ export default {
|
|||||||
hideCreateSchedulerModal () {
|
hideCreateSchedulerModal () {
|
||||||
this.isNewSchedulerModal = false;
|
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) {
|
async openCreateFunctionEditor (payload) {
|
||||||
const params = {
|
const params = {
|
||||||
uid: this.connection.uid,
|
uid: this.connection.uid,
|
||||||
|
@ -76,7 +76,6 @@ import { mapGetters, mapActions } from 'vuex';
|
|||||||
import BaseContextMenu from '@/components/BaseContextMenu';
|
import BaseContextMenu from '@/components/BaseContextMenu';
|
||||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||||
import Tables from '@/ipc-api/Tables';
|
import Tables from '@/ipc-api/Tables';
|
||||||
import Views from '@/ipc-api/Views';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'WorkspaceExploreBarTableContext',
|
name: 'WorkspaceExploreBarTableContext',
|
||||||
@ -163,36 +162,8 @@ export default {
|
|||||||
|
|
||||||
this.closeContext();
|
this.closeContext();
|
||||||
},
|
},
|
||||||
async duplicateTable () {
|
duplicateTable () {
|
||||||
this.closeContext();
|
this.$emit('duplicate-table', { schema: this.selectedSchema, table: this.selectedTable });
|
||||||
|
|
||||||
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'
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
async emptyTable () {
|
async emptyTable () {
|
||||||
this.closeContext();
|
this.closeContext();
|
||||||
@ -225,57 +196,8 @@ export default {
|
|||||||
type: 'table'
|
type: 'table'
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async deleteTable () {
|
deleteTable () {
|
||||||
this.closeContext();
|
this.$emit('delete-table', { schema: this.selectedSchema, table: this.selectedTable });
|
||||||
|
|
||||||
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'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -314,6 +314,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, table: this.localOptions.name });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.addNotification({ status: 'error', message: response });
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
@ -250,6 +250,7 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
this.removeTab({ uid: this.connection.uid, tab: this.tab.uid });
|
||||||
|
this.changeBreadcrumbs({ schema: this.schema, view: this.localView.name });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.addNotification({ status: 'error', message: response });
|
this.addNotification({ status: 'error', message: response });
|
||||||
|
Reference in New Issue
Block a user