mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-23 10:51:30 +00:00
Compare commits
4 Commits
eslint/fix
...
eslint/fix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b634cd403e | ||
|
|
2181988921 | ||
|
|
f7fa3f7c09 | ||
|
|
6ebf19c0c9 |
@@ -44,13 +44,13 @@ src/Explorer/DataSamples/ContainerSampleGenerator.test.ts
|
||||
src/Explorer/DataSamples/ContainerSampleGenerator.ts
|
||||
src/Explorer/DataSamples/DataSamplesUtil.test.ts
|
||||
src/Explorer/DataSamples/DataSamplesUtil.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/ArraysByKeyCache.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/D3ForceGraph.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/EdgeInfoCache.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GraphData.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GraphData.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinClient.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.test.ts
|
||||
src/Explorer/Graph/GraphExplorerComponent/GremlinSimpleClient.ts
|
||||
src/Explorer/Menus/ContextMenu.ts
|
||||
@@ -105,7 +105,6 @@ src/Explorer/Tabs/TabComponents.ts
|
||||
src/Explorer/Tabs/TabsBase.ts
|
||||
src/Explorer/Tabs/TriggerTab.ts
|
||||
src/Explorer/Tabs/UserDefinedFunctionTab.ts
|
||||
src/Explorer/Tree/AccessibleVerticalList.ts
|
||||
src/Explorer/Tree/Collection.ts
|
||||
src/Explorer/Tree/ConflictId.ts
|
||||
src/Explorer/Tree/DocumentId.ts
|
||||
|
||||
@@ -37,8 +37,8 @@ module.exports = {
|
||||
global: {
|
||||
branches: 25,
|
||||
functions: 25,
|
||||
lines: 29.5,
|
||||
statements: 29.5,
|
||||
lines: 29,
|
||||
statements: 29,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ describe("Cache arrays by key", () => {
|
||||
const key = "key";
|
||||
cache.insert(key, 1, 0);
|
||||
cache.clear();
|
||||
expect(cache.retrieve(key, 0, 1)).toBe(undefined);
|
||||
expect(cache.retrieve(key, 0, 1)).toBe(null);
|
||||
});
|
||||
|
||||
it("should invalidate oldest key to keep cache size under maximum", () => {
|
||||
@@ -21,7 +21,7 @@ describe("Cache arrays by key", () => {
|
||||
cache.insert(key1, 2, 4);
|
||||
|
||||
expect(cache.retrieve(key1, 0, 3)).toEqual([0, 2, 4]);
|
||||
expect(cache.retrieve(key2, 1, 1)).toEqual(undefined);
|
||||
expect(cache.retrieve(key2, 1, 1)).toEqual(null);
|
||||
});
|
||||
|
||||
it("should cache and retrieve cached page within boundaries", () => {
|
||||
@@ -39,7 +39,7 @@ describe("Cache arrays by key", () => {
|
||||
const key = "key";
|
||||
cache.insert(key, 0, 0);
|
||||
cache.insert(key, 1, 1);
|
||||
expect(cache.retrieve(key, 2, 1)).toEqual(undefined);
|
||||
expect(cache.retrieve(key, 2, 1)).toEqual(null);
|
||||
});
|
||||
|
||||
it("should not retrieve cached page overlapping boundaries", () => {
|
||||
@@ -48,7 +48,7 @@ describe("Cache arrays by key", () => {
|
||||
cache.insert(key, 0, 0);
|
||||
cache.insert(key, 1, 1);
|
||||
cache.insert(key, 2, 2);
|
||||
expect(cache.retrieve(key, 2, 4)).toEqual(undefined);
|
||||
expect(cache.retrieve(key, 2, 4)).toEqual(null);
|
||||
});
|
||||
|
||||
it("should not insert non-contiguous element", () => {
|
||||
@@ -57,7 +57,7 @@ describe("Cache arrays by key", () => {
|
||||
cache.insert(key, 0, 0);
|
||||
cache.insert(key, 1, 1);
|
||||
cache.insert(key, 3, 3);
|
||||
expect(cache.retrieve(key, 3, 1)).toEqual(undefined);
|
||||
expect(cache.retrieve(key, 3, 1)).toEqual(null);
|
||||
});
|
||||
|
||||
it("should cache multiple keys", () => {
|
||||
|
||||
@@ -61,12 +61,12 @@ export class ArraysByKeyCache<T> {
|
||||
* @param pageSize
|
||||
*/
|
||||
public retrieve(key: string, startIndex: number, pageSize: number): T[] | null {
|
||||
if (!Object.prototype.hasOwnProperty.call(this.cache, key)) {
|
||||
return undefined;
|
||||
if (!this.cache.hasOwnProperty(key)) {
|
||||
return null;
|
||||
}
|
||||
const elements = this.cache[key];
|
||||
if (startIndex + pageSize > elements.length) {
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
|
||||
return elements.slice(startIndex, startIndex + pageSize);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/**
|
||||
* Wrapper around GremlinSimpleClient using Q promises and tailored to cosmosdb authentication
|
||||
*/
|
||||
@@ -55,7 +56,7 @@ export class GremlinClient {
|
||||
this.flushResult(result.requestId);
|
||||
}
|
||||
},
|
||||
failureCallback: (result: Result, error: any) => {
|
||||
failureCallback: (result: Result, error: string) => {
|
||||
const errorMessage = getErrorMessage(error);
|
||||
const requestId = result.requestId;
|
||||
|
||||
@@ -68,7 +69,7 @@ export class GremlinClient {
|
||||
// Fail all pending requests if no request id (fatal)
|
||||
if (!requestId) {
|
||||
for (const reqId of this.pendingResults.keys()) {
|
||||
this.abortPendingRequest(reqId, errorMessage, null);
|
||||
this.abortPendingRequest(reqId, errorMessage, undefined);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -89,7 +90,7 @@ export class GremlinClient {
|
||||
},
|
||||
deferred: deferred,
|
||||
timeoutId: window.setTimeout(
|
||||
() => this.abortPendingRequest(requestId, GremlinClient.TIMEOUT_ERROR_MSG, null),
|
||||
() => this.abortPendingRequest(requestId, GremlinClient.TIMEOUT_ERROR_MSG, undefined),
|
||||
GremlinClient.PENDING_REQUEST_TIMEOUT_MS
|
||||
),
|
||||
});
|
||||
@@ -101,7 +102,7 @@ export class GremlinClient {
|
||||
return;
|
||||
}
|
||||
this.client.close();
|
||||
this.client = null;
|
||||
this.client = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,7 +111,8 @@ export class GremlinClient {
|
||||
* @return request charge or empty string
|
||||
*/
|
||||
public static getRequestChargeString(requestCharge: string | number): string {
|
||||
return requestCharge == undefined || requestCharge == null ? "" : `(${requestCharge} RUs)`;
|
||||
// eslint-disable-next-line no-null/no-null
|
||||
return requestCharge === undefined || requestCharge === null ? "" : `(${requestCharge} RUs)`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as _ from "underscore";
|
||||
import * as ko from "knockout";
|
||||
import * as _ from "underscore";
|
||||
|
||||
enum ScrollPosition {
|
||||
Top,
|
||||
@@ -7,25 +7,25 @@ enum ScrollPosition {
|
||||
}
|
||||
|
||||
export class AccessibleVerticalList {
|
||||
private items: any[] = [];
|
||||
private onSelect?: (item: any) => void;
|
||||
private items: unknown[] = [];
|
||||
private onSelect?: (item: unknown) => void;
|
||||
|
||||
public currentItemIndex: ko.Observable<number>;
|
||||
public currentItem: ko.Computed<any>;
|
||||
public currentItem: ko.Computed<unknown>;
|
||||
|
||||
constructor(initialSetOfItems: any[]) {
|
||||
constructor(initialSetOfItems: unknown[]) {
|
||||
this.items = initialSetOfItems;
|
||||
this.currentItemIndex = this.items != null && this.items.length > 0 ? ko.observable(0) : ko.observable(-1);
|
||||
this.currentItem = ko.computed<any>(() => this.items[this.currentItemIndex()]);
|
||||
this.currentItemIndex = this.items !== undefined && this.items.length > 0 ? ko.observable(0) : ko.observable(-1);
|
||||
this.currentItem = ko.computed<unknown>(() => this.items[this.currentItemIndex()]);
|
||||
}
|
||||
|
||||
public setOnSelect(onSelect: (item: any) => void): void {
|
||||
public setOnSelect(onSelect: (item: unknown) => void): void {
|
||||
this.onSelect = onSelect;
|
||||
}
|
||||
|
||||
public onKeyDown = (_src: unknown, event: KeyboardEvent): boolean => {
|
||||
const targetContainer: Element = <Element>event.target;
|
||||
if (this.items == null || this.items.length === 0) {
|
||||
if (this.items === undefined || this.items.length === 0) {
|
||||
// no items so this should be a noop
|
||||
return true;
|
||||
}
|
||||
@@ -62,8 +62,8 @@ export class AccessibleVerticalList {
|
||||
return true;
|
||||
};
|
||||
|
||||
public updateItemList(newItemList: any[]) {
|
||||
if (newItemList == null || newItemList.length === 0) {
|
||||
public updateItemList(newItemList: unknown[]): void {
|
||||
if (newItemList === undefined || newItemList.length === 0) {
|
||||
this.currentItemIndex(-1);
|
||||
this.items = [];
|
||||
return;
|
||||
@@ -73,7 +73,7 @@ export class AccessibleVerticalList {
|
||||
this.items = newItemList;
|
||||
}
|
||||
|
||||
public updateCurrentItem(item: any) {
|
||||
public updateCurrentItem(item: unknown): void {
|
||||
const updatedIndex: number = this.isItemListEmpty() ? -1 : _.indexOf(this.items, item);
|
||||
this.currentItemIndex(updatedIndex);
|
||||
}
|
||||
@@ -118,6 +118,6 @@ export class AccessibleVerticalList {
|
||||
}
|
||||
|
||||
private isItemListEmpty(): boolean {
|
||||
return this.items == null || this.items.length === 0;
|
||||
return this.items === undefined || this.items.length === 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ describe("GalleryUtils", () => {
|
||||
});
|
||||
|
||||
it("downloadItem shows dialog in data explorer", () => {
|
||||
const container = {} as Explorer;
|
||||
const container = new Explorer();
|
||||
GalleryUtils.downloadItem(container, undefined, galleryItem, undefined);
|
||||
|
||||
expect(useDialog.getState().visible).toBe(true);
|
||||
|
||||
@@ -69,7 +69,11 @@ export const useTabs: UseStore<TabsState> = create((set, get) => ({
|
||||
if (tab.tabId === activeTab.tabId && tabIndex !== -1) {
|
||||
const tabToTheRight = updatedTabs[tabIndex];
|
||||
const lastOpenTab = updatedTabs[updatedTabs.length - 1];
|
||||
set({ activeTab: tabToTheRight || lastOpenTab });
|
||||
const newActiveTab = tabToTheRight ?? lastOpenTab;
|
||||
set({ activeTab: newActiveTab });
|
||||
if (newActiveTab) {
|
||||
newActiveTab.onActivate();
|
||||
}
|
||||
}
|
||||
|
||||
set({ openedTabs: updatedTabs });
|
||||
|
||||
Reference in New Issue
Block a user