Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/1 Enhancements/5274.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Variable explorer UI fixes via PM / designer
2 changes: 1 addition & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
"DataScience.variableExplorerTypeColumn": "Type",
"DataScience.variableExplorerSizeColumn": "Size",
"DataScience.variableExplorerValueColumn": "Value",
"DataScience.showDataExplorerTooltip": "Show variable in data explorer.",
"DataScience.showDataExplorerTooltip": "Show variable in data viewer.",
"DataScience.dataExplorerInvalidVariableFormat": "'{0}' is not an active variable.",
"DataScience.jupyterGetVariablesExecutionError": "Failure during variable extraction:\r\n{0}",
"DataScience.loadingMessage": "loading ...",
Expand Down
1 change: 1 addition & 0 deletions src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ export type WebPanelMessage = {
// Wraps the VS Code webview panel
export const IWebPanel = Symbol('IWebPanel');
export interface IWebPanel {
title: string;
/**
* Makes the webpanel show up.
* @return A Promise that can be waited on
Expand Down
10 changes: 10 additions & 0 deletions src/client/common/application/webPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ export class WebPanel implements IWebPanel {
}
}

public get title(): string {
return this.panel ? this.panel.title : '';
}

public set title(newTitle: string) {
if (this.panel) {
this.panel.title = newTitle;
}
}

// tslint:disable-next-line:no-any
private async load(mainScriptPath: string, embeddedCss?: string, settings?: any) {
if (this.panel) {
Expand Down
9 changes: 9 additions & 0 deletions src/client/datascience/data-viewing/dataViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ export class DataViewer extends WebViewHost<IDataViewerMapping> implements IData
// Fill in our variable's beginning data
this.variable = await this.prepVariable(variable);

// Create our new title with the variable name
let newTitle = `${localize.DataScience.dataExplorerTitle()} - ${variable.name}`;
const TRIM_LENGTH = 40;
if (newTitle.length > TRIM_LENGTH) {
newTitle = `${newTitle.substr(0, TRIM_LENGTH)}...`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected such truncation to take place in CSS based on relative widths (e.g. %s of the total width, along with min width.. or similar)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DonJayamanne Hmmm, do you know of how we could actually see the widths? This is the string that goes in the VSCode editor file tab. We don't own the UI for that in our extension. When testing I realized that it doesn't truncate in the vscode editor tab (at least I was able to make a tab that took up basically my entire editor tab space) so this was just a sanity check to avoid a degenerate case with a super long variable name.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, if its for VSC, then its fine. I thought this was for the react webview.

}

super.setTitle(newTitle);

// Then show our web panel. Eventually we need to consume the data
await super.show(true);

Expand Down
6 changes: 6 additions & 0 deletions src/client/datascience/webViewHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ export class WebViewHost<IMapping> implements IDisposable {
}
}

public setTitle(newTitle: string) {
if (!this.isDisposed && this.webPanel) {
this.webPanel.title = newTitle;
}
}

//tslint:disable-next-line:no-any
protected onMessage(message: string, payload: any) {
switch (message) {
Expand Down
6 changes: 6 additions & 0 deletions src/datascience-ui/history-react/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum ImageName {
ExpandAll,
GoToSourceCode,
Interrupt,
OpenInNewWindow,
PopIn,
PopOut,
Redo,
Expand Down Expand Up @@ -51,6 +52,11 @@ const images: { [key: string] : { light: string; dark: string } } = {
light: require('./images/Interrupt/Interrupt_16x_vscode.svg'),
dark : require('./images/Interrupt/Interrupt_16x_vscode_dark.svg')
},
OpenInNewWindow:
{
light: require('./images/OpenInNewWindow/OpenInNewWindow_16x_vscode.svg'),
dark : require('./images/OpenInNewWindow/OpenInNewWindow_16x_vscode_dark.svg')
},
PopIn:
{
light: require('./images/PopIn/PopIn_16x_vscode.svg'),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/datascience-ui/history-react/variableExplorer.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
margin: 5px;
background-color: var(--vscode-editor-background);
}

#variable-explorer-data-grid {
margin: 4px;
}
9 changes: 9 additions & 0 deletions src/datascience-ui/history-react/variableExplorer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export class VariableExplorer extends React.Component<IVariableExplorerProps, IV
minHeight = {this.state.gridHeight}
headerRowHeight = {this.state.fontSize + 9}
rowHeight = {this.state.fontSize + 9}
onRowDoubleClick = {this.rowDoubleClick}
/>
</div>
</div>
Expand Down Expand Up @@ -156,6 +157,14 @@ export class VariableExplorer extends React.Component<IVariableExplorerProps, IV
this.props.variableExplorerToggled(!this.state.open);
}

private rowDoubleClick = (_rowIndex: number, row: IGridRow) => {
// On row double click, see if data explorer is supported and open it if it is
if (row.buttons && row.buttons.supportsDataExplorer !== undefined
&& row.buttons.name && row.buttons.supportsDataExplorer) {
this.props.showDataExplorer(row.buttons.name);
}
}

private updateHeight = () => {
// Make sure we check for a new height so we don't get into an update loop
const divElement = ReactDOM.findDOMNode(this) as HTMLDivElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export class VariableExplorerButtonCellFormatter extends React.Component<IVariab
if (this.props.value.supportsDataExplorer) {
return(
<div className={className}>
<CellButton baseTheme={this.props.baseTheme} tooltip={getLocString('DataScience.showDataExplorerTooltip', 'Show variable in data explorer.')} onClick={this.onDataExplorerClick}>
<Image baseTheme={this.props.baseTheme} class='cell-button-image' image={ImageName.CollapseAll}/>
<CellButton baseTheme={this.props.baseTheme} tooltip={getLocString('DataScience.showDataExplorerTooltip', 'Show variable in data viewer.')} onClick={this.onDataExplorerClick}>
<Image baseTheme={this.props.baseTheme} class='cell-button-image' image={ImageName.OpenInNewWindow}/>
</CellButton>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/datascience-ui/history-react/variableExplorerGrid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
}

#variable-explorer-data-grid .react-grid-Main {
font-family: var(--code-font-family);
background-color: var(--vscode-editor-background);
color: var(--vscode-editor-foreground);
outline: none;
Expand Down
1 change: 1 addition & 0 deletions types/react-data-grid.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ declare namespace AdazzleReactDataGrid {
* @param row object behind the row
*/
onRowClick?: (rowIdx: number, row: T) => void
onRowDoubleClick?: (rowIdx: number, row: T) => void

/**
* An event function called when a row is expanded with the toggle
Expand Down