diff --git a/news/3 Code Health/12893.md b/news/3 Code Health/12893.md new file mode 100644 index 000000000000..5a4d62330a56 --- /dev/null +++ b/news/3 Code Health/12893.md @@ -0,0 +1 @@ +Disable Notebook icons when Notebook is not trusted. diff --git a/package.json b/package.json index 18dcb1653f16..2b00476bd40e 100644 --- a/package.json +++ b/package.json @@ -369,7 +369,8 @@ "icon": { "light": "resources/light/export_to_python.svg", "dark": "resources/dark/export_to_python.svg" - } + }, + "enablement": "notebookViewType == jupyter-notebook && python.datascience.isnotebooktrusted" }, { "command": "python.datascience.exportAsPythonScript", @@ -702,16 +703,7 @@ "light": "resources/light/un-trusted.svg", "dark": "resources/dark/un-trusted.svg" }, - "enablement": "notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled" - }, - { - "command": "python.datascience.notebookeditor.trusted", - "title": "%DataScience.notebookIsTrusted%", - "category": "Python", - "icon": { - "light": "resources/light/trusted.svg", - "dark": "resources/dark/trusted.svg" - } + "enablement": "notebookViewType == jupyter-notebook && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled" }, { "command": "python.datascience.notebookeditor.runallcells", @@ -877,25 +869,19 @@ "command": "python.datascience.notebookeditor.restartkernel", "title": "%python.command.python.datascience.restartkernel.title%", "group": "navigation", - "when": "notebookEditorFocused" + "when": "notebookViewType == jupyter-notebook" }, { "command": "python.datascience.notebookeditor.trust", "title": "%DataScience.trustNotebookCommandTitle%", "group": "navigation@1", - "when": "notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled" - }, - { - "command": "python.datascience.notebookeditor.trusted", - "title": "%DataScience.notebookIsTrusted%", - "group": "navigation@1", - "when": "notebookEditorFocused && python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled" + "when": "notebookViewType == jupyter-notebook && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled" }, { "command": "python.datascience.export", "title": "%DataScience.notebookExportAs%", "group": "navigation", - "when": "notebookEditorFocused" + "when": "notebookViewType == jupyter-notebook" } ], "explorer/context": [ @@ -940,19 +926,19 @@ "command": "python.datascience.exportAsPythonScript", "title": "%python.command.python.datascience.exportAsPythonScript.title%", "category": "Python", - "when": "python.datascience.isnativeactive && python.datascience.featureenabled" + "when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted" }, { "command": "python.datascience.exportToHTML", "title": "%python.command.python.datascience.exportToHTML.title%", "category": "Python", - "when": "python.datascience.isnativeactive && python.datascience.featureenabled" + "when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted" }, { "command": "python.datascience.exportToPDF", "title": "%python.command.python.datascience.exportToPDF.title%", "category": "Python", - "when": "python.datascience.isnativeactive && python.datascience.featureenabled" + "when": "python.datascience.isnativeactive && python.datascience.featureenabled && python.datascience.isnotebooktrusted" }, { "command": "python.switchOffInsidersChannel", @@ -1175,12 +1161,6 @@ "category": "Python", "when": "python.datascience.featureenabled && notebookEditorFocused && !python.datascience.isnotebooktrusted && python.datascience.trustfeatureenabled" }, - { - "command": "python.datascience.notebookeditor.trusted", - "title": "%DataScience.notebookIsTrusted%", - "category": "Python", - "when": "config.noExists" - }, { "command": "python.datascience.notebookeditor.runallcells", "title": "%python.command.python.datascience.notebookeditor.runallcells.title%", diff --git a/src/client/common/application/commands.ts b/src/client/common/application/commands.ts index dc310105fdb1..9e35df989c56 100644 --- a/src/client/common/application/commands.ts +++ b/src/client/common/application/commands.ts @@ -184,5 +184,4 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu [DSCommands.GatherQuality]: [string]; [DSCommands.EnableLoadingWidgetsFrom3rdPartySource]: [undefined | never]; [DSCommands.TrustNotebook]: [undefined | never | Uri]; - [DSCommands.TrustedNotebook]: [undefined | never]; } diff --git a/src/client/datascience/constants.ts b/src/client/datascience/constants.ts index 7d7b732a1e4c..5a371aa92ff5 100644 --- a/src/client/datascience/constants.ts +++ b/src/client/datascience/constants.ts @@ -91,7 +91,6 @@ export namespace Commands { export const OpenNotebookNonCustomEditor = 'python.datascience.notebookeditor.open'; export const GatherQuality = 'python.datascience.gatherquality'; export const TrustNotebook = 'python.datascience.notebookeditor.trust'; - export const TrustedNotebook = 'python.datascience.notebookeditor.trusted'; export const EnableLoadingWidgetsFrom3rdPartySource = 'python.datascience.enableLoadingWidgetScriptsFromThirdPartySource'; } diff --git a/src/client/datascience/interactive-ipynb/trustCommandHandler.ts b/src/client/datascience/interactive-ipynb/trustCommandHandler.ts index 09ee31f49e62..f7834234477f 100644 --- a/src/client/datascience/interactive-ipynb/trustCommandHandler.ts +++ b/src/client/datascience/interactive-ipynb/trustCommandHandler.ts @@ -13,7 +13,6 @@ import '../../common/extensions'; import { IDisposableRegistry, IExperimentService } from '../../common/types'; import { swallowExceptions } from '../../common/utils/decorators'; import { DataScience } from '../../common/utils/localize'; -import { noop } from '../../common/utils/misc'; import { Commands } from '../constants'; import { INotebookStorageProvider } from '../interactive-ipynb/notebookStorageProvider'; import { INotebookEditorProvider, ITrustService } from '../types'; @@ -39,7 +38,6 @@ export class TrustCommandHandler implements IExtensionSingleActivationService { const context = new ContextKey('python.datascience.trustfeatureenabled', this.commandManager); context.set(true).ignoreErrors(); this.disposables.push(this.commandManager.registerCommand(Commands.TrustNotebook, this.onTrustNotebook, this)); - this.disposables.push(this.commandManager.registerCommand(Commands.TrustedNotebook, noop)); } @swallowExceptions('Trusting notebook') private async onTrustNotebook(uri?: Uri) {