Compare commits

..

4 Commits

Author SHA1 Message Date
sunilyadav840
b634cd403e Merge branch 'master' of https://github.com/Azure/cosmos-explorer into eslint/fixed-gremlinClient-AccessibleVerticalList 2021-10-06 16:08:53 +05:30
sunilyadav840
2181988921 Fixed eslint issue of GremlintClient.ts and AccessibleVerticalList.ts 2021-10-06 16:08:42 +05:30
Karthik chakravarthy
f7fa3f7c09 Fix Unit Test: Mock the class to its instance (#1117)
* mock to instance

* Update jest.config.js

Co-authored-by: Jordi Bunster <jbunster@microsoft.com>
2021-10-05 13:06:26 -07:00
Jordi Bunster
6ebf19c0c9 Close tab fixes (#1107)
* Close tab fixes

Ensure that when promoting a new tab to being the 'active' tab
(as a consequence of, say, closing the active tab) that the newly
promoted tab has a chance to install its buttons and what not.

* Set new active tab even if undefined
2021-10-05 09:25:35 -07:00
12 changed files with 946 additions and 33493 deletions

View File

@@ -18,7 +18,9 @@ src/Common/MessageHandler.test.ts
src/Common/MessageHandler.ts
src/Common/MongoProxyClient.test.ts
src/Common/MongoUtility.ts
src/Common/NotificationsClientBase.ts
src/Common/QueriesClient.ts
src/Common/Splitter.ts
src/Controls/Heatmap/Heatmap.test.ts
src/Controls/Heatmap/Heatmap.ts
src/Definitions/datatables.d.ts
@@ -35,7 +37,8 @@ src/Definitions/svg.d.ts
src/Explorer/ComponentRegisterer.test.ts
src/Explorer/ComponentRegisterer.ts
src/Explorer/Controls/DiffEditor/DiffEditorComponent.ts
src/Explorer/Controls/DynamicList/DynamicList.test.ts
src/Explorer/Controls/Editor/EditorComponent.ts
src/Explorer/Controls/JsonEditor/JsonEditorComponent.ts
src/Explorer/DataSamples/ContainerSampleGenerator.test.ts
src/Explorer/DataSamples/ContainerSampleGenerator.ts
@@ -45,11 +48,9 @@ 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
@@ -104,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
@@ -149,11 +149,14 @@ src/Explorer/Graph/GraphExplorerComponent/NodePropertiesComponent.tsx
src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.test.tsx
src/Explorer/Graph/GraphExplorerComponent/ReadOnlyNodePropertiesComponent.tsx
src/Explorer/Menus/CommandBar/CommandBarUtil.tsx
src/Explorer/Notebook/NotebookComponent/NotebookComponentAdapter.tsx
src/Explorer/Notebook/NotebookComponent/NotebookComponentBootstrapper.tsx
src/Explorer/Notebook/NotebookComponent/VirtualCommandBarComponent.tsx
src/Explorer/Notebook/NotebookComponent/contents/index.tsx
src/Explorer/Notebook/NotebookRenderer/NotebookReadOnlyRenderer.tsx
src/Explorer/Notebook/NotebookRenderer/NotebookRenderer.tsx
src/Explorer/Notebook/NotebookRenderer/decorators/draggable/index.tsx
src/Explorer/Notebook/NotebookRenderer/decorators/hijack-scroll/index.tsx
src/Explorer/Notebook/NotebookRenderer/decorators/kbd-shortcuts/index.tsx
src/Explorer/Notebook/temp/inputs/connected-editors/codemirror.tsx
src/Explorer/Tree/ResourceTreeAdapter.tsx

View File

@@ -37,8 +37,8 @@ module.exports = {
global: {
branches: 25,
functions: 25,
lines: 29.5,
statements: 29.5,
lines: 29,
statements: 29,
},
},

34351
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -35,11 +35,8 @@ export class Splitter {
this.initialize();
}
public initialize(): void {
if (
document.getElementById(this.splitterId) !== undefined &&
document.getElementById(this.leftSideId) !== undefined
) {
public initialize() {
if (document.getElementById(this.splitterId) !== null && document.getElementById(this.leftSideId) != null) {
this.splitter = <HTMLElement>document.getElementById(this.splitterId);
this.leftSide = <HTMLElement>document.getElementById(this.leftSideId);
}

View File

@@ -5,7 +5,6 @@ import template from "./editor-component.html";
/**
* Helper class for ko component registration
*/
//eslint-disable-next-line
export class EditorComponent {
constructor() {
return {
@@ -39,7 +38,7 @@ class EditorViewModel extends JsonEditorViewModel {
* setTimeout is needed as creating the edtior manipulates the dom directly and expects
* Knockout to have completed all of the initial bindings for the component
*/
this.params.content() !== undefined &&
this.params.content() != null &&
setTimeout(() => {
this.createEditor(this.params.content(), this.configureEditor.bind(this));
});

View File

@@ -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)`;
}
/**

View File

@@ -16,7 +16,7 @@ export interface NotebookComponentAdapterOptions {
export class NotebookComponentAdapter extends NotebookComponentBootstrapper implements ReactAdapter {
private onUpdateKernelInfo: () => void;
public parameters: undefined;
public parameters: any;
constructor(options: NotebookComponentAdapterOptions) {
super({

View File

@@ -46,9 +46,7 @@ const makeMapStateToProps = (
const { contentRef } = initialProps;
const mapStateToProps = (state: AppState) => {
const content = selectors.content(state, { contentRef });
let kernelStatus,
kernelSpecName,
currentCellType = "";
let kernelStatus, kernelSpecName, currentCellType;
if (!content || content.type !== "notebook") {
return {

View File

@@ -1,5 +1,5 @@
// /* eslint jsx-a11y/no-static-element-interactions: 0 */
// /* eslint jsx-a11y/click-events-have-key-events: 0 */
/* eslint jsx-a11y/no-static-element-interactions: 0 */
/* eslint jsx-a11y/click-events-have-key-events: 0 */
import { actions, AppState, ContentRef, selectors } from "@nteract/core";
import React from "react";
@@ -23,7 +23,7 @@ interface DispatchProps {
type Props = ComponentProps & DispatchProps & StateProps;
export class HijackScroll extends React.Component<Props> {
el: HTMLDivElement | null | undefined = undefined;
el: HTMLDivElement | null = null;
scrollIntoViewIfNeeded(prevFocused?: boolean): void {
// Check if the element is being hovered over.
@@ -38,7 +38,6 @@ export class HijackScroll extends React.Component<Props> {
) {
if (this.el && "scrollIntoViewIfNeeded" in this.el) {
// This is only valid in Chrome, WebKit
//eslint-disable-next-line
(this.el as any).scrollIntoViewIfNeeded();
} else if (this.el) {
// Make a best guess effort for older platforms
@@ -47,7 +46,7 @@ export class HijackScroll extends React.Component<Props> {
}
}
componentDidUpdate(prevProps: Props): void {
componentDidUpdate(prevProps: Props) {
this.scrollIntoViewIfNeeded(prevProps.focused);
}
@@ -55,7 +54,7 @@ export class HijackScroll extends React.Component<Props> {
this.scrollIntoViewIfNeeded();
}
render(): JSX.Element {
render() {
return (
<div
onClick={this.props.selectCell}

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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 });