Skip to content

Commit

Permalink
DataViewer added to the webview serviceRegistry.web.ts (#10495)
Browse files Browse the repository at this point in the history
* DataViewer in webviews serviceRegistry.web.ts

* Sending the new number of parameters to the DataViewer in the tests

* strictPropertyInitialization fixes non-fatal typescript errors that were specially visible in the editor

* test fix
  • Loading branch information
sadasant authored Jun 18, 2022
1 parent eb2d5c1 commit c925935
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 18 deletions.
13 changes: 8 additions & 5 deletions src/test/datascience/data-viewing/dataViewer.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import { anything, instance, mock, verify, when } from 'ts-mockito';
import { ConfigurationChangeEvent, EventEmitter } from 'vscode';
import { ConfigurationChangeEvent, EventEmitter, Uri } from 'vscode';
import { ApplicationShell } from '../../../platform/common/application/applicationShell';
import {
IApplicationShell,
Expand All @@ -15,9 +15,9 @@ import { WebviewPanelProvider } from '../../../webviews/extension-side/webviewPa
import { WorkspaceService } from '../../../platform/common/application/workspace.node';
import { JupyterSettings } from '../../../platform/common/configSettings';
import { ConfigurationService } from '../../../platform/common/configuration/service.node';
import { IConfigurationService } from '../../../platform/common/types';
import { IConfigurationService, IExtensionContext } from '../../../platform/common/types';
import { IDataScienceErrorHandler } from '../../../platform/errors/types';
import { DataViewer } from '../../../webviews/extension-side/dataviewer/dataViewer.node';
import { DataViewer } from '../../../webviews/extension-side/dataviewer/dataViewer';
import { JupyterVariableDataProvider } from '../../../webviews/extension-side/dataviewer/jupyterVariableDataProvider';
import { IDataViewer, IDataViewerDataProvider } from '../../../webviews/extension-side/dataviewer/types';
import { MockMemento } from '../../mocks/mementos';
Expand All @@ -39,22 +39,25 @@ suite('DataScience - DataViewer', () => {
dataProvider = mock(JupyterVariableDataProvider);
const settings = mock(JupyterSettings);
const settingsChangedEvent = new EventEmitter<void>();
const context: IExtensionContext = mock<IExtensionContext>();

when(settings.onDidChange).thenReturn(settingsChangedEvent.event);
when(configService.getSettings(anything())).thenReturn(instance(settings));

const configChangeEvent = new EventEmitter<ConfigurationChangeEvent>();
when(workspaceService.onDidChangeConfiguration).thenReturn(configChangeEvent.event);

when(workspaceService.onDidChangeConfiguration).thenReturn(configChangeEvent.event);
when(dataProvider.getDataFrameInfo(anything(), anything())).thenResolve({});
when(context.extensionUri).thenReturn(Uri.parse('/'));

dataViewer = new DataViewer(
instance(webPanelProvider),
instance(configService),
instance(workspaceService),
instance(applicationShell),
new MockMemento(),
instance(mock<IDataScienceErrorHandler>())
instance(mock<IDataScienceErrorHandler>()),
instance(context)
);
});
test('Data viewer showData calls gets dataFrame info from data provider', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { traceInfo } from '../../../platform/logging';
import { PythonEnvironment } from '../../../platform/pythonEnvironments/info';
import { IInterpreterService } from '../../../platform/interpreter/contracts';
import { Commands } from '../../../platform/common/constants';
import { DataViewer } from '../../../webviews/extension-side/dataviewer/dataViewer.node';
import { DataViewer } from '../../../webviews/extension-side/dataviewer/dataViewer';
import { IVariableViewProvider } from '../../../webviews/extension-side/variablesView/types';

suite('DataScience - VariableView', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EventEmitter, Memento, Uri, ViewColumn } from 'vscode';

import { sendTelemetryEvent } from '../../../telemetry';
import { JupyterDataRateLimitError } from '../../../platform/errors/jupyterDataRateLimitError';
import { DataViewerMessageListener } from './dataViewerMessageListener.node';
import { DataViewerMessageListener } from './dataViewerMessageListener';
import {
DataViewerMessages,
IDataFrameInfo,
Expand All @@ -19,10 +19,7 @@ import {
IGetSliceRequest,
IJupyterVariableDataProvider
} from './types';
import {
isValidSliceExpression,
preselectedSliceExpression
} from '../../../webviews/webview-side/data-explorer/helpers';
import { isValidSliceExpression, preselectedSliceExpression } from '../../webview-side/data-explorer/helpers';
import { CheckboxState } from '../../../telemetry/constants';
import { IKernel } from '../../../kernels/types';
import {
Expand All @@ -32,19 +29,24 @@ import {
} from '../../../platform/common/application/types';
import { HelpLinks } from '../../../platform/common/constants';
import { traceError, traceInfo } from '../../../platform/logging';
import { IConfigurationService, IMemento, GLOBAL_MEMENTO, Resource, IDisposable } from '../../../platform/common/types';
import {
IConfigurationService,
IMemento,
GLOBAL_MEMENTO,
Resource,
IDisposable,
IExtensionContext
} from '../../../platform/common/types';
import * as localize from '../../../platform/common/utils/localize';
import { StopWatch } from '../../../platform/common/utils/stopWatch';
import { EXTENSION_ROOT_DIR } from '../../../platform/constants.node';
import { IDataScienceErrorHandler } from '../../../platform/errors/types';
import { Telemetry } from '../../webview-side/common/constants';
import { WebViewViewChangeEventArgs } from '../types';
import { WebviewPanelHost } from '../webviewPanelHost.node';
import { WebviewPanelHost } from '../webviewPanelHost';
import { noop } from '../../../platform/common/utils/misc';
import { joinPath } from '../../../platform/vscode-path/resources';

const PREFERRED_VIEWGROUP = 'JupyterDataViewerPreferredViewColumn';
const dataExplorerDir = joinPath(Uri.file(EXTENSION_ROOT_DIR), 'out', 'webviews', 'webview-side', 'viewers');
@injectable()
export class DataViewer extends WebviewPanelHost<IDataViewerMapping> implements IDataViewer, IDisposable {
private dataProvider: IDataViewerDataProvider | IJupyterVariableDataProvider | undefined;
Expand Down Expand Up @@ -79,8 +81,10 @@ export class DataViewer extends WebviewPanelHost<IDataViewerMapping> implements
@inject(IWorkspaceService) workspaceService: IWorkspaceService,
@inject(IApplicationShell) private applicationShell: IApplicationShell,
@inject(IMemento) @named(GLOBAL_MEMENTO) readonly globalMemento: Memento,
@inject(IDataScienceErrorHandler) readonly errorHandler: IDataScienceErrorHandler
@inject(IDataScienceErrorHandler) readonly errorHandler: IDataScienceErrorHandler,
@inject(IExtensionContext) readonly context: IExtensionContext
) {
const dataExplorerDir = joinPath(context.extensionUri, 'out', 'webviews', 'webview-side', 'viewers');
super(
configuration,
provider,
Expand Down
2 changes: 1 addition & 1 deletion src/webviews/extension-side/plotting/plotViewer.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { IConfigurationService, IDisposable } from '../../../platform/common/typ
import { IFileSystemNode } from '../../../platform/common/platform/types.node';
import * as localize from '../../../platform/common/utils/localize';
import { EXTENSION_ROOT_DIR } from '../../../platform/constants.node';
import { WebviewPanelHost } from '../webviewPanelHost.node';
import { WebviewPanelHost } from '../webviewPanelHost';
import { joinPath } from '../../../platform/vscode-path/resources';
import { noop } from '../../../platform/common/utils/misc';

Expand Down
2 changes: 1 addition & 1 deletion src/webviews/extension-side/serviceRegistry.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { RendererCommunication } from './plotView/rendererCommunication.node';
import { PlotSaveHandler } from './plotView/plotSaveHandler.node';
import { PlotViewHandler } from './plotView/plotViewHandler.node';
import { DataViewerCommandRegistry } from './dataviewer/dataViewerCommandRegistry';
import { DataViewer } from './dataviewer/dataViewer.node';
import { DataViewer } from './dataviewer/dataViewer';
import { IPlotViewer, IPlotViewerProvider } from './plotting/types';
import { PlotViewer } from './plotting/plotViewer.node';
import { DataViewerDependencyService } from './dataviewer/dataViewerDependencyService.node';
Expand Down
3 changes: 3 additions & 0 deletions src/webviews/extension-side/serviceRegistry.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { VariableViewProvider } from './variablesView/variableViewProvider';
import { JupyterVariableDataProvider } from './dataviewer/jupyterVariableDataProvider';
import { JupyterVariableDataProviderFactory } from './dataviewer/jupyterVariableDataProviderFactory';
import {
IDataViewer,
IDataViewerFactory,
IJupyterVariableDataProvider,
IJupyterVariableDataProviderFactory
Expand All @@ -24,6 +25,7 @@ import { DataViewerFactory } from './dataviewer/dataViewerFactory';
import { ExtensionSideRenderer, IExtensionSideRenderer } from './renderer';
import { ActiveEditorContextService } from './activeEditorContext';
import { GlobalActivation } from './globalActivation';
import { DataViewer } from './dataviewer/dataViewer';
import { INotebookExporter } from '../../kernels/jupyter/types';
import { JupyterExporter } from './import-export/jupyterExporter';

Expand All @@ -38,6 +40,7 @@ export function registerTypes(serviceManager: IServiceManager, _isDevMode: boole
serviceManager.add<IWebviewPanelProvider>(IWebviewPanelProvider, WebviewPanelProvider);

// Data viewer
serviceManager.add<IDataViewer>(IDataViewer, DataViewer);
serviceManager.addSingleton<IDataViewerFactory>(IDataViewerFactory, DataViewerFactory);
serviceManager.addSingleton<IExtensionSingleActivationService>(
IExtensionSingleActivationService,
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"resolveJsonModule": true,
"removeComments": true,
"useUnknownInCatchVariables": false,
"strictPropertyInitialization": false,
"types": ["@types/vscode-notebook-renderer/preload", "webpack-env"]
},
"exclude": [
Expand Down

0 comments on commit c925935

Please sign in to comment.