Skip to content

Commit

Permalink
Restyle data viewer and add slice data panel (#4805)
Browse files Browse the repository at this point in the history
  • Loading branch information
joyceerhl authored Feb 23, 2021
1 parent 72a8527 commit b634a4d
Show file tree
Hide file tree
Showing 29 changed files with 1,525 additions and 131 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ module.exports = {
'src/test/datascience/cellMatcher.unit.test.ts',
'src/test/datascience/crossProcessLock.unit.test.ts',
'src/test/datascience/uiTests/helpers.ts',
'src/test/datascience/uiTests/webBrowserPanel.ts',
'src/test/datascience/uiTests/notebookUi.ts',
'src/test/datascience/uiTests/webBrowserPanelProvider.ts',
'src/test/datascience/uiTests/recorder.ts',
Expand Down Expand Up @@ -297,7 +296,6 @@ module.exports = {
'src/test/datascience/jupyter/jupyterConnection.unit.test.ts',
'src/test/datascience/jupyter/serverCache.unit.test.ts',
'src/test/datascience/mockWorkspaceConfig.ts',
'src/test/datascience/mountedWebView.ts',
'src/test/datascience/mockProcessService.ts',
'src/test/datascience/testNativeEditorProvider.ts',
'src/test/datascience/cellFactory.unit.test.ts',
Expand Down Expand Up @@ -415,11 +413,9 @@ module.exports = {
'src/datascience-ui/common/index.ts',
'src/datascience-ui/startPage/index.tsx',
'src/datascience-ui/startPage/startPage.tsx',
'src/datascience-ui/data-explorer/index.tsx',
'src/datascience-ui/data-explorer/globalJQueryImports.ts',
'src/datascience-ui/data-explorer/emptyRowsView.tsx',
'src/datascience-ui/data-explorer/progressBar.tsx',
'src/datascience-ui/data-explorer/reactSlickGridFilterBox.tsx',
'src/client/interpreter/interpreterService.ts',
'src/client/interpreter/configuration/interpreterComparer.ts',
'src/client/interpreter/configuration/interpreterSelector/commands/base.ts',
Expand Down
28 changes: 28 additions & 0 deletions ThirdPartyNotices-Repository.txt
Original file line number Diff line number Diff line change
Expand Up @@ -956,3 +956,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
=========================================
END OF vscodeJupyter NOTICES, INFORMATION, AND LICENSE

%% Seti UI NOTICES, INFORMATION, AND LICENSE BEGIN HERE
=========================================

MIT License

Copyright (c) 2014 Jesse Weed

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=========================================
END OF Seti UI NOTICES, INFORMATION, AND LICENSE
1 change: 1 addition & 0 deletions news/1 Enhancements/305.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ability to view a slice of the current variable in the data viewer using either axis/index dropdowns or a slice expression input field.
1 change: 1 addition & 0 deletions news/1 Enhancements/4689.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Always open the data viewer in the last view group that it was moved to.
169 changes: 169 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1867,6 +1867,7 @@
},
"dependencies": {
"@enonic/fnv-plus": "^1.3.0",
"@fluentui/react": "^7.160.1",
"@jupyter-widgets/base": "^2.0.1",
"@jupyter-widgets/controls": "^1.5.2",
"@jupyter-widgets/jupyterlab-manager": "^1.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,6 @@ def _VSCODE_getDataFrameInfo(df):

columnTypes = _VSCODE_builtins.list(df.dtypes)

# Make sure the index column exists
if indexColumn not in columnNames:
columnNames.insert(0, indexColumn)
columnTypes.insert(0, "int64")

# Then loop and generate our output json
columns = []
for n in _VSCODE_builtins.range(0, _VSCODE_builtins.len(columnNames)):
Expand Down
5 changes: 5 additions & 0 deletions src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,11 @@ export interface IWebviewViewOptions extends IWebviewOptions {
// Wraps the VS Code webview panel
export const IWebviewPanel = Symbol('IWebviewPanel');
export interface IWebviewPanel extends IWebview {
/**
* Editor position of the panel. This property is only set if the webview is in
* one of the editor view columns.
*/
viewColumn: ViewColumn | undefined;
setTitle(val: string): void;
/**
* Makes the webpanel show up.
Expand Down
6 changes: 5 additions & 1 deletion src/client/common/application/webviewPanels/webviewPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict';
import '../../extensions';

import { Uri, WebviewOptions, WebviewPanel as vscodeWebviewPanel, window } from 'vscode';
import { Uri, ViewColumn, WebviewOptions, WebviewPanel as vscodeWebviewPanel, window } from 'vscode';
import { IFileSystem } from '../../platform/types';
import { IDisposableRegistry } from '../../types';
import { IWebviewPanel, IWebviewPanelOptions } from '../types';
Expand Down Expand Up @@ -44,6 +44,10 @@ export class WebviewPanel extends Webview implements IWebviewPanel {
}
}

public get viewColumn(): ViewColumn | undefined {
return this.panel?.viewColumn;
}

public isVisible(): boolean {
return this.panel ? this.panel.visible : false;
}
Expand Down
27 changes: 21 additions & 6 deletions src/client/datascience/data-viewing/dataViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@
'use strict';
import '../../common/extensions';

import { inject, injectable } from 'inversify';
import { inject, injectable, named } from 'inversify';
import * as path from 'path';
import { ViewColumn } from 'vscode';
import { Memento, ViewColumn } from 'vscode';

import { IApplicationShell, IWebviewPanelProvider, IWorkspaceService } from '../../common/application/types';
import { EXTENSION_ROOT_DIR, UseCustomEditorApi } from '../../common/constants';
import { traceError } from '../../common/logger';
import { IConfigurationService, IDisposable, IExperimentService, Resource } from '../../common/types';
import {
GLOBAL_MEMENTO,
IConfigurationService,
IDisposable,
IExperimentService,
IMemento,
Resource
} from '../../common/types';
import * as localize from '../../common/utils/localize';
import { noop } from '../../common/utils/misc';
import { StopWatch } from '../../common/utils/stopWatch';
import { sendTelemetryEvent } from '../../telemetry';
import { HelpLinks, Telemetry } from '../constants';
import { JupyterDataRateLimitError } from '../jupyter/jupyterDataRateLimitError';
import { ICodeCssGenerator, IThemeFinder } from '../types';
import { ICodeCssGenerator, IThemeFinder, WebViewViewChangeEventArgs } from '../types';
import { WebviewPanelHost } from '../webviews/webviewPanelHost';
import { DataViewerMessageListener } from './dataViewerMessageListener';
import {
Expand All @@ -31,6 +38,7 @@ import {
} from './types';
import { Experiments } from '../../common/experiments/groups';

const PREFERRED_VIEWGROUP = 'JupyterDataViewerPreferredViewColumn';
const dataExplorerDir = path.join(EXTENSION_ROOT_DIR, 'out', 'datascience-ui', 'viewers');
@injectable()
export class DataViewer extends WebviewPanelHost<IDataViewerMapping> implements IDataViewer, IDisposable {
Expand All @@ -48,7 +56,8 @@ export class DataViewer extends WebviewPanelHost<IDataViewerMapping> implements
@inject(IWorkspaceService) workspaceService: IWorkspaceService,
@inject(IApplicationShell) private applicationShell: IApplicationShell,
@inject(UseCustomEditorApi) useCustomEditorApi: boolean,
@inject(IExperimentService) private experimentService: IExperimentService
@inject(IExperimentService) private experimentService: IExperimentService,
@inject(IMemento) @named(GLOBAL_MEMENTO) readonly globalMemento: Memento
) {
super(
configuration,
Expand All @@ -60,7 +69,7 @@ export class DataViewer extends WebviewPanelHost<IDataViewerMapping> implements
dataExplorerDir,
[path.join(dataExplorerDir, 'commons.initial.bundle.js'), path.join(dataExplorerDir, 'dataExplorer.js')],
localize.DataScience.dataExplorerTitle(),
ViewColumn.One,
globalMemento.get(PREFERRED_VIEWGROUP) ?? ViewColumn.One,
useCustomEditorApi
);
}
Expand Down Expand Up @@ -100,6 +109,12 @@ export class DataViewer extends WebviewPanelHost<IDataViewerMapping> implements
}
}

protected async onViewStateChanged(args: WebViewViewChangeEventArgs) {
if (args.current.active && args.current.visible && args.previous.active && args.current.visible) {
await this.globalMemento.update(PREFERRED_VIEWGROUP, this.webPanel?.viewColumn);
}
}

protected get owningResource(): Resource {
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export class JupyterVariableDataProvider implements IJupyterVariableDataProvider
shape: JupyterVariableDataProvider.parseShape(variable.shape),
sliceExpression,
type: variable.type,
maximumRowChunkSize: variable.maximumRowChunkSize
maximumRowChunkSize: variable.maximumRowChunkSize,
name: variable.name,
fileName: variable.fileName
};
}
return dataFrameInfo;
Expand Down
Loading

0 comments on commit b634a4d

Please sign in to comment.