mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 01:25:38 -05:00
Kusto Notebook Kernel Changes (#11760)
* Able to get Kernel Alias using extension registery * Get Kernel Alias through Capability Services * Notebook Action feature to add kusto to dropdown based on extension - complete * Fixed indexing issue when Kusto is in kernels Dropdown * Kusto Kernel listed properly and selected when kernel changes * Added kernel change when user Attaches To Kusto connection * Deleted unnecessary code/refactored * Fix Merge Issues * Resolving Compile issues - test file error * Capabilities Provider Changes * Fixed Notebook Tests * Rearchitect kernel changes to Notebook Model * Address minor changes
This commit is contained in:
@@ -313,7 +313,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
layoutChanged: this._notebookParams.input.layoutChanged,
|
||||
capabilitiesService: this.capabilitiesService,
|
||||
editorLoadedTimestamp: this._notebookParams.input.editorOpenedTimestamp
|
||||
}, this.profile, this.logService, this.notificationService, this.adstelemetryService);
|
||||
}, this.profile, this.logService, this.notificationService, this.adstelemetryService, this.capabilitiesService);
|
||||
let trusted = await this.notebookService.isNotebookTrustCached(this._notebookParams.notebookUri, this.isDirty());
|
||||
this._register(model.onError((errInfo: INotification) => this.handleModelError(errInfo)));
|
||||
this._register(model.contentChanged((change) => this.handleContentChanged(change)));
|
||||
|
||||
@@ -274,6 +274,7 @@ export class CollapseCellsAction extends ToggleableAction {
|
||||
const showAllKernelsConfigName = 'notebook.showAllKernels';
|
||||
const workbenchPreviewConfigName = 'workbench.enablePreviewFeatures';
|
||||
export const noKernelName = localize('noKernel', "No Kernel");
|
||||
|
||||
export class KernelsDropdown extends SelectBox {
|
||||
private model: NotebookModel;
|
||||
private _showAllKernels: boolean = false;
|
||||
@@ -300,16 +301,21 @@ export class KernelsDropdown extends SelectBox {
|
||||
updateModel(model: INotebookModel): void {
|
||||
this.model = model as NotebookModel;
|
||||
this._register(this.model.kernelChanged((changedArgs: azdata.nb.IKernelChangedArgs) => {
|
||||
this.updateKernel(changedArgs.newValue);
|
||||
this.updateKernel(changedArgs.newValue, changedArgs.nbKernelAlias);
|
||||
}));
|
||||
let kernel = this.model.clientSession && this.model.clientSession.kernel;
|
||||
this.updateKernel(kernel);
|
||||
}
|
||||
|
||||
// Update SelectBox values
|
||||
public updateKernel(kernel: azdata.nb.IKernel) {
|
||||
public updateKernel(kernel: azdata.nb.IKernel, nbKernelAlias?: string) {
|
||||
let kernels: string[] = this._showAllKernels ? [...new Set(this.model.specs.kernels.map(a => a.display_name).concat(this.model.standardKernelsDisplayName()))]
|
||||
: this.model.standardKernelsDisplayName();
|
||||
if (this.model.kernelAliases?.length) {
|
||||
for (let x in this.model.kernelAliases) {
|
||||
kernels.splice(1, 0, this.model.kernelAliases[x]);
|
||||
}
|
||||
}
|
||||
if (kernel && kernel.isReady) {
|
||||
let standardKernel = this.model.getStandardKernelFromName(kernel.name);
|
||||
if (kernels) {
|
||||
@@ -320,6 +326,9 @@ export class KernelsDropdown extends SelectBox {
|
||||
let kernelSpec = this.model.specs.kernels.find(k => k.name === kernel.name);
|
||||
index = firstIndex(kernels, k => k === kernelSpec?.display_name);
|
||||
}
|
||||
if (nbKernelAlias) {
|
||||
index = kernels.indexOf(nbKernelAlias);
|
||||
}
|
||||
// This is an error case that should never happen
|
||||
// Just in case, setting index to 0
|
||||
if (index < 0) {
|
||||
@@ -477,6 +486,13 @@ export class AttachToDropdown extends SelectBox {
|
||||
this.model.addAttachToConnectionsToBeDisposed(connectionUri);
|
||||
// Call doChangeContext to set the newly chosen connection in the model
|
||||
this.doChangeContext(connectionProfile);
|
||||
|
||||
//Changes kernel based on connection attached to
|
||||
if (this.model.kernelAliases.includes(connectionProfile.serverCapabilities.notebookKernelAlias)) {
|
||||
this.model.changeKernel(connectionProfile.serverCapabilities.notebookKernelAlias);
|
||||
} else {
|
||||
this.model.changeKernel('SQL');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -396,11 +396,12 @@ suite('Notebook Actions', function (): void {
|
||||
const e: azdata.nb.IKernelChangedArgs = <azdata.nb.IKernelChangedArgs>{
|
||||
newValue: <azdata.nb.IKernel>{
|
||||
name: 'StandardKernel2'
|
||||
}
|
||||
},
|
||||
nbKernelAlias: ''
|
||||
};
|
||||
notebookModel.kernelChangedEmitter.fire(e);
|
||||
assert.ok(updateKernelStub.calledOnce, `updateKernel should be called exactly once`);
|
||||
assert.ok(updateKernelStub.calledWithExactly(e.newValue), `updateKernel should be called with the parameter: ${JSON.stringify(e.newValue)}`);
|
||||
assert.ok(updateKernelStub.calledWithExactly(e.newValue, e.nbKernelAlias), `updateKernel should be called with the parameter: ${JSON.stringify(e.newValue), JSON.stringify(e.nbKernelAlias)}`);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user