Compare commits

..

4 Commits

Author SHA1 Message Date
vaidankarswapnil
244f3ff273 Fix eslint issues for Tabsbase and JupyterLabAppFactory 2021-10-07 16:13:07 +05:30
vaidankarswapnil
ed1ffb692f Fix ally database panel open issue (#1120) 2021-10-06 07:53:46 -07:00
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
11 changed files with 47 additions and 34 deletions

View File

@@ -104,8 +104,9 @@ src/Explorer/Tabs/MongoDocumentsTab.ts
src/Explorer/Tabs/NotebookV2Tab.ts
src/Explorer/Tabs/ScriptTabBase.ts
src/Explorer/Tabs/TabComponents.ts
src/Explorer/Tabs/TabsBase.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
@@ -117,19 +118,21 @@ src/Explorer/Tree/TreeComponents.ts
src/Explorer/Tree/Trigger.ts
src/Explorer/WaitsForTemplateViewModel.ts
src/GitHub/GitHubClient.test.ts
src/GitHub/GitHubClient.ts
src/GitHub/GitHubConnector.ts
src/GitHub/GitHubOAuthService.ts
src/Index.ts
src/Juno/JunoClient.test.ts
src/Juno/JunoClient.ts
src/Platform/Hosted/Authorization.ts
src/ReactDevTools.ts
src/Shared/Constants.ts
src/Shared/DefaultExperienceUtility.test.ts
src/Shared/DefaultExperienceUtility.ts
src/Shared/appInsights.ts
src/SparkClusterManager/ArcadiaResourceManager.ts
src/SparkClusterManager/SparkClusterManager.ts
src/Terminal/JupyterLabAppFactory.ts
# src/Terminal/JupyterLabAppFactory.ts
src/Terminal/NotebookAppContracts.d.ts
src/applyExplorerBindings.ts
src/global.d.ts
@@ -154,6 +157,7 @@ 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

View File

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

View File

@@ -307,11 +307,18 @@ function createOpenSynapseLinkDialogButton(container: Explorer): CommandButtonCo
function createNewDatabase(container: Explorer): CommandButtonComponentProps {
const label = "New " + getDatabaseName();
const newDatabaseButton = document.activeElement as HTMLElement;
return {
iconSrc: AddDatabaseIcon,
iconAlt: label,
onCommandClick: () =>
useSidePanel.getState().openSidePanel("New " + getDatabaseName(), <AddDatabasePanel explorer={container} />),
useSidePanel
.getState()
.openSidePanel(
"New " + getDatabaseName(),
<AddDatabasePanel explorer={container} buttonElement={newDatabaseButton} />
),
commandButtonLabel: label,
ariaLabel: label,
hasPopup: true,

View File

@@ -31,13 +31,12 @@ import StatusBar from "./StatusBar";
import CellToolbar from "./Toolbar";
export interface NotebookRendererBaseProps {
contentRef: ContentRef;
contentRef: any;
}
interface NotebookRendererDispatchProps {
storeNotebookSnapshot: (imageSrc: string, requestId: string) => void;
notebookSnapshotError: (error: string) => void;
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) => void;
}
interface StateProps {
@@ -74,7 +73,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
componentDidMount() {
if (!userContext.features.sandboxNotebookOutputs) {
loadTransform(this.props as NotebookRendererProps);
loadTransform(this.props as any);
}
}
@@ -139,7 +138,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
}}
</CodeCell>
),
markdown: ({ id, contentRef }: { id: CellId; contentRef: ContentRef }) =>
markdown: ({ id, contentRef }: { id: any; contentRef: ContentRef }) =>
decorate(
id,
contentRef,
@@ -156,7 +155,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
</MarkdownCell>
),
raw: ({ id, contentRef }: { id: CellId; contentRef: ContentRef }) =>
raw: ({ id, contentRef }: { id: any; contentRef: ContentRef }) =>
decorate(
id,
contentRef,
@@ -203,8 +202,7 @@ export const makeMapStateToProps = (
return mapStateToProps;
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const makeMapDispatchToProps = (_initialDispatch: Dispatch, _initialProps: NotebookRendererBaseProps) => {
const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: NotebookRendererBaseProps) => {
const mapDispatchToProps = (dispatch: Dispatch) => {
return {
addTransform: (transform: React.ComponentType & { MIMETYPE: string }) =>

View File

@@ -44,7 +44,7 @@ function TabNav({ tab, active }: { tab: Tab; active: boolean }) {
onMouseOver={() => setHovering(true)}
onMouseLeave={() => setHovering(false)}
onClick={() => tab.onTabClick()}
onKeyPress={({ nativeEvent: e }) => tab.onKeyPressActivate(undefined, e)}
onKeyPress={({ nativeEvent: e }) => tab.onKeyPressActivate(e)}
className={active ? "active tabList" : "tabList"}
title={useObservable(tab.tabPath)}
aria-selected={active}
@@ -83,7 +83,7 @@ const CloseButton = ({ tab, active, hovering }: { tab: Tab; active: boolean; hov
className="cancelButton"
onClick={() => tab.onCloseTabButtonClick()}
tabIndex={active ? 0 : undefined}
onKeyPress={({ nativeEvent: e }) => tab.onKeyPressClose(undefined, e)}
onKeyPress={({ nativeEvent: e }) => tab.onKeyPressClose(e)}
>
<span className="tabIcon close-Icon">
<img src={errorIcon} title="Close" alt="Close" />
@@ -98,8 +98,8 @@ const ErrorIcon = ({ tab, active }: { tab: Tab; active: boolean }) => (
title="Click to view more details"
tabIndex={active ? 0 : undefined}
className={active ? "actionsEnabled errorIconContainer" : "errorIconContainer"}
onClick={({ nativeEvent: e }) => tab.onErrorDetailsClick(undefined, e)}
onKeyPress={({ nativeEvent: e }) => tab.onErrorDetailsKeyPress(undefined, e)}
onClick={() => tab.onErrorDetailsClick()}
onKeyPress={({ nativeEvent: e }) => tab.onErrorDetailsKeyPress(e)}
>
<span className="errorIcon" />
</div>

View File

@@ -94,11 +94,11 @@ export default class TabsBase extends WaitsForTemplateViewModel {
return true;
}
public onKeyPressActivate = (source: any, event: KeyboardEvent): boolean => {
public onKeyPressActivate = (event: KeyboardEvent): boolean => {
return this.onSpaceOrEnterKeyPress(event, () => this.onTabClick());
};
public onKeyPressClose = (source: any, event: KeyboardEvent): boolean => {
public onKeyPressClose = (event: KeyboardEvent): boolean => {
return this.onSpaceOrEnterKeyPress(event, () => this.onCloseTabButtonClick());
};
@@ -120,22 +120,22 @@ export default class TabsBase extends WaitsForTemplateViewModel {
});
}
public onErrorDetailsClick = (src: any, event: MouseEvent): boolean => {
public onErrorDetailsClick = (): boolean => {
useNotificationConsole.getState().expandConsole();
useNotificationConsole.getState().expandConsole();
return false;
};
public onErrorDetailsKeyPress = (src: any, event: KeyboardEvent): boolean => {
public onErrorDetailsKeyPress = (event: KeyboardEvent): boolean => {
if (event.keyCode === Constants.KeyCodes.Space || event.keyCode === Constants.KeyCodes.Enter) {
this.onErrorDetailsClick(src, null);
this.onErrorDetailsClick();
return false;
}
return true;
};
public refresh() {
public refresh(): void {
location.reload();
}
@@ -144,6 +144,7 @@ export default class TabsBase extends WaitsForTemplateViewModel {
}
/** Renders a Javascript object to be displayed inside Monaco Editor */
//eslint-disable-next-line
public renderObjectForEditor(value: any, replacer: any, space: string | number): string {
return JSON.stringify(value, replacer, space);
}

View File

@@ -1,9 +1,9 @@
import { Octokit } from "@octokit/rest";
import { HttpStatusCodes } from "../Common/Constants";
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
import * as Logger from "../Common/Logger";
import * as UrlUtility from "../Common/UrlUtility";
import { NotebookUtil } from "../Explorer/Notebook/NotebookUtil";
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
export interface IGitHubPageInfo {
endCursor: string;
@@ -225,7 +225,7 @@ export class GitHubClient {
private static readonly SelfErrorCode = 599;
private ocktokit: Octokit;
constructor(private errorCallback: (error: Error) => void) {
constructor(private errorCallback: (error: any) => void) {
this.initOctokit();
}
@@ -501,11 +501,10 @@ export class GitHubClient {
this.ocktokit = new Octokit({
auth: token,
log: {
// eslint-disable-next-line @typescript-eslint/no-empty-function
debug: () => {},
info: (message?: string) => GitHubClient.log(Logger.logInfo, message),
warn: (message?: string) => GitHubClient.log(Logger.logWarning, message),
error: (error?: Error) => Logger.logError(getErrorMessage(error), "GitHubClient.Octokit"),
info: (message?: any) => GitHubClient.log(Logger.logInfo, message),
warn: (message?: any) => GitHubClient.log(Logger.logWarning, message),
error: (error?: any) => Logger.logError(getErrorMessage(error), "GitHubClient.Octokit"),
},
});
@@ -515,7 +514,7 @@ export class GitHubClient {
});
}
private static log(logger: (message: string, area: string) => void, message?: string) {
private static log(logger: (message: string, area: string) => void, message?: any) {
if (message) {
message = typeof message === "string" ? message : JSON.stringify(message);
logger(message, "GitHubClient.Octokit");

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
if (window.parent !== window) {
(window as any).__REACT_DEVTOOLS_GLOBAL_HOOK__ = (window.parent as any).__REACT_DEVTOOLS_GLOBAL_HOOK__;
}

View File

@@ -5,6 +5,7 @@ import { ServerConnection, TerminalManager } from "@jupyterlab/services";
import { Terminal } from "@jupyterlab/terminal";
import { Panel, Widget } from "@phosphor/widgets";
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
export class JupyterLabAppFactory {
public static async createTerminalApp(serverSettings: ServerConnection.ISettings) {
const manager = new TerminalManager({
@@ -21,8 +22,8 @@ export class JupyterLabAppFactory {
term.title.closable = false;
term.addClass("terminalWidget");
let panel = new Panel();
panel.addWidget(term as any);
const panel = new Panel();
panel.addWidget((term as unknown) as Widget);
panel.id = "main";
// Attach the widget to the dom.

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