Skip to content

Commit

Permalink
Remove hideSoSWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
BoPeng committed Oct 16, 2024
1 parent b14dbc6 commit 99e1d4c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 20 deletions.
18 changes: 0 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,15 +662,6 @@ function connectSoSComm(panel: NotebookPanel, renew: boolean = false) {
}
}

function hideSoSWidgets(element: HTMLElement) {
let sos_elements = element.getElementsByClassName(
'jp-CelllanguageDropDown'
) as HTMLCollectionOf<HTMLElement>;
for (let i = 0; i < sos_elements.length; ++i)
sos_elements[i].style.display = 'none';
}



(<any>window).task_action = async function (param) {
if (!param.action) {
Expand Down Expand Up @@ -731,10 +722,6 @@ export class SoSWidgets

// this is a singleton class
context.sessionContext.ready.then(() => {
// kernel information (for opened notebook) should be ready at this time.
// However, when the notebook is created from File -> New Notebook -> Select Kernel
// The kernelPreference.name is not yet set and we have to use kernelDisplayName
// which is SoS (not sos)
void context.sessionContext.session?.kernel?.info.then(kernel_info => {
const lang = kernel_info.language_info;
const kernel_name = context.sessionContext.session.kernel.name;
Expand All @@ -758,8 +745,6 @@ export class SoSWidgets
}
updateCellStyles(panel, info);
showSoSWidgets(panel.node);
} else {
hideSoSWidgets(panel.node);
}
})
});
Expand Down Expand Up @@ -788,9 +773,6 @@ export class SoSWidgets
}
updateCellStyles(panel, info);
showSoSWidgets(panel.node);
} else {
// in this case, the .sos_widget should be hidden
hideSoSWidgets(panel.node);
}
});
});
Expand Down
5 changes: 3 additions & 2 deletions src/selectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import { ReactWidget } from '@jupyterlab/apputils';
import React from 'react';

const CELL_LANGUAGE_DROPDOWN_CLASS = 'jp-CelllanguageDropDown';
const CELL_HIDDEN_LANGUAGE_DROPDOWN_CLASS = 'jp-Hidden'

export function showSoSWidgets(element: HTMLElement) {
let sos_elements = element.getElementsByClassName(
CELL_LANGUAGE_DROPDOWN_CLASS
) as HTMLCollectionOf<HTMLElement>;
for (let i = 0; i < sos_elements.length; ++i)
sos_elements[i].classList.remove('jp-Hidden');
sos_elements[i].classList.remove(CELL_HIDDEN_LANGUAGE_DROPDOWN_CLASS);
}

export function saveKernelInfo() {
Expand Down Expand Up @@ -333,7 +334,7 @@ export class KernelSwitcher extends ReactWidget {

return (
<HTMLSelect
className={CELL_LANGUAGE_DROPDOWN_CLASS + " jp-Hidden"}
className={CELL_LANGUAGE_DROPDOWN_CLASS + " " + CELL_HIDDEN_LANGUAGE_DROPDOWN_CLASS}
onChange={this.handleChange}
onKeyDown={this.handleKeyDown}
value={kernel ? kernel : 'SoS'}
Expand Down

0 comments on commit 99e1d4c

Please sign in to comment.