Skip to content

Commit aba1d20

Browse files
authored
Add trust feature for VS Code Notebooks (#12818)
1 parent 9e4e356 commit aba1d20

35 files changed

+829
-246
lines changed

build/ci/vscode-python-pr-validation.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ stages:
5656
'DataScience':
5757
TestsToRun: 'testDataScience'
5858
NeedsPythonTestReqs: true
59+
NeedsPythonFunctionalReqs: true
5960
'Smoke':
6061
TestsToRun: 'testSmoke'
6162
NeedsPythonTestReqs: true

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,25 @@
694694
},
695695
"enablement": "python.datascience.notebookeditor.canrestartNotebookkernel"
696696
},
697+
{
698+
"command": "python.datascience.notebookeditor.trust",
699+
"title": "%DataScience.trustNotebookCommandTitle%",
700+
"category": "Python",
701+
"icon": {
702+
"light": "resources/light/un-trusted.svg",
703+
"dark": "resources/dark/un-trusted.svg"
704+
},
705+
"enablement": "notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
706+
},
707+
{
708+
"command": "python.datascience.notebookeditor.trusted",
709+
"title": "%DataScience.notebookIsTrusted%",
710+
"category": "Python",
711+
"icon": {
712+
"light": "resources/light/trusted.svg",
713+
"dark": "resources/dark/trusted.svg"
714+
}
715+
},
697716
{
698717
"command": "python.datascience.notebookeditor.runallcells",
699718
"title": "%python.command.python.datascience.notebookeditor.runallcells.title%",
@@ -860,6 +879,18 @@
860879
"group": "navigation",
861880
"when": "notebookEditorFocused"
862881
},
882+
{
883+
"command": "python.datascience.notebookeditor.trust",
884+
"title": "%DataScience.trustNotebookCommandTitle%",
885+
"group": "navigation@1",
886+
"when": "notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
887+
},
888+
{
889+
"command": "python.datascience.notebookeditor.trusted",
890+
"title": "%DataScience.notebookIsTrusted%",
891+
"group": "navigation@1",
892+
"when": "notebookEditorFocused && python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
893+
},
863894
{
864895
"command": "python.datascience.export",
865896
"title": "%DataScience.notebookExportAs%",
@@ -1138,6 +1169,18 @@
11381169
"category": "Python",
11391170
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
11401171
},
1172+
{
1173+
"command": "python.datascience.notebookeditor.trust",
1174+
"title": "%DataScience.trustNotebookCommandTitle%",
1175+
"category": "Python",
1176+
"when": "python.datascience.featureenabled && notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
1177+
},
1178+
{
1179+
"command": "python.datascience.notebookeditor.trusted",
1180+
"title": "%DataScience.notebookIsTrusted%",
1181+
"category": "Python",
1182+
"when": "config.noExists"
1183+
},
11411184
{
11421185
"command": "python.datascience.notebookeditor.runallcells",
11431186
"title": "%python.command.python.datascience.notebookeditor.runallcells.title%",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@
370370
"DataScience.fetchingDataViewer": "Fetching data ...",
371371
"DataScience.noRowsInDataViewer": "No rows match current filter",
372372
"DataScience.jupyterServer": "Jupyter Server",
373+
"DataScience.trustNotebookCommandTitle": "Trust notebook",
373374
"DataScience.notebookIsTrusted": "Trusted",
374375
"DataScience.notebookIsNotTrusted": "Not Trusted",
375376
"DataScience.noKernel": "No Kernel",

resources/dark/trusted.svg

Lines changed: 4 additions & 0 deletions
Loading

resources/dark/un-trusted.svg

Lines changed: 4 additions & 0 deletions
Loading

resources/light/run-file.svg

Lines changed: 3 additions & 2 deletions
Loading

resources/light/trusted.svg

Lines changed: 4 additions & 0 deletions
Loading

resources/light/un-trusted.svg

Lines changed: 4 additions & 0 deletions
Loading

src/client/common/application/commands.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,6 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
183183
[DSCommands.OpenNotebookNonCustomEditor]: [Uri];
184184
[DSCommands.GatherQuality]: [string];
185185
[DSCommands.EnableLoadingWidgetsFrom3rdPartySource]: [undefined | never];
186+
[DSCommands.TrustNotebook]: [undefined | never | Uri];
187+
[DSCommands.TrustedNotebook]: [undefined | never];
186188
}

src/client/datascience/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ export namespace Commands {
9090
export const SaveAsNotebookNonCustomEditor = 'python.datascience.notebookeditor.saveAs';
9191
export const OpenNotebookNonCustomEditor = 'python.datascience.notebookeditor.open';
9292
export const GatherQuality = 'python.datascience.gatherquality';
93+
export const TrustNotebook = 'python.datascience.notebookeditor.trust';
94+
export const TrustedNotebook = 'python.datascience.notebookeditor.trusted';
9395
export const EnableLoadingWidgetsFrom3rdPartySource =
9496
'python.datascience.enableLoadingWidgetScriptsFromThirdPartySource';
9597
}

0 commit comments

Comments
 (0)