|
@@ -132,7 +132,15 @@ export interface ISessionContext extends IObservableDisposable {
|
|
|
kernelPreference: ISessionContext.IKernelPreference;
|
|
|
|
|
|
/**
|
|
|
- * The sensible display name for the kernel, or "No Kernel"
|
|
|
+ * Whether the kernel is "No Kernel" or not.
|
|
|
+ *
|
|
|
+ * #### Notes
|
|
|
+ * As the displayed name is translated, this can be used directly.
|
|
|
+ */
|
|
|
+ readonly hasNoKernel: boolean;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The sensible display name for the kernel, or translated "No Kernel"
|
|
|
*
|
|
|
* #### Notes
|
|
|
* This is at this level since the underlying kernel connection does not
|
|
@@ -478,6 +486,16 @@ export class SessionContext implements ISessionContext {
|
|
|
*/
|
|
|
readonly specsManager: KernelSpec.IManager;
|
|
|
|
|
|
+ /**
|
|
|
+ * Whether the kernel is "No Kernel" or not.
|
|
|
+ *
|
|
|
+ * #### Notes
|
|
|
+ * As the displayed name is translated, this can be used directly.
|
|
|
+ */
|
|
|
+ get hasNoKernel(): boolean {
|
|
|
+ return this.kernelDisplayName === this.noKernelName;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* The display name of the current kernel, or a sensible alternative.
|
|
|
*
|
|
@@ -487,8 +505,8 @@ export class SessionContext implements ISessionContext {
|
|
|
*/
|
|
|
get kernelDisplayName(): string {
|
|
|
const kernel = this.session?.kernel;
|
|
|
- if (this._pendingKernelName === this._trans.__('No Kernel')) {
|
|
|
- return this._trans.__('No Kernel');
|
|
|
+ if (this._pendingKernelName === this.noKernelName) {
|
|
|
+ return this.noKernelName;
|
|
|
}
|
|
|
if (
|
|
|
!kernel &&
|
|
@@ -508,7 +526,7 @@ export class SessionContext implements ISessionContext {
|
|
|
name = this.specsManager.specs?.kernelspecs[name]?.display_name ?? name;
|
|
|
return name;
|
|
|
}
|
|
|
- return this._trans.__('No Kernel');
|
|
|
+ return this.noKernelName;
|
|
|
}
|
|
|
if (this._pendingKernelName) {
|
|
|
return (
|
|
@@ -517,7 +535,7 @@ export class SessionContext implements ISessionContext {
|
|
|
);
|
|
|
}
|
|
|
if (!kernel) {
|
|
|
- return this._trans.__('No Kernel');
|
|
|
+ return this.noKernelName;
|
|
|
}
|
|
|
return (
|
|
|
this.specsManager.specs?.kernelspecs[kernel.name]?.display_name ??
|
|
@@ -543,7 +561,7 @@ export class SessionContext implements ISessionContext {
|
|
|
return 'restarting';
|
|
|
}
|
|
|
|
|
|
- if (this._pendingKernelName === this._trans.__('No Kernel')) {
|
|
|
+ if (this._pendingKernelName === this.noKernelName) {
|
|
|
return 'idle';
|
|
|
}
|
|
|
|
|
@@ -588,6 +606,13 @@ export class SessionContext implements ISessionContext {
|
|
|
return this._disposed;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Get the constant displayed name for "No Kernel"
|
|
|
+ */
|
|
|
+ protected get noKernelName(): string {
|
|
|
+ return this._trans.__('No Kernel');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Dispose of the resources held by the context.
|
|
|
*/
|
|
@@ -668,7 +693,7 @@ export class SessionContext implements ISessionContext {
|
|
|
}
|
|
|
await this._initStarted.promise;
|
|
|
this._pendingSessionRequest = '';
|
|
|
- this._pendingKernelName = this._trans.__('No Kernel');
|
|
|
+ this._pendingKernelName = this.noKernelName;
|
|
|
return this._shutdownSession();
|
|
|
}
|
|
|
|
|
@@ -1216,8 +1241,8 @@ export const sessionContextDialogs: ISessionContext.IDialogs = {
|
|
|
// If there is no existing kernel, offer the option
|
|
|
// to keep no kernel.
|
|
|
let label = trans.__('Cancel');
|
|
|
- if (sessionContext.kernelDisplayName === trans.__('No Kernel')) {
|
|
|
- label = trans.__('No Kernel');
|
|
|
+ if (sessionContext.hasNoKernel) {
|
|
|
+ label = sessionContext.kernelDisplayName;
|
|
|
}
|
|
|
const buttons = [
|
|
|
Dialog.cancelButton({ label }),
|
|
@@ -1235,10 +1260,7 @@ export const sessionContextDialogs: ISessionContext.IDialogs = {
|
|
|
return;
|
|
|
}
|
|
|
const model = result.value;
|
|
|
- if (
|
|
|
- model === null &&
|
|
|
- sessionContext.kernelDisplayName !== trans.__('No Kernel')
|
|
|
- ) {
|
|
|
+ if (model === null && !sessionContext.hasNoKernel) {
|
|
|
return sessionContext.shutdown();
|
|
|
}
|
|
|
if (model) {
|
|
@@ -1347,7 +1369,7 @@ namespace Private {
|
|
|
selector,
|
|
|
options,
|
|
|
translator,
|
|
|
- sessionContext.kernelDisplayName
|
|
|
+ !sessionContext.hasNoKernel ? sessionContext.kernelDisplayName : null
|
|
|
);
|
|
|
body.appendChild(selector);
|
|
|
return body;
|
|
@@ -1424,7 +1446,7 @@ namespace Private {
|
|
|
node: HTMLSelectElement,
|
|
|
options: SessionContext.IKernelSearch,
|
|
|
translator?: ITranslator,
|
|
|
- currentKernelDisplayName?: string
|
|
|
+ currentKernelDisplayName: string | null = null
|
|
|
): void {
|
|
|
while (node.firstChild) {
|
|
|
node.removeChild(node.firstChild);
|