4
4
'use strict' ;
5
5
6
6
import { inject , injectable } from 'inversify' ;
7
- import { Uri } from 'vscode' ;
8
7
import { IExtensionSingleActivationService } from '../../activation/types' ;
9
- import { IApplicationShell , ICommandManager , IVSCodeNotebook } from '../../common/application/types' ;
10
- import { traceError } from '../../common/logger' ;
8
+ import { IVSCodeNotebook } from '../../common/application/types' ;
11
9
import { IFileSystem } from '../../common/platform/types' ;
12
10
import { IDisposableRegistry } from '../../common/types' ;
13
- import { swallowExceptions } from '../../common/utils/decorators' ;
14
- import { DataScience } from '../../common/utils/localize' ;
15
- import { noop } from '../../common/utils/misc' ;
16
- import { Commands } from '../constants' ;
17
- import { INotebookStorageProvider } from '../interactive-ipynb/notebookStorageProvider' ;
18
11
import { INotebookEditorProvider , ITrustService } from '../types' ;
19
12
import { updateVSCNotebookAfterTrustingNotebook } from './helpers/cellUpdateHelpers' ;
20
13
import { isJupyterNotebook } from './helpers/helpers' ;
@@ -25,15 +18,10 @@ export class NotebookTrustHandler implements IExtensionSingleActivationService {
25
18
@inject ( ITrustService ) private readonly trustService : ITrustService ,
26
19
@inject ( IVSCodeNotebook ) private readonly vscNotebook : IVSCodeNotebook ,
27
20
@inject ( INotebookEditorProvider ) private readonly editorProvider : INotebookEditorProvider ,
28
- @inject ( INotebookStorageProvider ) private readonly storageProvider : INotebookStorageProvider ,
29
21
@inject ( IFileSystem ) private readonly fs : IFileSystem ,
30
- @inject ( ICommandManager ) private readonly commandManager : ICommandManager ,
31
- @inject ( IApplicationShell ) private readonly applicationShell : IApplicationShell ,
32
22
@inject ( IDisposableRegistry ) private readonly disposables : IDisposableRegistry
33
23
) { }
34
24
public async activate ( ) : Promise < void > {
35
- this . disposables . push ( this . commandManager . registerCommand ( Commands . TrustNotebook , this . onTrustNotebook , this ) ) ;
36
- this . disposables . push ( this . commandManager . registerCommand ( Commands . TrustedNotebook , noop ) ) ;
37
25
this . trustService . onDidSetNotebookTrust ( this . onDidTrustNotebook , this , this . disposables ) ;
38
26
}
39
27
private onDidTrustNotebook ( ) {
@@ -47,34 +35,4 @@ export class NotebookTrustHandler implements IExtensionSingleActivationService {
47
35
}
48
36
} ) ;
49
37
}
50
- @swallowExceptions ( 'Trusting notebook' )
51
- private async onTrustNotebook ( uri ?: Uri ) {
52
- uri = uri ?? this . editorProvider . activeEditor ?. file ;
53
- if ( ! uri ) {
54
- return ;
55
- }
56
- const model = await this . storageProvider . get ( uri ) ;
57
- if ( model . isTrusted ) {
58
- return ;
59
- }
60
-
61
- const prompts = [ DataScience . trustNotebook ( ) , DataScience . doNotTrustNotebook ( ) ] ;
62
- const selection = await this . applicationShell . showErrorMessage (
63
- DataScience . launchNotebookTrustPrompt ( ) ,
64
- ...prompts
65
- ) ;
66
- if ( selection !== DataScience . trustNotebook ( ) || model . isTrusted ) {
67
- return ;
68
- }
69
- // Update model trust
70
- model . update ( {
71
- source : 'user' ,
72
- kind : 'updateTrust' ,
73
- oldDirty : model . isDirty ,
74
- newDirty : model . isDirty ,
75
- isNotebookTrusted : true
76
- } ) ;
77
- const contents = model . getContent ( ) ;
78
- await this . trustService . trustNotebook ( model . file , contents ) ;
79
- }
80
38
}
0 commit comments