Skip to content

Commit

Permalink
unlink checkbox with setting
Browse files Browse the repository at this point in the history
  • Loading branch information
NexVeridian committed May 13, 2024
1 parent f8e1aad commit 7e0c6a6
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions packages/apputils/src/sessioncontext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ export namespace ISessionContext {
* found (default `false`).
*/
readonly autoStartDefault?: boolean;

/**
* Skip showing the kernel restart dialog if checked (default `false`).
*/
readonly skipKernelRestartDialog?: boolean;
}

export type KernelDisplayStatus =
Expand Down Expand Up @@ -1421,13 +1426,15 @@ export class SessionContextDialogs implements ISessionContext.IDialogs {

// Skip the dialog and restart the kernel
const kernelPluginId = '@jupyterlab/apputils-extension:sessionDialogs';
const skipKernelRestartDialog =
sessionContext.kernelPreference?.skipKernelRestartDialog ?? false;
const skipKernelRestartDialogSetting = (
await this._settingRegistry?.get(
kernelPluginId,
'skipKernelRestartDialog'
)
)?.composite as boolean;
if (skipKernelRestartDialogSetting) {
if (skipKernelRestartDialogSetting || skipKernelRestartDialog) {
await sessionContext.restartKernel();
return true;
}
Expand Down Expand Up @@ -1458,17 +1465,22 @@ export class SessionContextDialogs implements ISessionContext.IDialogs {
return false;
}
if (result.button.accept) {
if (
typeof result.isChecked === 'boolean' &&
result.isChecked == true &&
this._settingRegistry
) {
if (this._settingRegistry) {
this._settingRegistry
.set(kernelPluginId, 'skipKernelRestartDialog', !result.isChecked)
.catch(reason => {
.catch((reason: any) => {
console.error(`Fail to set 'skipKernelRestartDialog:\n${reason}`);
});
} else if (
typeof result.isChecked === 'boolean' &&
result.isChecked == true
) {
sessionContext.kernelPreference = {
...sessionContext.kernelPreference,
skipKernelRestartDialog: true
};
}

await sessionContext.restartKernel();
return true;
}
Expand Down

0 comments on commit 7e0c6a6

Please sign in to comment.