From 99e1d4c4d0c5ca8b8662cd24d78e6ef1f2e253d2 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Wed, 16 Oct 2024 11:22:45 -0500 Subject: [PATCH] Remove hideSoSWidget --- src/index.ts | 18 ------------------ src/selectors.tsx | 5 +++-- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/index.ts b/src/index.ts index f4ce4ba..2405b37 100644 --- a/src/index.ts +++ b/src/index.ts @@ -662,15 +662,6 @@ function connectSoSComm(panel: NotebookPanel, renew: boolean = false) { } } -function hideSoSWidgets(element: HTMLElement) { - let sos_elements = element.getElementsByClassName( - 'jp-CelllanguageDropDown' - ) as HTMLCollectionOf; - for (let i = 0; i < sos_elements.length; ++i) - sos_elements[i].style.display = 'none'; -} - - (window).task_action = async function (param) { if (!param.action) { @@ -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; @@ -758,8 +745,6 @@ export class SoSWidgets } updateCellStyles(panel, info); showSoSWidgets(panel.node); - } else { - hideSoSWidgets(panel.node); } }) }); @@ -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); } }); }); diff --git a/src/selectors.tsx b/src/selectors.tsx index 00b9e3a..cedd039 100644 --- a/src/selectors.tsx +++ b/src/selectors.tsx @@ -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; 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() { @@ -333,7 +334,7 @@ export class KernelSwitcher extends ReactWidget { return (