Skip to content

Commit ddbe3be

Browse files
authored
Disable Notebook icons when Notebook is not trusted (#12894)
For #12893
1 parent 5e8cef7 commit ddbe3be

File tree

5 files changed

+10
-33
lines changed

5 files changed

+10
-33
lines changed

news/3 Code Health/12893.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Disable Notebook icons when Notebook is not trusted.

package.json

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@
369369
"icon": {
370370
"light": "resources/light/export_to_python.svg",
371371
"dark": "resources/dark/export_to_python.svg"
372-
}
372+
},
373+
"enablement": "notebookViewType == jupyter-notebook && python.datascience.isnotebooktrusted"
373374
},
374375
{
375376
"command": "python.datascience.exportAsPythonScript",
@@ -702,16 +703,7 @@
702703
"light": "resources/light/un-trusted.svg",
703704
"dark": "resources/dark/un-trusted.svg"
704705
},
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-
}
706+
"enablement": "notebookViewType == jupyter-notebook && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
715707
},
716708
{
717709
"command": "python.datascience.notebookeditor.runallcells",
@@ -877,25 +869,19 @@
877869
"command": "python.datascience.notebookeditor.restartkernel",
878870
"title": "%python.command.python.datascience.restartkernel.title%",
879871
"group": "navigation",
880-
"when": "notebookEditorFocused"
872+
"when": "notebookViewType == jupyter-notebook"
881873
},
882874
{
883875
"command": "python.datascience.notebookeditor.trust",
884876
"title": "%DataScience.trustNotebookCommandTitle%",
885877
"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"
878+
"when": "notebookViewType == jupyter-notebook && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
893879
},
894880
{
895881
"command": "python.datascience.export",
896882
"title": "%DataScience.notebookExportAs%",
897883
"group": "navigation",
898-
"when": "notebookEditorFocused"
884+
"when": "notebookViewType == jupyter-notebook"
899885
}
900886
],
901887
"explorer/context": [
@@ -940,19 +926,19 @@
940926
"command": "python.datascience.exportAsPythonScript",
941927
"title": "%python.command.python.datascience.exportAsPythonScript.title%",
942928
"category": "Python",
943-
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
929+
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
944930
},
945931
{
946932
"command": "python.datascience.exportToHTML",
947933
"title": "%python.command.python.datascience.exportToHTML.title%",
948934
"category": "Python",
949-
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
935+
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
950936
},
951937
{
952938
"command": "python.datascience.exportToPDF",
953939
"title": "%python.command.python.datascience.exportToPDF.title%",
954940
"category": "Python",
955-
"when": "python.datascience.isnativeactive && python.datascience.featureenabled"
941+
"when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted"
956942
},
957943
{
958944
"command": "python.switchOffInsidersChannel",
@@ -1175,12 +1161,6 @@
11751161
"category": "Python",
11761162
"when": "python.datascience.featureenabled && notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled"
11771163
},
1178-
{
1179-
"command": "python.datascience.notebookeditor.trusted",
1180-
"title": "%DataScience.notebookIsTrusted%",
1181-
"category": "Python",
1182-
"when": "config.noExists"
1183-
},
11841164
{
11851165
"command": "python.datascience.notebookeditor.runallcells",
11861166
"title": "%python.command.python.datascience.notebookeditor.runallcells.title%",

src/client/common/application/commands.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,4 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
184184
[DSCommands.GatherQuality]: [string];
185185
[DSCommands.EnableLoadingWidgetsFrom3rdPartySource]: [undefined | never];
186186
[DSCommands.TrustNotebook]: [undefined | never | Uri];
187-
[DSCommands.TrustedNotebook]: [undefined | never];
188187
}

src/client/datascience/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export namespace Commands {
9191
export const OpenNotebookNonCustomEditor = 'python.datascience.notebookeditor.open';
9292
export const GatherQuality = 'python.datascience.gatherquality';
9393
export const TrustNotebook = 'python.datascience.notebookeditor.trust';
94-
export const TrustedNotebook = 'python.datascience.notebookeditor.trusted';
9594
export const EnableLoadingWidgetsFrom3rdPartySource =
9695
'python.datascience.enableLoadingWidgetScriptsFromThirdPartySource';
9796
}

src/client/datascience/interactive-ipynb/trustCommandHandler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import '../../common/extensions';
1313
import { IDisposableRegistry, IExperimentService } from '../../common/types';
1414
import { swallowExceptions } from '../../common/utils/decorators';
1515
import { DataScience } from '../../common/utils/localize';
16-
import { noop } from '../../common/utils/misc';
1716
import { Commands } from '../constants';
1817
import { INotebookStorageProvider } from '../interactive-ipynb/notebookStorageProvider';
1918
import { INotebookEditorProvider, ITrustService } from '../types';
@@ -39,7 +38,6 @@ export class TrustCommandHandler implements IExtensionSingleActivationService {
3938
const context = new ContextKey('python.datascience.trustfeatureenabled', this.commandManager);
4039
context.set(true).ignoreErrors();
4140
this.disposables.push(this.commandManager.registerCommand(Commands.TrustNotebook, this.onTrustNotebook, this));
42-
this.disposables.push(this.commandManager.registerCommand(Commands.TrustedNotebook, noop));
4341
}
4442
@swallowExceptions('Trusting notebook')
4543
private async onTrustNotebook(uri?: Uri) {

0 commit comments

Comments
 (0)