Mongo tabs UX fixes (#851)

* Fixed mongo tabs UX

* changed logic for new tab index

* moved index to tabs base

* removed getIndex method
This commit is contained in:
Srinath Narayanan
2021-06-08 00:17:55 +05:30
committed by GitHub
parent f296c00a1c
commit ee60f61cfe
5 changed files with 27 additions and 5 deletions

View File

@@ -690,14 +690,23 @@ export default class Collection implements ViewModels.Collection {
}
public onNewMongoShellClick() {
const id = this.container.tabsManager.getTabs(ViewModels.CollectionTabKind.MongoShell).length + 1;
const mongoShellTabs = this.container.tabsManager.getTabs(
ViewModels.CollectionTabKind.MongoShell
) as MongoShellTab[];
let index = 1;
if (mongoShellTabs.length > 0) {
index = mongoShellTabs[mongoShellTabs.length - 1].index + 1;
}
const mongoShellTab: MongoShellTab = new MongoShellTab({
tabKind: ViewModels.CollectionTabKind.MongoShell,
title: "Shell " + id,
title: "Shell " + index,
tabPath: "",
collection: this,
node: this,
hashLocation: `${Constants.HashRoutePrefixes.collectionsWithIds(this.databaseId, this.id())}/mongoShell`,
index: index,
});
this.container.tabsManager.activateNewTab(mongoShellTab);