Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to hide chosen columns in diagnostics panel #159

Merged
merged 6 commits into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG

## `@krassowski/jupyterlab-lsp 0.7.1` (unreleased)

- features

- users can now choose which columns to display/hide
in the diagnostic panel, using a context menu action (
[#159](https://github.com/krassowski/jupyterlab-lsp/pull/159)
)

## `lsp-ws-connection 0.3.1`

- added `sendSaved()` method (textDocument/didSave) (
Expand Down
6 changes: 0 additions & 6 deletions atest/01_Editor.robot
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ Measure Cursor Position
${position} = Wait Until Keyword Succeeds 20 x 0.05s Get Vertical Position ${CM CURSOR}
[Return] ${position}

Open Context Menu Over
[Arguments] ${sel}
Wait Until Keyword Succeeds 10 x 0.1 s Mouse Over ${sel}
Wait Until Keyword Succeeds 10 x 0.1 s Click Element ${sel}
Wait Until Keyword Succeeds 10 x 0.1 s Open Context Menu ${sel}

Get Editor Content
${content} Execute JavaScript return document.querySelector('.CodeMirror').CodeMirror.getValue()
[Return] ${content}
Expand Down
18 changes: 18 additions & 0 deletions atest/04_Interface/DiagnosticsPanel.robot
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Resource ../Keywords.robot
*** Variables ***
${EXPECTED_COUNT} 1
${DIAGNOSTIC} W291 trailing whitespace (pycodestyle)
${DIAGNOSTIC MESSAGE} trailing whitespace
${MENU COLUMNS} xpath://div[contains(@class, 'p-Menu-itemLabel')][contains(text(), "columns")]
${MENU COLUMN MESSAGE} xpath://div[contains(@class, 'p-Menu-itemLabel')][contains(text(), "Message")]

*** Test Cases ***
Diagnostics Panel Opens
Expand Down Expand Up @@ -36,6 +39,21 @@ Diagnostics Panel Can Be Restored
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count
[Teardown] Clean Up After Working With File Panel.ipynb

Columns Can Be Hidden
[Setup] Gently Reset Workspace
Open Notebook And Panel Panel.ipynb
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
Open Context Menu Over css:.lsp-diagnostics-listing th
Capture Page Screenshot 01-menu-visible.png
Mouse Over ${MENU COLUMNS}
Wait Until Page Contains Element ${MENU COLUMN MESSAGE} timeout=10s
Mouse Over ${MENU COLUMN MESSAGE}
Capture Page Screenshot 02-message-column-visible.png
Click Element ${MENU COLUMN MESSAGE}
Capture Page Screenshot 03-message-column-toggled.png
Wait Until Keyword Succeeds 10 x 1s Element Should Not Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
[Teardown] Clean Up After Working With File Panel.ipynb

*** Keywords ***
Open Notebook And Panel
[Arguments] ${notebook}
Expand Down
6 changes: 6 additions & 0 deletions atest/Keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,9 @@ Enter Cell Editor

Wait Until Fully Initialized
Wait Until Element Contains ${STATUSBAR} Fully initialized timeout=35s

Open Context Menu Over
[Arguments] ${sel}
Wait Until Keyword Succeeds 10 x 0.1 s Mouse Over ${sel}
Wait Until Keyword Succeeds 10 x 0.1 s Click Element ${sel}
Wait Until Keyword Succeeds 10 x 0.1 s Open Context Menu ${sel}
2 changes: 2 additions & 0 deletions packages/jupyterlab-lsp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@jupyterlab/testutils": "^1.2.2",
"@jupyterlab/tooltip": "^1.1",
"@phosphor/algorithm": "*",
"@phosphor/widgets": "*",
"@types/chai": "^4.1.7",
"@types/codemirror": "^0.0.74",
"@types/events": "^3.0.0",
Expand Down Expand Up @@ -93,6 +94,7 @@
"@jupyterlab/testutils": "^1.2.2",
"@jupyterlab/tooltip": "^1.1",
"@phosphor/algorithm": "*",
"@phosphor/widgets": "*",
"codemirror": "*",
"react": "*"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import * as CodeMirror from 'codemirror';
import * as lsProtocol from 'vscode-languageserver-protocol';
import { Menu } from '@phosphor/widgets';
import { PositionConverter } from '../../../converter';
import { IVirtualPosition } from '../../../positioning';
import { diagnosticSeverityNames } from '../../../lsp';
import { DefaultMap } from '../../../utils';
import { CodeMirrorLSPFeature, IFeatureCommand } from '../feature';
import { MainAreaWidget } from '@jupyterlab/apputils';
import {
DIAGNOSTICS_LISTING_CLASS,
DiagnosticsDatabase,
DiagnosticsListing,
IEditorDiagnostic
Expand All @@ -21,6 +23,7 @@ const default_severity = 2;
class DiagnosticsPanel {
content: DiagnosticsListing;
widget: MainAreaWidget<DiagnosticsListing>;
is_registered = false;

constructor() {
this.widget = this.init_widget();
Expand Down Expand Up @@ -57,6 +60,8 @@ export const diagnostics_databases = new Map<
DiagnosticsDatabase
>();

const CMD_COLUMN_VISIBILITY = 'lsp-set-column-visibility';

export class Diagnostics extends CodeMirrorLSPFeature {
name = 'Diagnostics';

Expand All @@ -69,6 +74,44 @@ export class Diagnostics extends CodeMirrorLSPFeature {

let panel_widget = diagnostics_panel.widget;

let get_column = (name: string) => {
// TODO: a hashmap in the panel itself?
for (let column of panel_widget.content.columns) {
if (column.name === name) {
return column;
}
}
};

if (!diagnostics_panel.is_registered) {
let columns_menu = new Menu({ commands: app.commands });
app.commands.addCommand(CMD_COLUMN_VISIBILITY, {
execute: args => {
let column = get_column(args['name'] as string);
column.is_visible = !column.is_visible;
panel_widget.update();
},
label: args => args['name'] as string,
isToggled: args => {
let column = get_column(args['name'] as string);
return column.is_visible;
}
});
columns_menu.title.label = 'Panel columns';
for (let column of panel_widget.content.columns) {
columns_menu.addItem({
command: CMD_COLUMN_VISIBILITY,
args: { name: column.name }
});
}
app.contextMenu.addItem({
selector: '.' + DIAGNOSTICS_LISTING_CLASS + ' th',
submenu: columns_menu,
type: 'submenu'
});
diagnostics_panel.is_registered = true;
}

if (!panel_widget.isAttached) {
app.shell.add(panel_widget, 'main');
}
Expand Down
Loading