Add container ids to tabs (#1772)
* Added container ids to tabs * prettier run * Updated for undefined scenarios * prettier * added ellipsis to long container names * added slice * prettier * Added ellipsis to long DB names in tabs * Added undefined DB case * Replaced dots with ellipsis character * corrected undefined return value
This commit is contained in:
parent
0df68c4967
commit
56408a97d7
|
@ -40,11 +40,10 @@ export default class TabsBase extends WaitsForTemplateViewModel {
|
||||||
this.database = options.database;
|
this.database = options.database;
|
||||||
this.rid = options.rid || (this.collection && this.collection.rid) || "";
|
this.rid = options.rid || (this.collection && this.collection.rid) || "";
|
||||||
this.tabKind = options.tabKind;
|
this.tabKind = options.tabKind;
|
||||||
this.tabTitle = ko.observable<string>(options.title);
|
this.tabTitle = ko.observable<string>(this.getTitle(options));
|
||||||
this.tabPath =
|
this.tabPath =
|
||||||
ko.observable(options.tabPath ?? "") ||
|
this.collection &&
|
||||||
(this.collection &&
|
ko.observable<string>(`${this.collection.databaseId}>${this.collection.id()}>${options.title}`);
|
||||||
ko.observable<string>(`${this.collection.databaseId}>${this.collection.id()}>${this.tabTitle()}`));
|
|
||||||
this.pendingNotification = ko.observable<DataModels.Notification>(undefined);
|
this.pendingNotification = ko.observable<DataModels.Notification>(undefined);
|
||||||
this.onLoadStartKey = options.onLoadStartKey;
|
this.onLoadStartKey = options.onLoadStartKey;
|
||||||
this.closeTabButton = {
|
this.closeTabButton = {
|
||||||
|
@ -143,6 +142,26 @@ export default class TabsBase extends WaitsForTemplateViewModel {
|
||||||
return (this.collection && this.collection.container) || (this.database && this.database.container);
|
return (this.collection && this.collection.container) || (this.database && this.database.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getTitle(options: ViewModels.TabOptions): string {
|
||||||
|
const coll = this.collection?.id();
|
||||||
|
const db = this.database?.id();
|
||||||
|
if (coll) {
|
||||||
|
if (coll.length > 8) {
|
||||||
|
return coll.slice(0, 5) + "…" + options.title;
|
||||||
|
} else {
|
||||||
|
return coll + "." + options.title;
|
||||||
|
}
|
||||||
|
} else if (db) {
|
||||||
|
if (db.length > 8) {
|
||||||
|
return db.slice(0, 5) + "…" + options.title;
|
||||||
|
} else {
|
||||||
|
return db + "." + options.title;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return options.title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Renders a Javascript object to be displayed inside Monaco Editor */
|
/** Renders a Javascript object to be displayed inside Monaco Editor */
|
||||||
public renderObjectForEditor(value: any, replacer: any, space: string | number): string {
|
public renderObjectForEditor(value: any, replacer: any, space: string | number): string {
|
||||||
return JSON.stringify(value, replacer, space);
|
return JSON.stringify(value, replacer, space);
|
||||||
|
|
|
@ -308,7 +308,7 @@ export default class Collection implements ViewModels.Collection {
|
||||||
collectionName: this.id(),
|
collectionName: this.id(),
|
||||||
|
|
||||||
dataExplorerArea: Constants.Areas.Tab,
|
dataExplorerArea: Constants.Areas.Tab,
|
||||||
tabTitle: this.rawDataModel.id + " - Items",
|
tabTitle: "Items",
|
||||||
});
|
});
|
||||||
this.documentIds([]);
|
this.documentIds([]);
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ export default class Collection implements ViewModels.Collection {
|
||||||
partitionKey: this.partitionKey,
|
partitionKey: this.partitionKey,
|
||||||
documentIds: ko.observableArray<DocumentId>([]),
|
documentIds: ko.observableArray<DocumentId>([]),
|
||||||
tabKind: ViewModels.CollectionTabKind.Documents,
|
tabKind: ViewModels.CollectionTabKind.Documents,
|
||||||
title: this.rawDataModel.id + " - Items",
|
title: "Items",
|
||||||
collection: this,
|
collection: this,
|
||||||
node: this,
|
node: this,
|
||||||
tabPath: `${this.databaseId}>${this.id()}>Documents`,
|
tabPath: `${this.databaseId}>${this.id()}>Documents`,
|
||||||
|
|
Loading…
Reference in New Issue