Skip to content

Disable Notebook icons when Notebook is not trusted #12894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/3 Code Health/12893.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable Notebook icons when Notebook is not trusted.
38 changes: 9 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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%",
Expand Down
1 change: 0 additions & 1 deletion src/client/common/application/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
1 change: 0 additions & 1 deletion src/client/datascience/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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) {
Expand Down