mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-19 17:01:13 +00:00
Update prettier to latest. Remove tslint (#1641)
* Rev up prettier * Reformat * Remove deprecated tslint * Remove call to tslint and update package-lock.json
This commit is contained in:
@@ -72,7 +72,7 @@ export class NotebookClientV2 {
|
||||
actions.fetchKernelspecs({
|
||||
hostRef: this.contentHostRef,
|
||||
kernelspecsRef: this.kernelSpecsRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -192,36 +192,36 @@ export class NotebookClientV2 {
|
||||
* is triggered for *any* state change).
|
||||
* TODO: Use react-redux connect() to subscribe to state changes?
|
||||
*/
|
||||
const cacheKernelSpecsMiddleware: Middleware = <D extends Dispatch<AnyAction>, S extends AppState>({
|
||||
dispatch,
|
||||
getState,
|
||||
}: MiddlewareAPI<D, S>) => (next: Dispatch<AnyAction>) => <A extends AnyAction>(action: A): A => {
|
||||
switch (action.type) {
|
||||
case actions.FETCH_KERNELSPECS_FULFILLED: {
|
||||
const payload = ((action as unknown) as actions.FetchKernelspecsFulfilled).payload;
|
||||
const defaultKernelName = payload.defaultKernelName;
|
||||
this.kernelSpecsForDisplay = Object.values(payload.kernelspecs)
|
||||
.filter((spec) => !spec.metadata?.hasOwnProperty("hidden"))
|
||||
.map((spec) => ({
|
||||
name: spec.name,
|
||||
displayName: spec.displayName,
|
||||
}))
|
||||
.sort((a: KernelSpecsDisplay, b: KernelSpecsDisplay) => {
|
||||
// Put default at the top, otherwise lexicographically compare
|
||||
if (a.displayName === defaultKernelName) {
|
||||
return -1;
|
||||
} else if (b.name === defaultKernelName) {
|
||||
return 1;
|
||||
} else {
|
||||
return a.displayName.localeCompare(b.displayName);
|
||||
}
|
||||
});
|
||||
break;
|
||||
const cacheKernelSpecsMiddleware: Middleware =
|
||||
<D extends Dispatch<AnyAction>, S extends AppState>({ dispatch, getState }: MiddlewareAPI<D, S>) =>
|
||||
(next: Dispatch<AnyAction>) =>
|
||||
<A extends AnyAction>(action: A): A => {
|
||||
switch (action.type) {
|
||||
case actions.FETCH_KERNELSPECS_FULFILLED: {
|
||||
const payload = (action as unknown as actions.FetchKernelspecsFulfilled).payload;
|
||||
const defaultKernelName = payload.defaultKernelName;
|
||||
this.kernelSpecsForDisplay = Object.values(payload.kernelspecs)
|
||||
.filter((spec) => !spec.metadata?.hasOwnProperty("hidden"))
|
||||
.map((spec) => ({
|
||||
name: spec.name,
|
||||
displayName: spec.displayName,
|
||||
}))
|
||||
.sort((a: KernelSpecsDisplay, b: KernelSpecsDisplay) => {
|
||||
// Put default at the top, otherwise lexicographically compare
|
||||
if (a.displayName === defaultKernelName) {
|
||||
return -1;
|
||||
} else if (b.name === defaultKernelName) {
|
||||
return 1;
|
||||
} else {
|
||||
return a.displayName.localeCompare(b.displayName);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return next(action);
|
||||
};
|
||||
return next(action);
|
||||
};
|
||||
|
||||
const traceErrorFct = (title: string, message: string) => {
|
||||
TelemetryProcessor.traceFailure(Action.NotebookErrorNotification, {
|
||||
@@ -238,13 +238,13 @@ export class NotebookClientV2 {
|
||||
params.contentProvider,
|
||||
traceErrorFct,
|
||||
[cacheKernelSpecsMiddleware],
|
||||
!params.isReadOnly
|
||||
!params.isReadOnly,
|
||||
);
|
||||
|
||||
// Additional configuration
|
||||
this.store.dispatch(configOption("editorType").action(params.cellEditorType ?? "codemirror"));
|
||||
this.store.dispatch(
|
||||
configOption("autoSaveInterval").action(params.autoSaveInterval ?? Constants.Notebook.autoSaveIntervalMs)
|
||||
configOption("autoSaveInterval").action(params.autoSaveInterval ?? Constants.Notebook.autoSaveIntervalMs),
|
||||
);
|
||||
this.store.dispatch(configOption("codeMirror.lineNumbers").action(true));
|
||||
|
||||
|
||||
@@ -12,7 +12,10 @@ export interface InMemoryContentProviderParams {
|
||||
// Nteract relies on `errno` property to figure out the kind of failure
|
||||
// That's why we need a custom wrapper around Error to include `errno` property
|
||||
class InMemoryContentProviderError extends Error {
|
||||
constructor(error: string, public errno: number = InMemoryContentProvider.SelfErrorCode) {
|
||||
constructor(
|
||||
error: string,
|
||||
public errno: number = InMemoryContentProvider.SelfErrorCode,
|
||||
) {
|
||||
super(error);
|
||||
}
|
||||
}
|
||||
@@ -47,7 +50,7 @@ export class InMemoryContentProvider implements IContentProvider {
|
||||
public save<FT extends FileType>(
|
||||
_config: ServerConfig, // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
uri: string,
|
||||
model: Partial<IContent<FT>>
|
||||
model: Partial<IContent<FT>>,
|
||||
): Observable<AjaxResponse> {
|
||||
const item = this.params[uri];
|
||||
if (item) {
|
||||
|
||||
@@ -39,7 +39,7 @@ export class NotebookComponentAdapter extends NotebookComponentBootstrapper impl
|
||||
params: {},
|
||||
kernelRef,
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ export class NotebookComponentBootstrapper {
|
||||
model: NotebookComponentBootstrapper.wrapModelIntoContent(name, undefined, content),
|
||||
kernelRef: undefined,
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ export class NotebookComponentBootstrapper {
|
||||
*/
|
||||
public renderComponent(
|
||||
renderer?: any, // TODO FIX THIS React.ComponentClass<{ contentRef: ContentRef; isReadOnly?: boolean }>,
|
||||
props?: any
|
||||
props?: any,
|
||||
): JSX.Element {
|
||||
return (
|
||||
<Provider store={this.getStore()}>
|
||||
@@ -149,18 +149,18 @@ export class NotebookComponentBootstrapper {
|
||||
this.getStore().dispatch(
|
||||
actions.save({
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
"Cancel",
|
||||
undefined,
|
||||
this.getSaveNotebookSubText()
|
||||
this.getSaveNotebookSubText(),
|
||||
);
|
||||
} else {
|
||||
this.getStore().dispatch(
|
||||
actions.save({
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ export class NotebookComponentBootstrapper {
|
||||
contentRef: this.contentRef,
|
||||
kernelSpecName,
|
||||
oldKernelRef: this.getCurrentKernelRef(),
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ export class NotebookComponentBootstrapper {
|
||||
this.getStore().dispatch(
|
||||
CdbActions.executeFocusedCellAndFocusNext({
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ export class NotebookComponentBootstrapper {
|
||||
this.getStore().dispatch(
|
||||
actions.executeAllCells({
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ export class NotebookComponentBootstrapper {
|
||||
this.getStore().dispatch(
|
||||
actions.interruptKernel({
|
||||
kernelRef: this.getCurrentKernelRef(),
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ export class NotebookComponentBootstrapper {
|
||||
actions.killKernel({
|
||||
restarting: false,
|
||||
kernelRef: this.getCurrentKernelRef(),
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ export class NotebookComponentBootstrapper {
|
||||
kernelRef: this.getCurrentKernelRef(),
|
||||
contentRef: this.contentRef,
|
||||
outputHandling: "None",
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ export class NotebookComponentBootstrapper {
|
||||
this.getStore().dispatch(
|
||||
actions.clearAllOutputs({
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ export class NotebookComponentBootstrapper {
|
||||
actions.createCellBelow({
|
||||
cellType: "code",
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ export class NotebookComponentBootstrapper {
|
||||
id: focusedCellId,
|
||||
contentRef: this.contentRef,
|
||||
to: type,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ export class NotebookComponentBootstrapper {
|
||||
actions.copyCell({
|
||||
id: focusedCellId,
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ export class NotebookComponentBootstrapper {
|
||||
actions.cutCell({
|
||||
id: focusedCellId,
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ export class NotebookComponentBootstrapper {
|
||||
this.getStore().dispatch(
|
||||
actions.pasteCell({
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -298,14 +298,14 @@ export class NotebookComponentBootstrapper {
|
||||
actions.killKernel({
|
||||
restarting: false,
|
||||
kernelRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
store.dispatch(
|
||||
CdbActions.closeNotebook({
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export class NotebookContentProvider implements IContentProvider {
|
||||
constructor(
|
||||
private inMemoryContentProvider: InMemoryContentProvider,
|
||||
private gitHubContentProvider: GitHubContentProvider,
|
||||
private jupyterContentProvider: IContentProvider
|
||||
private jupyterContentProvider: IContentProvider,
|
||||
) {}
|
||||
|
||||
public remove(serverConfig: ServerConfig, path: string): Observable<AjaxResponse> {
|
||||
@@ -24,7 +24,7 @@ export class NotebookContentProvider implements IContentProvider {
|
||||
public update<FT extends FileType>(
|
||||
serverConfig: ServerConfig,
|
||||
path: string,
|
||||
model: Partial<IContent<FT>>
|
||||
model: Partial<IContent<FT>>,
|
||||
): Observable<AjaxResponse> {
|
||||
return this.getContentProvider(path).update(serverConfig, path, model);
|
||||
}
|
||||
@@ -32,7 +32,7 @@ export class NotebookContentProvider implements IContentProvider {
|
||||
public create<FT extends FileType>(
|
||||
serverConfig: ServerConfig,
|
||||
path: string,
|
||||
model: Partial<IContent<FT>> & { type: FT }
|
||||
model: Partial<IContent<FT>> & { type: FT },
|
||||
): Observable<AjaxResponse> {
|
||||
return this.getContentProvider(path).create(serverConfig, path, model);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ export class NotebookContentProvider implements IContentProvider {
|
||||
public save<FT extends FileType>(
|
||||
serverConfig: ServerConfig,
|
||||
path: string,
|
||||
model: Partial<IContent<FT>>
|
||||
model: Partial<IContent<FT>>,
|
||||
): Observable<AjaxResponse> {
|
||||
return this.getContentProvider(path).save(serverConfig, path, model);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ export class NotebookContentProvider implements IContentProvider {
|
||||
public restoreFromCheckpoint(
|
||||
serverConfig: ServerConfig,
|
||||
path: string,
|
||||
checkpointID: string
|
||||
checkpointID: string,
|
||||
): Observable<AjaxResponse> {
|
||||
return this.getContentProvider(path).restoreFromCheckpoint(serverConfig, path, checkpointID);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ interface InitialProps {
|
||||
// Redux
|
||||
const makeMapStateToProps = (
|
||||
initialState: AppState,
|
||||
initialProps: InitialProps
|
||||
initialProps: InitialProps,
|
||||
): ((state: AppState) => VirtualCommandBarComponentProps) => {
|
||||
const { contentRef } = initialProps;
|
||||
const mapStateToProps = (state: AppState) => {
|
||||
|
||||
@@ -84,7 +84,7 @@ interface InitialProps {
|
||||
|
||||
function makeMapStateToTextFileProps(
|
||||
initialState: AppState,
|
||||
initialProps: InitialProps
|
||||
initialProps: InitialProps,
|
||||
): (state: AppState) => MappedStateProps {
|
||||
const { contentRef } = initialProps;
|
||||
|
||||
@@ -107,7 +107,7 @@ function makeMapStateToTextFileProps(
|
||||
|
||||
const makeMapDispatchToTextFileProps = (
|
||||
initialDispatch: Dispatch,
|
||||
initialProps: InitialProps
|
||||
initialProps: InitialProps,
|
||||
): ((dispatch: Dispatch) => MappedDispatchProps) => {
|
||||
const { contentRef } = initialProps;
|
||||
|
||||
@@ -118,7 +118,7 @@ const makeMapDispatchToTextFileProps = (
|
||||
actions.updateFileText({
|
||||
contentRef,
|
||||
text: source,
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -128,7 +128,7 @@ const makeMapDispatchToTextFileProps = (
|
||||
|
||||
const ConnectedTextFile = connect<MappedStateProps, MappedDispatchProps, InitialProps, AppState>(
|
||||
makeMapStateToTextFileProps,
|
||||
makeMapDispatchToTextFileProps
|
||||
makeMapDispatchToTextFileProps,
|
||||
)(TextFile);
|
||||
|
||||
export function handles(mimetype: string) {
|
||||
|
||||
@@ -141,7 +141,7 @@ const mapDispatchToProps = (dispatch: Dispatch, ownProps: ContentsProps): object
|
||||
actions.overwriteMetadataFields({
|
||||
...props,
|
||||
contentRef: ownProps.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
// `HotKeys` handlers object
|
||||
|
||||
@@ -131,7 +131,7 @@ describe("launchWebSocketKernelEpic", () => {
|
||||
kernelSpecName,
|
||||
cwd,
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
(sessions as any).__setResponse({
|
||||
@@ -197,7 +197,7 @@ describe("launchWebSocketKernelEpic", () => {
|
||||
kernelSpecName,
|
||||
cwd,
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
(sessions as any).__setResponse({
|
||||
@@ -250,7 +250,7 @@ describe("launchWebSocketKernelEpic", () => {
|
||||
kernelSpecName: undefined,
|
||||
cwd,
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
(sessions as any).__setResponse({
|
||||
@@ -299,7 +299,7 @@ describe("launchWebSocketKernelEpic", () => {
|
||||
kernelSpecName: undefined,
|
||||
cwd,
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
(sessions as any).__setResponse({
|
||||
@@ -397,7 +397,7 @@ describe("launchWebSocketKernelEpic", () => {
|
||||
kernelSpecName: "kernel2",
|
||||
cwd: "cwd",
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
await launchWebSocketKernelEpic(action$, state$).pipe(toArray()).toPromise();
|
||||
@@ -418,7 +418,7 @@ describe("launchWebSocketKernelEpic", () => {
|
||||
kernelSpecName: undefined,
|
||||
cwd: "cwd",
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
await launchWebSocketKernelEpic(action$, state$).pipe(toArray()).toPromise();
|
||||
@@ -440,7 +440,7 @@ describe("launchWebSocketKernelEpic", () => {
|
||||
kernelSpecName: "This is an unknown kernelspec",
|
||||
cwd: "cwd",
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
await launchWebSocketKernelEpic(action$, state$).pipe(toArray()).toPromise();
|
||||
@@ -462,7 +462,7 @@ describe("launchWebSocketKernelEpic", () => {
|
||||
kernelSpecName: "ernel1",
|
||||
cwd: "cwd",
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
await launchWebSocketKernelEpic(action$, state$).pipe(toArray()).toPromise();
|
||||
|
||||
@@ -66,7 +66,7 @@ const logFailureToTelemetry = (state: CdbAppState, title: string, error?: string
|
||||
*/
|
||||
const addInitialCodeCellEpic = (
|
||||
action$: Observable<actions.FetchContentFulfilled>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<{} | actions.CreateCellBelow> => {
|
||||
return action$.pipe(
|
||||
ofType(actions.FETCH_CONTENT_FULFILLED),
|
||||
@@ -86,12 +86,12 @@ const addInitialCodeCellEpic = (
|
||||
actions.createCellAppend({
|
||||
cellType: "code",
|
||||
contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return EMPTY;
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -126,7 +126,7 @@ export const acquireKernelInfoEpic = (action$: Observable<actions.NewKernelActio
|
||||
},
|
||||
} = action;
|
||||
return acquireKernelInfo(channels, kernelRef, contentRef);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -183,7 +183,7 @@ function acquireKernelInfo(channels: Channels, kernelRef: KernelRef, contentRef:
|
||||
kernelRef,
|
||||
contentRef,
|
||||
error: new Error(
|
||||
"The kernel that you are attempting to launch does not support the latest version (v5) of the messaging protocol."
|
||||
"The kernel that you are attempting to launch does not support the latest version (v5) of the messaging protocol.",
|
||||
),
|
||||
}),
|
||||
];
|
||||
@@ -203,7 +203,7 @@ function acquireKernelInfo(channels: Channels, kernelRef: KernelRef, contentRef:
|
||||
}
|
||||
|
||||
return of(...result);
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
return Observable.create((observer: Observer<any>) => {
|
||||
@@ -246,13 +246,13 @@ const connect = (serverConfig: NotebookServiceConfig, kernelID: string, sessionI
|
||||
}
|
||||
},
|
||||
(e: Error) => wsSubject.error(e),
|
||||
() => wsSubject.complete()
|
||||
() => wsSubject.complete(),
|
||||
), // Subscriber
|
||||
// Subject.create takes a subscriber and an observable. We're only
|
||||
// overriding the subscriber here so we pass the subject on as an
|
||||
// observable as the second argument to Subject.create (since it's
|
||||
// _also_ an observable)
|
||||
wsSubject
|
||||
wsSubject,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -268,7 +268,7 @@ const connect = (serverConfig: NotebookServiceConfig, kernelID: string, sessionI
|
||||
*/
|
||||
export const launchWebSocketKernelEpic = (
|
||||
action$: Observable<actions.LaunchKernelByNameAction>,
|
||||
state$: StateObservable<CdbAppState>
|
||||
state$: StateObservable<CdbAppState>,
|
||||
) => {
|
||||
return action$.pipe(
|
||||
ofType(actions.LAUNCH_KERNEL_BY_NAME),
|
||||
@@ -305,10 +305,10 @@ export const launchWebSocketKernelEpic = (
|
||||
return of(
|
||||
actions.launchKernelFailed({
|
||||
error: new Error(
|
||||
"Unable to launch kernel: no kernelspec name specified to launch and no default kernelspecs"
|
||||
"Unable to launch kernel: no kernelspec name specified to launch and no default kernelspecs",
|
||||
),
|
||||
contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
} else if (currentKernelspecs && !currentKernelspecs.byName.get(kernelSpecToLaunch)) {
|
||||
@@ -316,7 +316,7 @@ export const launchWebSocketKernelEpic = (
|
||||
|
||||
// Find a kernel that best matches the kernel name
|
||||
const match = currentKernelspecs.byName.find(
|
||||
(value) => value.name.toLowerCase().indexOf(kernelSpecName.toLowerCase()) !== -1
|
||||
(value) => value.name.toLowerCase().indexOf(kernelSpecName.toLowerCase()) !== -1,
|
||||
);
|
||||
if (match) {
|
||||
kernelSpecToLaunch = match.name;
|
||||
@@ -362,14 +362,14 @@ export const launchWebSocketKernelEpic = (
|
||||
kernelRef,
|
||||
contentRef: action.payload.contentRef,
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}),
|
||||
catchError((error) => {
|
||||
return of(actions.launchKernelFailed({ error }));
|
||||
})
|
||||
}),
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
/**
|
||||
@@ -379,7 +379,7 @@ export const launchWebSocketKernelEpic = (
|
||||
*/
|
||||
export const restartWebSocketKernelEpic = (
|
||||
action$: Observable<actions.RestartKernel | actions.NewKernelAction>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
) =>
|
||||
action$.pipe(
|
||||
ofType(actions.RESTART_KERNEL),
|
||||
@@ -398,7 +398,7 @@ export const restartWebSocketKernelEpic = (
|
||||
error: new Error("Can't execute restart without kernel ref."),
|
||||
kernelRef: "none provided",
|
||||
contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ export const restartWebSocketKernelEpic = (
|
||||
error: new Error("Can't restart a kernel with no Jupyter host."),
|
||||
kernelRef,
|
||||
contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -420,7 +420,7 @@ export const restartWebSocketKernelEpic = (
|
||||
error: new Error("Can't restart a kernel that does not exist."),
|
||||
kernelRef,
|
||||
contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -430,7 +430,7 @@ export const restartWebSocketKernelEpic = (
|
||||
error: new Error("Can only restart Websocket kernels via API."),
|
||||
kernelRef,
|
||||
contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -471,13 +471,13 @@ export const restartWebSocketKernelEpic = (
|
||||
error,
|
||||
kernelRef: newKernelRef,
|
||||
contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
return merge(of(kill, relaunch), awaitKernelReady);
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -489,7 +489,7 @@ export const restartWebSocketKernelEpic = (
|
||||
*/
|
||||
const changeWebSocketKernelEpic = (
|
||||
action$: Observable<actions.ChangeKernelByName>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
) => {
|
||||
return action$.pipe(
|
||||
ofType(actions.CHANGE_KERNEL_BY_NAME),
|
||||
@@ -552,15 +552,15 @@ const changeWebSocketKernelEpic = (
|
||||
kernelRef,
|
||||
contentRef: action.payload.contentRef,
|
||||
selectNextKernel: true,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}),
|
||||
catchError((error) => of(actions.launchKernelFailed({ error, kernelRef, contentRef })))
|
||||
catchError((error) => of(actions.launchKernelFailed({ error, kernelRef, contentRef }))),
|
||||
);
|
||||
}),
|
||||
catchError((error) => of(actions.launchKernelFailed({ error, kernelRef, contentRef })))
|
||||
catchError((error) => of(actions.launchKernelFailed({ error, kernelRef, contentRef }))),
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -571,7 +571,7 @@ const changeWebSocketKernelEpic = (
|
||||
*/
|
||||
const focusInitialCodeCellEpic = (
|
||||
action$: Observable<actions.CreateCellAppend>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<{} | actions.FocusCell> => {
|
||||
return action$.pipe(
|
||||
ofType(actions.CREATE_CELL_APPEND),
|
||||
@@ -593,12 +593,12 @@ const focusInitialCodeCellEpic = (
|
||||
actions.focusCell({
|
||||
id,
|
||||
contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return EMPTY;
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -615,7 +615,7 @@ const notificationsToUserEpic = (action$: Observable<any>, state$: StateObservab
|
||||
actions.RESTART_KERNEL_FAILED,
|
||||
actions.SAVE_FULFILLED,
|
||||
actions.SAVE_FAILED,
|
||||
actions.FETCH_CONTENT_FAILED
|
||||
actions.FETCH_CONTENT_FAILED,
|
||||
),
|
||||
mergeMap((action) => {
|
||||
switch (action.type) {
|
||||
@@ -648,7 +648,7 @@ const notificationsToUserEpic = (action$: Observable<any>, state$: StateObservab
|
||||
}
|
||||
}
|
||||
return EMPTY;
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -659,7 +659,7 @@ const notificationsToUserEpic = (action$: Observable<any>, state$: StateObservab
|
||||
*/
|
||||
const handleKernelConnectionLostEpic = (
|
||||
action$: Observable<actions.UpdateDisplayFailed>,
|
||||
state$: StateObservable<CdbAppState>
|
||||
state$: StateObservable<CdbAppState>,
|
||||
): Observable<CdbActions.UpdateKernelRestartDelayAction | actions.RestartKernel | {}> => {
|
||||
return action$.pipe(
|
||||
ofType(actions.UPDATE_DISPLAY_FAILED),
|
||||
@@ -702,12 +702,12 @@ const handleKernelConnectionLostEpic = (
|
||||
retryWhen((errors) => {
|
||||
return errors.pipe(
|
||||
delayWhen(() => timer(Constants.Notebook.heartbeatDelayMs)),
|
||||
tap(() => console.log("retrying...")) // TODO: Send new action?
|
||||
tap(() => console.log("retrying...")), // TODO: Send new action?
|
||||
);
|
||||
})
|
||||
)
|
||||
}),
|
||||
),
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -718,7 +718,7 @@ const handleKernelConnectionLostEpic = (
|
||||
*/
|
||||
export const cleanKernelOnConnectionLostEpic = (
|
||||
action$: Observable<actions.UpdateDisplayFailed>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<actions.KillKernelSuccessful> => {
|
||||
return action$.pipe(
|
||||
ofType(actions.UPDATE_DISPLAY_FAILED),
|
||||
@@ -728,9 +728,9 @@ export const cleanKernelOnConnectionLostEpic = (
|
||||
return of(
|
||||
actions.killKernelSuccessful({
|
||||
kernelRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -741,7 +741,7 @@ export const cleanKernelOnConnectionLostEpic = (
|
||||
*/
|
||||
const executeFocusedCellAndFocusNextEpic = (
|
||||
action$: Observable<CdbActions.ExecuteFocusedCellAndFocusNextAction>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<{} | actions.FocusNextCellEditor> => {
|
||||
return action$.pipe(
|
||||
ofType(CdbActions.EXECUTE_FOCUSED_CELL_AND_FOCUS_NEXT),
|
||||
@@ -749,9 +749,9 @@ const executeFocusedCellAndFocusNextEpic = (
|
||||
const contentRef = action.payload.contentRef;
|
||||
return concat(
|
||||
of(actions.executeFocusedCell({ contentRef })),
|
||||
of(actions.focusNextCell({ contentRef, createCellIfUndefined: false }))
|
||||
of(actions.focusNextCell({ contentRef, createCellIfUndefined: false })),
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -762,7 +762,7 @@ const executeFocusedCellAndFocusNextEpic = (
|
||||
*/
|
||||
const closeUnsupportedMimetypesEpic = (
|
||||
action$: Observable<actions.FetchContentFulfilled>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<{}> => {
|
||||
return action$.pipe(
|
||||
ofType(actions.FETCH_CONTENT_FULFILLED),
|
||||
@@ -774,14 +774,15 @@ const closeUnsupportedMimetypesEpic = (
|
||||
useTabs
|
||||
.getState()
|
||||
.closeTabsByComparator(
|
||||
(tab: any) => (tab as any).notebookPath && FileSystemUtil.isPathEqual((tab as any).notebookPath(), filepath)
|
||||
(tab: any) =>
|
||||
(tab as any).notebookPath && FileSystemUtil.isPathEqual((tab as any).notebookPath(), filepath),
|
||||
);
|
||||
const msg = `${filepath} cannot be rendered. Please download the file, in order to view it outside of Data Explorer.`;
|
||||
useDialog.getState().showOkModalDialog("File cannot be rendered", msg);
|
||||
logConsoleError(msg);
|
||||
}
|
||||
return EMPTY;
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -792,7 +793,7 @@ const closeUnsupportedMimetypesEpic = (
|
||||
*/
|
||||
const closeContentFailedToFetchEpic = (
|
||||
action$: Observable<actions.FetchContentFailed>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<{}> => {
|
||||
return action$.pipe(
|
||||
ofType(actions.FETCH_CONTENT_FAILED),
|
||||
@@ -802,19 +803,19 @@ const closeContentFailedToFetchEpic = (
|
||||
useTabs
|
||||
.getState()
|
||||
.closeTabsByComparator(
|
||||
(tab: any) => (tab as any).notebookPath && FileSystemUtil.isPathEqual((tab as any).notebookPath(), filepath)
|
||||
(tab: any) => (tab as any).notebookPath && FileSystemUtil.isPathEqual((tab as any).notebookPath(), filepath),
|
||||
);
|
||||
const msg = `Failed to load file: ${filepath}.`;
|
||||
useDialog.getState().showOkModalDialog("Failure to load", msg);
|
||||
logConsoleError(msg);
|
||||
return EMPTY;
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const traceNotebookTelemetryEpic = (
|
||||
action$: Observable<cdbActions.TraceNotebookTelemetryAction>,
|
||||
state$: StateObservable<CdbAppState>
|
||||
state$: StateObservable<CdbAppState>,
|
||||
): Observable<{}> => {
|
||||
return action$.pipe(
|
||||
ofType(cdbActions.TRACE_NOTEBOOK_TELEMETRY),
|
||||
@@ -828,7 +829,7 @@ const traceNotebookTelemetryEpic = (
|
||||
dataExplorerArea: Areas.Notebook,
|
||||
});
|
||||
return EMPTY;
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -840,7 +841,7 @@ const traceNotebookTelemetryEpic = (
|
||||
*/
|
||||
const traceNotebookInfoEpic = (
|
||||
action$: Observable<actions.FetchContentFulfilled>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<{} | cdbActions.TraceNotebookTelemetryAction> => {
|
||||
return action$.pipe(
|
||||
ofType(actions.FETCH_CONTENT_FULFILLED),
|
||||
@@ -880,9 +881,9 @@ const traceNotebookInfoEpic = (
|
||||
action: TelemetryAction.NotebooksFetched,
|
||||
actionModifier: ActionModifiers.Mark,
|
||||
data: dataToLog,
|
||||
})
|
||||
}),
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -893,7 +894,7 @@ const traceNotebookInfoEpic = (
|
||||
*/
|
||||
const traceNotebookKernelEpic = (
|
||||
action$: Observable<AnyAction>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<cdbActions.TraceNotebookTelemetryAction> => {
|
||||
return action$.pipe(
|
||||
ofType(actions.LAUNCH_KERNEL_SUCCESSFUL),
|
||||
@@ -905,15 +906,15 @@ const traceNotebookKernelEpic = (
|
||||
data: {
|
||||
kernelSpecName: action.payload.kernel.name,
|
||||
},
|
||||
})
|
||||
}),
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
const resetCellStatusOnExecuteCanceledEpic = (
|
||||
action$: Observable<actions.ExecuteCanceled>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<actions.UpdateCellStatus> => {
|
||||
return action$.pipe(
|
||||
ofType(actions.EXECUTE_CANCELED),
|
||||
@@ -938,9 +939,9 @@ const resetCellStatusOnExecuteCanceledEpic = (
|
||||
return from(busyCellIds).pipe(
|
||||
map((busyCellId) => {
|
||||
return actions.updateCellStatus({ id: busyCellId, contentRef, status: undefined });
|
||||
})
|
||||
}),
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
@@ -956,7 +957,7 @@ const { selector: autoSaveInterval } = defineConfigOption({
|
||||
*/
|
||||
export function autoSaveCurrentContentEpic(
|
||||
action$: Observable<Action>,
|
||||
state$: StateObservable<AppState>
|
||||
state$: StateObservable<AppState>,
|
||||
): Observable<actions.Save> {
|
||||
return state$.pipe(
|
||||
map((state) => autoSaveInterval(state)),
|
||||
@@ -971,9 +972,9 @@ export function autoSaveCurrentContentEpic(
|
||||
* Only save contents that are files or notebooks with
|
||||
* a filepath already set.
|
||||
*/
|
||||
(content) => (content.type === "file" || content.type === "notebook") && content.filepath !== ""
|
||||
(content) => (content.type === "file" || content.type === "notebook") && content.filepath !== "",
|
||||
)
|
||||
.keys()
|
||||
.keys(),
|
||||
);
|
||||
}),
|
||||
filter((contentRef: ContentRef) => {
|
||||
@@ -988,7 +989,7 @@ export function autoSaveCurrentContentEpic(
|
||||
}
|
||||
return false;
|
||||
}),
|
||||
map((contentRef: ContentRef) => actions.save({ contentRef }))
|
||||
map((contentRef: ContentRef) => actions.save({ contentRef })),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ export const coreReducer = (state: CoreRecord, action: Action) => {
|
||||
typedAction = action as cdbActions.CloseNotebookAction;
|
||||
return state.setIn(
|
||||
["entities", "contents", "byRef"],
|
||||
state.entities.contents.byRef.delete(typedAction.payload.contentRef)
|
||||
state.entities.contents.byRef.delete(typedAction.payload.contentRef),
|
||||
);
|
||||
}
|
||||
case actions.CHANGE_KERNEL_BY_NAME: {
|
||||
|
||||
@@ -16,21 +16,21 @@ export default function configureStore(
|
||||
contentProvider: IContentProvider,
|
||||
onTraceFailure: (title: string, message: string) => void,
|
||||
customMiddlewares?: Middleware<{}, any, Dispatch<AnyAction>>[],
|
||||
autoStartKernelOnNotebookOpen?: boolean
|
||||
autoStartKernelOnNotebookOpen?: boolean,
|
||||
): Store<CdbAppState, AnyAction> {
|
||||
/**
|
||||
* Catches errors in reducers
|
||||
*/
|
||||
const catchErrorMiddleware: Middleware = <D extends Dispatch<AnyAction>, S extends AppState>({
|
||||
dispatch,
|
||||
getState,
|
||||
}: MiddlewareAPI<D, S>) => (next: Dispatch<AnyAction>) => <A extends AnyAction>(action: A): any => {
|
||||
try {
|
||||
next(action);
|
||||
} catch (error) {
|
||||
traceFailure("Reducer failure", error);
|
||||
}
|
||||
};
|
||||
const catchErrorMiddleware: Middleware =
|
||||
<D extends Dispatch<AnyAction>, S extends AppState>({ dispatch, getState }: MiddlewareAPI<D, S>) =>
|
||||
(next: Dispatch<AnyAction>) =>
|
||||
<A extends AnyAction>(action: A): any => {
|
||||
try {
|
||||
next(action);
|
||||
} catch (error) {
|
||||
traceFailure("Reducer failure", error);
|
||||
}
|
||||
};
|
||||
|
||||
const protect = (epic: Epic) => {
|
||||
return (action$: Observable<any>, state$: any, dependencies: any) =>
|
||||
@@ -38,7 +38,7 @@ export default function configureStore(
|
||||
catchError((error, caught) => {
|
||||
traceFailure("Epic failure", error);
|
||||
return caught;
|
||||
})
|
||||
}),
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export class NotebookContainerClient {
|
||||
|
||||
useNotebook.subscribe(
|
||||
() => this.scheduleHeartbeat(delayMs),
|
||||
(state) => state.notebookServerInfo
|
||||
(state) => state.notebookServerInfo,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export class NotebookContainerClient {
|
||||
Logger.logError(getErrorMessage(error), "NotebookContainerClient/getMemoryUsage");
|
||||
if (!this.clearReconnectionAttemptMessage) {
|
||||
this.clearReconnectionAttemptMessage = logConsoleProgress(
|
||||
"Connection lost with Notebook server. Attempting to reconnect..."
|
||||
"Connection lost with Notebook server. Attempting to reconnect...",
|
||||
);
|
||||
}
|
||||
this.onConnectionLost();
|
||||
@@ -91,7 +91,7 @@ export class NotebookContainerClient {
|
||||
|
||||
private async _getMemoryAsync(
|
||||
notebookServerEndpoint: string,
|
||||
authToken: string
|
||||
authToken: string,
|
||||
): Promise<DataModels.MemoryUsageInfo> {
|
||||
if (this.shouldExecuteMemoryCall()) {
|
||||
const response = await fetch(`${notebookServerEndpoint}api/metrics/memory`, {
|
||||
@@ -168,7 +168,7 @@ export class NotebookContainerClient {
|
||||
.getState()
|
||||
.showOkModalDialog(
|
||||
"Connection Failed",
|
||||
"We are unable to connect to the temporary workspace. Please try again in a few minutes. If the error persists, file a support ticket."
|
||||
"We are unable to connect to the temporary workspace. Please try again in a few minutes. If the error persists, file a support ticket.",
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
|
||||
@@ -38,7 +38,7 @@ export class NotebookContentClient {
|
||||
*/
|
||||
public async createNewNotebookFile(
|
||||
parent: NotebookContentItem,
|
||||
isGithubTree?: boolean
|
||||
isGithubTree?: boolean,
|
||||
): Promise<NotebookContentItem> {
|
||||
if (!parent || parent.type !== NotebookContentItemType.Directory) {
|
||||
throw new Error(`Parent must be a directory: ${parent}`);
|
||||
@@ -97,7 +97,7 @@ export class NotebookContentClient {
|
||||
name: string,
|
||||
content: string,
|
||||
parent: NotebookContentItem,
|
||||
isGithubTree?: boolean
|
||||
isGithubTree?: boolean,
|
||||
): Promise<NotebookContentItem> {
|
||||
if (!parent || parent.type !== NotebookContentItemType.Directory) {
|
||||
throw new Error(`Parent must be a directory: ${parent}`);
|
||||
@@ -147,7 +147,7 @@ export class NotebookContentClient {
|
||||
public renameNotebook(
|
||||
item: NotebookContentItem,
|
||||
targetName: string,
|
||||
isGithubTree?: boolean
|
||||
isGithubTree?: boolean,
|
||||
): Promise<NotebookContentItem> {
|
||||
const sourcePath = item.path;
|
||||
// Match extension
|
||||
@@ -189,7 +189,7 @@ export class NotebookContentClient {
|
||||
public async createDirectory(
|
||||
parent: NotebookContentItem,
|
||||
newDirectoryName: string,
|
||||
isGithubTree?: boolean
|
||||
isGithubTree?: boolean,
|
||||
): Promise<NotebookContentItem> {
|
||||
if (parent.type !== NotebookContentItemType.Directory) {
|
||||
throw new Error(`Parent is not a directory: ${parent.path}`);
|
||||
@@ -295,7 +295,7 @@ export class NotebookContentClient {
|
||||
name: item.name,
|
||||
path: item.path,
|
||||
type: NotebookUtil.getType(item.type),
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ export default class NotebookManager {
|
||||
this.notebookContentProvider = new NotebookContentProvider(
|
||||
this.inMemoryContentProvider,
|
||||
this.gitHubContentProvider,
|
||||
contents.JupyterContentProvider
|
||||
contents.JupyterContentProvider,
|
||||
);
|
||||
|
||||
this.notebookClient = new NotebookContainerClient(() =>
|
||||
this.params.container.initNotebooks(userContext?.databaseAccount)
|
||||
this.params.container.initNotebooks(userContext?.databaseAccount),
|
||||
);
|
||||
|
||||
this.notebookContentClient = new NotebookContentClient(this.notebookContentProvider);
|
||||
@@ -100,7 +100,7 @@ export default class NotebookManager {
|
||||
explorer={this.params.container}
|
||||
gitHubClientProp={this.params.container.notebookManager.gitHubClient}
|
||||
junoClientProp={this.junoClient}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
}, 200);
|
||||
}
|
||||
@@ -129,7 +129,7 @@ export default class NotebookManager {
|
||||
content: NotebookPaneContent,
|
||||
notebookContentRef: string,
|
||||
onTakeSnapshot: (request: SnapshotRequest) => void,
|
||||
onClosePanel: () => void
|
||||
onClosePanel: () => void,
|
||||
): Promise<void> {
|
||||
useSidePanel
|
||||
.getState()
|
||||
@@ -145,7 +145,7 @@ export default class NotebookManager {
|
||||
onTakeSnapshot={onTakeSnapshot}
|
||||
/>,
|
||||
"440px",
|
||||
onClosePanel
|
||||
onClosePanel,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ export default class NotebookManager {
|
||||
gitHubOAuthService={this.gitHubOAuthService}
|
||||
name={name}
|
||||
content={content}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -188,10 +188,10 @@ export default class NotebookManager {
|
||||
explorer={this.params.container}
|
||||
gitHubClientProp={this.params.container.notebookManager.gitHubClient}
|
||||
junoClientProp={this.junoClient}
|
||||
/>
|
||||
/>,
|
||||
),
|
||||
"Cancel",
|
||||
undefined
|
||||
undefined,
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -223,7 +223,7 @@ export default class NotebookManager {
|
||||
commitMsg = newValue;
|
||||
},
|
||||
},
|
||||
!commitMsg
|
||||
!commitMsg,
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -108,7 +108,7 @@ const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: Noteboo
|
||||
actions.addTransform({
|
||||
mediaType: transform.MIMETYPE,
|
||||
component: transform,
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -93,7 +93,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
|
||||
this.notebookRendererRef.current,
|
||||
this.props.pendingSnapshotRequest.aspectRatio,
|
||||
[...this.props.cellOutputSnapshots.values()],
|
||||
this.props.pendingSnapshotRequest.downloadFilename
|
||||
this.props.pendingSnapshotRequest.downloadFilename,
|
||||
);
|
||||
this.props.storeNotebookSnapshot(result.imageSrc, this.props.pendingSnapshotRequest.requestId);
|
||||
} catch (error) {
|
||||
@@ -136,7 +136,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
|
||||
? () => <SandboxOutputs id={id} contentRef={contentRef} />
|
||||
: undefined,
|
||||
}}
|
||||
</CodeCell>
|
||||
</CodeCell>,
|
||||
),
|
||||
markdown: ({ id, contentRef }: { id: any; contentRef: ContentRef }) =>
|
||||
decorate(
|
||||
@@ -152,7 +152,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
|
||||
},
|
||||
toolbar: () => <CellToolbar id={id} contentRef={contentRef} />,
|
||||
}}
|
||||
</MarkdownCell>
|
||||
</MarkdownCell>,
|
||||
),
|
||||
|
||||
raw: ({ id, contentRef }: { id: any; contentRef: ContentRef }) =>
|
||||
@@ -169,7 +169,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
|
||||
},
|
||||
toolbar: () => <CellToolbar id={id} contentRef={contentRef} />,
|
||||
}}
|
||||
</RawCell>
|
||||
</RawCell>,
|
||||
),
|
||||
}}
|
||||
</Cells>
|
||||
@@ -186,7 +186,7 @@ class BaseNotebookRenderer extends React.Component<NotebookRendererProps> {
|
||||
|
||||
export const makeMapStateToProps = (
|
||||
initialState: CdbAppState,
|
||||
ownProps: NotebookRendererProps
|
||||
ownProps: NotebookRendererProps,
|
||||
): ((state: CdbAppState) => StateProps) => {
|
||||
const mapStateToProps = (state: CdbAppState): StateProps => {
|
||||
const { contentRef } = ownProps;
|
||||
@@ -210,7 +210,7 @@ const makeMapDispatchToProps = (initialDispatch: Dispatch, initialProps: Noteboo
|
||||
actions.addTransform({
|
||||
mediaType: transform.MIMETYPE,
|
||||
component: transform,
|
||||
})
|
||||
}),
|
||||
),
|
||||
storeNotebookSnapshot: (imageSrc: string, requestId: string) =>
|
||||
dispatch(cdbActions.storeNotebookSnapshot({ imageSrc, requestId })),
|
||||
|
||||
@@ -87,7 +87,7 @@ const makeMapStateToProps = (_state: CdbAppState, ownProps: ComponentProps): ((s
|
||||
|
||||
const mapDispatchToProps = (
|
||||
dispatch: Dispatch,
|
||||
{ id, contentRef }: { id: string; contentRef: ContentRef }
|
||||
{ id, contentRef }: { id: string; contentRef: ContentRef },
|
||||
): DispatchProps => ({
|
||||
executeCell: () => {
|
||||
dispatch(actions.executeCell({ id, contentRef }));
|
||||
@@ -95,7 +95,7 @@ const mapDispatchToProps = (
|
||||
cdbActions.traceNotebookTelemetry({
|
||||
action: Action.ExecuteCellPromptBtn,
|
||||
actionModifier: ActionModifiers.Mark,
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
stopExecution: () => dispatch(actions.interruptKernel({})),
|
||||
|
||||
@@ -8,7 +8,7 @@ describe("StatusBar", () => {
|
||||
const kernelSpecDisplayName = "python3";
|
||||
|
||||
const component = shallow(
|
||||
<StatusBar kernelStatus="kernel status" lastSaved={lastSaved} kernelSpecDisplayName={kernelSpecDisplayName} />
|
||||
<StatusBar kernelStatus="kernel status" lastSaved={lastSaved} kernelSpecDisplayName={kernelSpecDisplayName} />,
|
||||
);
|
||||
|
||||
expect(component).not.toBeNull();
|
||||
@@ -18,7 +18,7 @@ describe("StatusBar", () => {
|
||||
const kernelSpecDisplayName = "python3";
|
||||
|
||||
const component = shallow(
|
||||
<StatusBar kernelStatus="kernel status" lastSaved={lastSaved} kernelSpecDisplayName={kernelSpecDisplayName} />
|
||||
<StatusBar kernelStatus="kernel status" lastSaved={lastSaved} kernelSpecDisplayName={kernelSpecDisplayName} />,
|
||||
);
|
||||
|
||||
const shouldUpdate = component.instance().shouldComponentUpdate(
|
||||
@@ -28,7 +28,7 @@ describe("StatusBar", () => {
|
||||
kernelStatus: "kernelStatus",
|
||||
},
|
||||
undefined,
|
||||
undefined
|
||||
undefined,
|
||||
);
|
||||
expect(shouldUpdate).toBe(true);
|
||||
});
|
||||
@@ -37,7 +37,7 @@ describe("StatusBar", () => {
|
||||
const kernelSpecDisplayName = "python3";
|
||||
|
||||
const component = shallow(
|
||||
<StatusBar kernelStatus="kernel status" lastSaved={lastSaved} kernelSpecDisplayName={kernelSpecDisplayName} />
|
||||
<StatusBar kernelStatus="kernel status" lastSaved={lastSaved} kernelSpecDisplayName={kernelSpecDisplayName} />,
|
||||
);
|
||||
|
||||
const shouldUpdate = component.instance().shouldComponentUpdate(
|
||||
@@ -47,7 +47,7 @@ describe("StatusBar", () => {
|
||||
kernelStatus: "kernelStatus",
|
||||
},
|
||||
undefined,
|
||||
undefined
|
||||
undefined,
|
||||
);
|
||||
expect(shouldUpdate).toBe(true);
|
||||
});
|
||||
|
||||
@@ -197,7 +197,7 @@ class BaseToolbar extends React.PureComponent<ComponentProps & DispatchProps & S
|
||||
|
||||
const mapDispatchToProps = (
|
||||
dispatch: Dispatch,
|
||||
{ id, contentRef }: { id: CellId; contentRef: ContentRef }
|
||||
{ id, contentRef }: { id: CellId; contentRef: ContentRef },
|
||||
): DispatchProps => ({
|
||||
executeCell: () => dispatch(actions.executeCell({ id, contentRef })),
|
||||
insertCodeCellAbove: () => dispatch(actions.createCellAbove({ id, contentRef, cellType: "code" })),
|
||||
|
||||
@@ -144,7 +144,7 @@ export const cellTarget = {
|
||||
|
||||
function collectSource(
|
||||
connect: DragSourceConnector,
|
||||
monitor: DragSourceMonitor
|
||||
monitor: DragSourceMonitor,
|
||||
): {
|
||||
connectDragSource: ConnectDragSource;
|
||||
isDragging: boolean;
|
||||
@@ -159,7 +159,7 @@ function collectSource(
|
||||
|
||||
function collectTarget(
|
||||
connect: DropTargetConnector,
|
||||
monitor: DropTargetMonitor
|
||||
monitor: DropTargetMonitor,
|
||||
): {
|
||||
connectDropTarget: ConnectDropTarget;
|
||||
isOver: boolean;
|
||||
@@ -210,12 +210,12 @@ export class DraggableCellView extends React.Component<Props & DnDSourceProps &
|
||||
// Same thing with connectDragSource... It also needs a React Element that matches a DOM element
|
||||
<div>
|
||||
<DragHandle onClick={this.selectCell} />
|
||||
</div>
|
||||
</div>,
|
||||
)}
|
||||
{this.props.children}
|
||||
</DragHandleAnchor>
|
||||
</DragArea>
|
||||
</div>
|
||||
</div>,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export class PureMarkdownCell extends React.Component<ComponentProps & DispatchP
|
||||
|
||||
export const makeMapStateToProps = (
|
||||
initialState: AppState,
|
||||
ownProps: ComponentProps
|
||||
ownProps: ComponentProps,
|
||||
): ((state: AppState) => StateProps) => {
|
||||
const { id, contentRef } = ownProps;
|
||||
const mapStateToProps = (state: AppState): StateProps => {
|
||||
@@ -135,7 +135,7 @@ export const makeMapStateToProps = (
|
||||
|
||||
const makeMapDispatchToProps = (
|
||||
initialDispatch: Dispatch,
|
||||
ownProps: ComponentProps
|
||||
ownProps: ComponentProps,
|
||||
): ((dispatch: Dispatch) => DispatchProps) => {
|
||||
const { id, contentRef } = ownProps;
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ export class SandboxOutputs extends React.Component<SandboxOutputsProps> {
|
||||
const { data } = (await postRobot.send(
|
||||
this.childWindow,
|
||||
"snapshotRequest",
|
||||
this.props.pendingSnapshotRequest
|
||||
this.props.pendingSnapshotRequest,
|
||||
)) as { data: SnapshotResponse };
|
||||
if (this.props.pendingSnapshotRequest.type === "notebook") {
|
||||
if (data.imageSrc === undefined) {
|
||||
@@ -145,7 +145,7 @@ export class SandboxOutputs extends React.Component<SandboxOutputsProps> {
|
||||
|
||||
export const makeMapStateToProps = (
|
||||
initialState: AppState,
|
||||
ownProps: ComponentProps
|
||||
ownProps: ComponentProps,
|
||||
): ((state: AppState) => StateProps) => {
|
||||
const mapStateToProps = (state: CdbAppState): StateProps => {
|
||||
let outputs = Immutable.List();
|
||||
@@ -181,7 +181,7 @@ export const makeMapStateToProps = (
|
||||
|
||||
export const makeMapDispatchToProps = (
|
||||
initialDispath: Dispatch,
|
||||
ownProps: ComponentProps
|
||||
ownProps: ComponentProps,
|
||||
): ((dispatch: Dispatch) => DispatchProps) => {
|
||||
const { id, contentRef } = ownProps;
|
||||
const mapDispatchToProps = (dispatch: Dispatch) => {
|
||||
@@ -194,7 +194,7 @@ export const makeMapDispatchToProps = (
|
||||
metadata,
|
||||
index: index || 0,
|
||||
mediaType,
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
storeSnapshotFragment: (cellId: string, snapshot: SnapshotFragment) =>
|
||||
@@ -209,5 +209,5 @@ export const makeMapDispatchToProps = (
|
||||
|
||||
export default connect<StateProps, DispatchProps, ComponentProps, AppState>(
|
||||
makeMapStateToProps,
|
||||
makeMapDispatchToProps
|
||||
makeMapDispatchToProps,
|
||||
)(SandboxOutputs);
|
||||
|
||||
@@ -123,7 +123,7 @@ describe("NotebookUtil", () => {
|
||||
it("works for github file uris", () => {
|
||||
expect(NotebookUtil.replaceName(gitHubFileUri, "newName")).toEqual(gitHubFileUri.replace(fileName, "newName"));
|
||||
expect(NotebookUtil.replaceName(gitHubNotebookUri, "newName")).toEqual(
|
||||
gitHubNotebookUri.replace(notebookName, "newName")
|
||||
gitHubNotebookUri.replace(notebookName, "newName"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -109,7 +109,7 @@ export class NotebookUtil {
|
||||
contentInfo.owner,
|
||||
contentInfo.repo,
|
||||
contentInfo.branch,
|
||||
parentPath.replace(/\/$/, "") // no trailling slash
|
||||
parentPath.replace(/\/$/, ""), // no trailling slash
|
||||
);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ export class NotebookUtil {
|
||||
(output) =>
|
||||
output.output_type === "display_data" ||
|
||||
output.output_type === "execute_result" ||
|
||||
output.output_type === "stream"
|
||||
output.output_type === "stream",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ export class NotebookUtil {
|
||||
target: HTMLElement,
|
||||
aspectRatio: number,
|
||||
subSnapshots: SnapshotFragment[],
|
||||
downloadFilename?: string
|
||||
downloadFilename?: string,
|
||||
): Promise<{ imageSrc: string | undefined }> => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
@@ -248,7 +248,7 @@ export class NotebookUtil {
|
||||
context.drawImage(
|
||||
snapshot.image,
|
||||
snapshot.boundingClientRect.x - parentRect.x,
|
||||
snapshot.boundingClientRect.y - parentRect.y
|
||||
snapshot.boundingClientRect.y - parentRect.y,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -259,7 +259,7 @@ export class NotebookUtil {
|
||||
if (downloadFilename) {
|
||||
NotebookUtil.downloadFile(
|
||||
downloadFilename,
|
||||
canvas.toDataURL("image/png").replace("image/png", "image/octet-stream")
|
||||
canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"),
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -273,7 +273,7 @@ export class NotebookUtil {
|
||||
target: HTMLElement,
|
||||
aspectRatio: number,
|
||||
subSnapshots: SnapshotFragment[],
|
||||
downloadFilename?: string
|
||||
downloadFilename?: string,
|
||||
): Promise<{ imageSrc?: string }> => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// target.scrollIntoView();
|
||||
@@ -317,7 +317,7 @@ export class NotebookUtil {
|
||||
context.drawImage(
|
||||
snapshot.image,
|
||||
snapshot.boundingClientRect.x - parentRect.x,
|
||||
snapshot.boundingClientRect.y - parentRect.y
|
||||
snapshot.boundingClientRect.y - parentRect.y,
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -328,7 +328,7 @@ export class NotebookUtil {
|
||||
if (downloadFilename) {
|
||||
NotebookUtil.downloadFile(
|
||||
downloadFilename,
|
||||
canvas.toDataURL("image/png").replace("image/png", "image/octet-stream")
|
||||
canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -211,7 +211,7 @@ const makeMapDispatchToProps = () => {
|
||||
actions.addTransform({
|
||||
mediaType: transform.MIMETYPE,
|
||||
component: transform,
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
runCell: (contentRef: ContentRef, cellId: string) => {
|
||||
@@ -219,7 +219,7 @@ const makeMapDispatchToProps = () => {
|
||||
actions.executeCell({
|
||||
contentRef,
|
||||
id: cellId,
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
updateCell: (text: string, id: string, contentRef: ContentRef) => {
|
||||
|
||||
@@ -13,7 +13,11 @@ export class SchemaAnalyzerAdapter extends NotebookComponentBootstrapper impleme
|
||||
public parameters: unknown;
|
||||
private kernelRef: KernelRef;
|
||||
|
||||
constructor(options: NotebookComponentBootstrapperOptions, private databaseId: string, private collectionId: string) {
|
||||
constructor(
|
||||
options: NotebookComponentBootstrapperOptions,
|
||||
private databaseId: string,
|
||||
private collectionId: string,
|
||||
) {
|
||||
super(options);
|
||||
|
||||
if (!this.contentRef) {
|
||||
@@ -26,7 +30,7 @@ export class SchemaAnalyzerAdapter extends NotebookComponentBootstrapper impleme
|
||||
params: {},
|
||||
kernelRef: this.kernelRef,
|
||||
contentRef: this.contentRef,
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export const SchemaAnalyzerHeader = ({
|
||||
|
||||
const onSampleSizeWrapDefaultLabelRenderer = (
|
||||
props: ITextFieldProps,
|
||||
defaultRender: IRenderFunction<ITextFieldProps>
|
||||
defaultRender: IRenderFunction<ITextFieldProps>,
|
||||
): JSX.Element => {
|
||||
return (
|
||||
<Stack horizontal verticalAlign="center" tokens={{ childrenGap: 4 }}>
|
||||
|
||||
@@ -10,7 +10,7 @@ describe("SecurityWarningBar", () => {
|
||||
isNotebookUntrusted={true}
|
||||
markNotebookAsTrusted={undefined}
|
||||
saveNotebook={undefined}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
@@ -23,7 +23,7 @@ describe("SecurityWarningBar", () => {
|
||||
isNotebookUntrusted={false}
|
||||
markNotebookAsTrusted={undefined}
|
||||
saveNotebook={undefined}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
||||
@@ -81,7 +81,7 @@ const makeMapDispatchToProps = () => {
|
||||
actions.deleteMetadataField({
|
||||
contentRef,
|
||||
field: "untrusted",
|
||||
})
|
||||
}),
|
||||
);
|
||||
},
|
||||
saveNotebook: (contentRef: string) => dispatch(actions.save({ contentRef })),
|
||||
|
||||
@@ -48,7 +48,7 @@ describe("auto start kernel", () => {
|
||||
undefined, // content provider
|
||||
expect.anything(), // onTraceFailure
|
||||
expect.anything(), // customMiddlewares
|
||||
!isReadOnly
|
||||
!isReadOnly,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user