mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-25 01:25:36 -05:00
Introduce Trust Book in Book Viewlet (#9414)
This commit is contained in:
@@ -233,6 +233,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
|
||||
public set trustedMode(isTrusted: boolean) {
|
||||
this._trustedMode = isTrusted;
|
||||
|
||||
if (this._cells) {
|
||||
this._cells.forEach(c => {
|
||||
c.trustedMode = this._trustedMode;
|
||||
@@ -290,6 +291,7 @@ export class NotebookModel extends Disposable implements INotebookModel {
|
||||
public async loadContents(isTrusted: boolean = false): Promise<void> {
|
||||
try {
|
||||
this._trustedMode = isTrusted;
|
||||
|
||||
let contents = null;
|
||||
|
||||
if (this._notebookOptions && this._notebookOptions.contentManager) {
|
||||
|
||||
@@ -112,6 +112,13 @@ export interface INotebookService {
|
||||
* @param sectionId ID of the section to navigate to
|
||||
*/
|
||||
navigateTo(notebookUri: URI, sectionId: string): void;
|
||||
|
||||
/**
|
||||
* Sets the trusted mode for the sepcified notebook.
|
||||
* @param notebookUri URI of the notebook to navigate to
|
||||
* @param isTrusted True if notebook is to be set to trusted, false otherwise.
|
||||
*/
|
||||
setTrusted(notebookUri: URI, isTrusted: boolean): Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface INotebookProvider {
|
||||
|
||||
@@ -606,4 +606,25 @@ export class NotebookService extends Disposable implements INotebookService {
|
||||
editor.navigateToSection(sectionId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trusts a notebook with the specified URI.
|
||||
* @param notebookUri The notebook URI to set the trusted mode for.
|
||||
* @param isTrusted True if the notebook is to be trusted, false otherwise.
|
||||
*/
|
||||
async setTrusted(notebookUri: URI, isTrusted: boolean): Promise<boolean> {
|
||||
let editor = this.findNotebookEditor(notebookUri);
|
||||
|
||||
if (editor && editor.model) {
|
||||
if (isTrusted) {
|
||||
this._trustedCacheQueue.push(notebookUri);
|
||||
} else {
|
||||
this._unTrustedCacheQueue.push(notebookUri);
|
||||
}
|
||||
await this.updateTrustedCache();
|
||||
editor.model.trustedMode = isTrusted;
|
||||
}
|
||||
|
||||
return isTrusted;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user