mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat: close tabs if element deleted
This commit is contained in:
@ -212,7 +212,7 @@
|
|||||||
:is-selected="selectedTab === tab.uid"
|
:is-selected="selectedTab === tab.uid"
|
||||||
:table="tab.elementName"
|
:table="tab.elementName"
|
||||||
:schema="tab.schema"
|
:schema="tab.schema"
|
||||||
:element-type="tab.element"
|
:element-type="tab.elementType"
|
||||||
/>
|
/>
|
||||||
<WorkspacePropsTab
|
<WorkspacePropsTab
|
||||||
v-else-if="tab.type === 'table-props'"
|
v-else-if="tab.type === 'table-props'"
|
||||||
@ -323,30 +323,6 @@ export default {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
selectedTab () {
|
selectedTab () {
|
||||||
// if (
|
|
||||||
// (
|
|
||||||
// this.workspace.breadcrumbs.table === null &&
|
|
||||||
// this.workspace.breadcrumbs.view === null &&
|
|
||||||
// this.workspace.breadcrumbs.trigger === null &&
|
|
||||||
// this.workspace.breadcrumbs.procedure === null &&
|
|
||||||
// this.workspace.breadcrumbs.function === null &&
|
|
||||||
// this.workspace.breadcrumbs.triggerFunction === null &&
|
|
||||||
// this.workspace.breadcrumbs.scheduler === null &&
|
|
||||||
// ['data', 'prop'].includes(this.workspace.selected_tab)
|
|
||||||
// ) ||
|
|
||||||
// (
|
|
||||||
// this.workspace.breadcrumbs.table === null &&
|
|
||||||
// this.workspace.breadcrumbs.view === null &&
|
|
||||||
// this.workspace.selected_tab === 'data'
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// return 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;
|
return this.workspace.selected_tab;
|
||||||
},
|
},
|
||||||
queryTabs () {
|
queryTabs () {
|
||||||
@ -391,8 +367,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.removeTab({ uid: this.connection.uid, tab: tab.uid });
|
this.removeTab({ uid: this.connection.uid, tab: tab.uid });
|
||||||
if (this.selectedTab === tab.uid && this.workspace.tabs.length)
|
|
||||||
this.selectTab({ uid: this.workspace.uid, tab: this.workspace.tabs[0].uid });
|
|
||||||
},
|
},
|
||||||
showProcessesModal () {
|
showProcessesModal () {
|
||||||
this.isProcessesModal = true;
|
this.isProcessesModal = true;
|
||||||
|
@ -108,6 +108,7 @@ export default {
|
|||||||
...mapActions({
|
...mapActions({
|
||||||
addNotification: 'notifications/addNotification',
|
addNotification: 'notifications/addNotification',
|
||||||
newTab: 'workspaces/newTab',
|
newTab: 'workspaces/newTab',
|
||||||
|
removeTabs: 'workspaces/removeTabs',
|
||||||
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
changeBreadcrumbs: 'workspaces/changeBreadcrumbs'
|
||||||
}),
|
}),
|
||||||
showCreateTableModal () {
|
showCreateTableModal () {
|
||||||
@ -220,8 +221,12 @@ export default {
|
|||||||
const { status, response } = res;
|
const { status, response } = res;
|
||||||
|
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
if (this.selectedTable.name === this.workspace.breadcrumbs.table || this.selectedTable.name === this.workspace.breadcrumbs.view)
|
this.removeTabs({
|
||||||
this.changeBreadcrumbs({ table: null, view: null });
|
uid: this.selectedWorkspace,
|
||||||
|
elementName: this.selectedTable.name,
|
||||||
|
elementType: this.selectedTable.type,
|
||||||
|
schema: this.selectedSchema
|
||||||
|
});
|
||||||
|
|
||||||
this.closeContext();
|
this.closeContext();
|
||||||
this.$emit('reload');
|
this.$emit('reload');
|
||||||
|
@ -212,6 +212,22 @@ export default {
|
|||||||
return workspace;
|
return workspace;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
REMOVE_TABS (state, { uid, schema, elementName, elementType }) { // Multiple tabs based on schema and element name
|
||||||
|
state.workspaces = state.workspaces.map(workspace => {
|
||||||
|
if (workspace.uid === uid) {
|
||||||
|
return {
|
||||||
|
...workspace,
|
||||||
|
tabs: workspace.tabs.filter(tab =>
|
||||||
|
tab.schema !== schema ||
|
||||||
|
tab.elementName !== elementName ||
|
||||||
|
tab.elementType !== elementType
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return workspace;
|
||||||
|
});
|
||||||
|
},
|
||||||
REPLACE_TAB (state, { uid, tab: tUid, type, schema, elementName, elementType }) {
|
REPLACE_TAB (state, { uid, tab: tUid, type, schema, elementName, elementType }) {
|
||||||
state.workspaces = state.workspaces.map(workspace => {
|
state.workspaces = state.workspaces.map(workspace => {
|
||||||
if (workspace.uid === uid) {
|
if (workspace.uid === uid) {
|
||||||
@ -490,13 +506,7 @@ export default {
|
|||||||
|
|
||||||
dispatch('setUnsavedChanges', false);
|
dispatch('setUnsavedChanges', false);
|
||||||
},
|
},
|
||||||
changeBreadcrumbs ({ state, commit, getters }, payload) {
|
changeBreadcrumbs ({ commit, getters }, payload) {
|
||||||
// if (state.has_unsaved_changes) {
|
|
||||||
// commit('SET_UNSAVED_DISCARD_MODAL', true);
|
|
||||||
// commit('SET_PENDING_BREADCRUMBS', payload);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
const breadcrumbsObj = {
|
const breadcrumbsObj = {
|
||||||
schema: null,
|
schema: null,
|
||||||
table: null,
|
table: null,
|
||||||
@ -597,11 +607,25 @@ export default {
|
|||||||
|
|
||||||
commit('SELECT_TAB', { uid, tab: tabUid });
|
commit('SELECT_TAB', { uid, tab: tabUid });
|
||||||
},
|
},
|
||||||
|
checkSelectedTabExists ({ state, commit }, uid) {
|
||||||
|
const workspace = state.workspaces.find(workspace => workspace.uid === uid);
|
||||||
|
const isSelectedExistent = workspace
|
||||||
|
? workspace.tabs.some(tab => tab.uid === workspace.selected_tab)
|
||||||
|
: false;
|
||||||
|
|
||||||
|
if (!isSelectedExistent)
|
||||||
|
commit('SELECT_TAB', { uid, tab: workspace.tabs[workspace.tabs.length - 1].uid });
|
||||||
|
},
|
||||||
renameTabs ({ commit }, payload) {
|
renameTabs ({ commit }, payload) {
|
||||||
commit('RENAME_TABS', payload);
|
commit('RENAME_TABS', payload);
|
||||||
},
|
},
|
||||||
removeTab ({ commit }, payload) {
|
removeTab ({ commit, dispatch }, payload) {
|
||||||
commit('REMOVE_TAB', payload);
|
commit('REMOVE_TAB', payload);
|
||||||
|
dispatch('checkSelectedTabExists', payload.uid);
|
||||||
|
},
|
||||||
|
removeTabs ({ commit, dispatch }, payload) {
|
||||||
|
commit('REMOVE_TABS', payload);
|
||||||
|
dispatch('checkSelectedTabExists', payload.uid);
|
||||||
},
|
},
|
||||||
selectTab ({ commit }, payload) {
|
selectTab ({ commit }, payload) {
|
||||||
commit('SELECT_TAB', payload);
|
commit('SELECT_TAB', payload);
|
||||||
|
Reference in New Issue
Block a user