Fix trusting opened notebooks (#9615)

* Fix trusting opened notebooks

* Addressing comments
This commit is contained in:
Jorge Berumen
2020-03-13 18:10:55 -07:00
committed by GitHub
parent 4a54f53ae3
commit 6a1037ab2d
2 changed files with 17 additions and 0 deletions

View File

@@ -74,9 +74,22 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
let bookPathToTrust = bookTreeItem ? bookTreeItem.root : this.currentBook?.bookPath; let bookPathToTrust = bookTreeItem ? bookTreeItem.root : this.currentBook?.bookPath;
if (bookPathToTrust) { if (bookPathToTrust) {
let trustChanged = this._bookTrustManager.setBookAsTrusted(bookPathToTrust); let trustChanged = this._bookTrustManager.setBookAsTrusted(bookPathToTrust);
if (trustChanged) { if (trustChanged) {
let notebookDocuments = this._apiWrapper.getNotebookDocuments();
if (notebookDocuments) {
// update trust state of opened items
notebookDocuments.forEach(document => {
let notebook = this.currentBook.getNotebook(document.uri.fsPath);
if (notebook && this._bookTrustManager.isNotebookTrustedByDefault(document.uri.fsPath)) {
document.setTrusted(true);
}
});
}
this._apiWrapper.showInfoMessage(loc.msgBookTrusted); this._apiWrapper.showInfoMessage(loc.msgBookTrusted);
} else { } else {
this._apiWrapper.showInfoMessage(loc.msgBookAlreadyTrusted); this._apiWrapper.showInfoMessage(loc.msgBookAlreadyTrusted);

View File

@@ -65,6 +65,10 @@ export class ApiWrapper {
return vscode.commands.executeCommand(BuiltInCommands.SetContext, key, value); return vscode.commands.executeCommand(BuiltInCommands.SetContext, key, value);
} }
public getNotebookDocuments() {
return azdata.nb.notebookDocuments;
}
/** /**
* Get the configuration for a extensionName * Get the configuration for a extensionName
* @param extensionName The string name of the extension to get the configuration for * @param extensionName The string name of the extension to get the configuration for