TabsManager in react (#500)

This commit is contained in:
Jordi Bunster
2021-04-19 13:11:48 -07:00
committed by GitHub
parent 19cf203606
commit f2585bba14
8 changed files with 147 additions and 152 deletions

View File

@@ -1,5 +1,4 @@
import * as ko from "knockout";
import Q from "q";
import * as Constants from "../../Common/Constants";
import * as ThemeUtility from "../../Common/ThemeUtility";
import * as DataModels from "../../Contracts/DataModels";
@@ -21,15 +20,13 @@ export default class TabsBase extends WaitsForTemplateViewModel {
public collection: ViewModels.CollectionBase;
public database: ViewModels.Database;
public rid: string;
public hasFocus: ko.Observable<boolean>;
public isMouseOver: ko.Observable<boolean>;
public tabId = `tab${TabsBase.id++}`;
public tabKind: ViewModels.CollectionTabKind;
public tabTitle: ko.Observable<string>;
public tabPath: ko.Observable<string>;
public hashLocation: ko.Observable<string>;
public isExecutionError: ko.Observable<boolean>;
public isExecuting: ko.Observable<boolean>;
public isExecutionError = ko.observable(false);
public isExecuting = ko.observable(false);
public pendingNotification?: ko.Observable<DataModels.Notification>;
public manager?: TabsManager;
protected _theme: string;
@@ -42,16 +39,12 @@ export default class TabsBase extends WaitsForTemplateViewModel {
this.collection = options.collection;
this.database = options.database;
this.rid = options.rid || (this.collection && this.collection.rid) || "";
this.hasFocus = ko.observable<boolean>(false);
this.isMouseOver = ko.observable<boolean>(false);
this.tabKind = options.tabKind;
this.tabTitle = ko.observable<string>(options.title);
this.tabPath =
ko.observable(options.tabPath ?? "") ||
(this.collection &&
ko.observable<string>(`${this.collection.databaseId}>${this.collection.id()}>${this.tabTitle()}`));
this.isExecutionError = ko.observable<boolean>(false);
this.isExecuting = ko.observable<boolean>(false);
this.pendingNotification = ko.observable<DataModels.Notification>(undefined);
this.onLoadStartKey = options.onLoadStartKey;
this.hashLocation = ko.observable<string>(options.hashLocation || "");
@@ -117,22 +110,12 @@ export default class TabsBase extends WaitsForTemplateViewModel {
public onActivate(): void {
this.updateSelectedNode();
if (!!this.collection) {
this.collection.selectedSubnodeKind(this.tabKind);
}
if (!!this.database) {
this.database.selectedSubnodeKind(this.tabKind);
}
this.hasFocus(true);
this.collection?.selectedSubnodeKind(this.tabKind);
this.database?.selectedSubnodeKind(this.tabKind);
this.updateGlobalHash(this.hashLocation());
this.updateNavbarWithTabsButtons();
TelemetryProcessor.trace(Action.Tab, ActionModifiers.Open, {
tabName: this.constructor.name,
dataExplorerArea: Constants.Areas.Tab,
tabTitle: this.tabTitle(),
tabId: this.tabId,
@@ -140,13 +123,8 @@ export default class TabsBase extends WaitsForTemplateViewModel {
}
public onErrorDetailsClick = (src: any, event: MouseEvent): boolean => {
if (this.collection && this.collection.container) {
this.collection.container.expandConsole();
}
if (this.database && this.database.container) {
this.database.container.expandConsole();
}
this.collection?.container?.expandConsole();
this.database?.container?.expandConsole();
return false;
};
@@ -159,9 +137,8 @@ export default class TabsBase extends WaitsForTemplateViewModel {
return true;
};
public refresh(): Q.Promise<any> {
public refresh() {
location.reload();
return Q();
}
public getContainer(): Explorer {
@@ -190,8 +167,3 @@ export default class TabsBase extends WaitsForTemplateViewModel {
}
};
}
interface EditorPosition {
line: number;
column: number;
}