Notebooks: Save connection information in metadata (#13060)

* save connection info in notebook metadata

* update attachTo dropdown based on saved alias

* add setting for saving connection (default=false)

* dont show saved conn if seting off + added test

* show conn dialog if save conn name setting off

* address PR comments and fix unit test

* change connectionName to connection_name
This commit is contained in:
Lucy Zhang
2020-10-30 13:56:33 -07:00
committed by GitHub
parent 17073f9d2a
commit 69527f91b0
11 changed files with 144 additions and 21 deletions

View File

@@ -331,7 +331,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.capabilitiesService);
}, this.profile, this.logService, this.notificationService, this.adstelemetryService, this.connectionManagementService, this._configurationService, 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)));
@@ -429,7 +429,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
let attachToContainer = document.createElement('li');
let attachToDropdown = new AttachToDropdown(attachToContainer, this.contextViewService, this.modelReady,
this.connectionManagementService, this.connectionDialogService, this.notificationService, this.capabilitiesService);
this.connectionManagementService, this.connectionDialogService, this.notificationService, this.capabilitiesService, this._configurationService);
attachToDropdown.render(attachToContainer);
attachSelectBoxStyler(attachToDropdown, this.themeService);
@@ -493,7 +493,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
let attachToContainer = document.createElement('div');
let attachToDropdown = new AttachToDropdown(attachToContainer, this.contextViewService, this.modelReady,
this.connectionManagementService, this.connectionDialogService, this.notificationService, this.capabilitiesService);
this.connectionManagementService, this.connectionDialogService, this.notificationService, this.capabilitiesService, this._configurationService);
attachToDropdown.render(attachToContainer);
attachSelectBoxStyler(attachToDropdown, this.themeService);

View File

@@ -230,7 +230,12 @@ configurationRegistry.registerConfiguration({
'type': 'boolean',
'default': true,
'description': localize('notebook.setRichTextViewByDefault', "Set Rich Text View mode by default for text cells")
}
},
'notebook.saveConnectionName': {
'type': 'boolean',
'default': false,
'description': localize('notebook.saveConnectionName', "(Preview) Save connection name in notebook metadata.")
},
}
});

View File

@@ -355,6 +355,7 @@ export class KernelsDropdown extends SelectBox {
}
const attachToDropdownElementId = 'attach-to-dropdown';
const saveConnectionNameConfigName = 'notebook.saveConnectionName';
export class AttachToDropdown extends SelectBox {
private model: NotebookModel;
@@ -365,6 +366,7 @@ export class AttachToDropdown extends SelectBox {
@IConnectionDialogService private _connectionDialogService: IConnectionDialogService,
@INotificationService private _notificationService: INotificationService,
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
@IConfigurationService private _configurationService: IConfigurationService
) {
super([msgLoadingContexts], msgLoadingContexts, contextViewProvider, container, { labelText: attachToLabel, labelOnTop: false, ariaLabel: attachToLabel, id: attachToDropdownElementId } as ISelectBoxOptionsWithLabel);
if (modelReady) {
@@ -428,7 +430,14 @@ export class AttachToDropdown extends SelectBox {
if ((connProviderIds && connProviderIds.length === 0) || currentKernel === noKernel) {
this.setOptions([msgLocalHost]);
} else {
let connections: string[] = model.context && model.context.title && (connProviderIds.includes(this.model.context.providerName)) ? [model.context.title] : [msgSelectConnection];
let connections: string[] = [];
if (model.context && model.context.title && (connProviderIds.includes(this.model.context.providerName))) {
connections.push(model.context.title);
} else if (this._configurationService.getValue(saveConnectionNameConfigName) && model.savedConnectionName) {
connections.push(model.savedConnectionName);
} else {
connections.push(msgSelectConnection);
}
if (!connections.find(x => x === msgChangeConnection)) {
connections.push(msgChangeConnection);
}