Skip to content

Reduce visual complexity of trust prompt #12839

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 9, 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
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@
"DataScience.openExportFileNo": "No",
"DataScience.failedExportMessage": "Export failed.",
"DataScience.exportToPDFDependencyMessage": "If you have not installed xelatex (TeX) you will need to do so before you can export to PDF, for further instructions please look [here](https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex). \r\nTo avoid installing xelatex (TeX) you might want to try exporting to HTML and using your browsers \"Print to PDF\" feature.",
"DataScience.launchNotebookTrustPrompt": "A notebook could execute harmful code when opened. Some cells & outputs have been hidden. Do you trust this notebook? (To trust all notebooks by default, click [here](command:workbench.action.openSettings?%5B%22python.dataScience.alwaysTrustNotebooks%22%5D).) [Learn more.](https://aka.ms/trusted-notebooks)",
"DataScience.launchNotebookTrustPrompt": "A notebook could execute harmful code when opened. Some outputs have been hidden. Do you trust this notebook? [Learn more.](https://aka.ms/trusted-notebooks)",
"DataScience.launchNotebookTrustPrompt.yes": "Trust",
"DataScience.launchNotebookTrustPrompt.no": "Do not trust",
"DataScience.launchNotebookTrustPrompt.trustAllNotebooks": "Trust all notebooks",
"python.command.python.viewLanguageServerOutput.title": "Show Language Server Output",
"python.command.python.selectAndRunTestMethod.title": "Run Test Method ...",
"python.command.python.selectAndDebugTestMethod.title": "Debug Test Method ...",
Expand Down
6 changes: 5 additions & 1 deletion src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1024,10 +1024,14 @@ export namespace DataScience {
);
export const launchNotebookTrustPrompt = localize(
'DataScience.launchNotebookTrustPrompt',
'A notebook could execute harmful code when opened. Some cells & outputs have been hidden. Do you trust this notebook? (To trust all notebooks by default, click [here](command:workbench.action.openSettings?%5B%22python.dataScience.alwaysTrustNotebooks%22%5D).) [Learn more.](https://aka.ms/trusted-notebooks)'
'A notebook could execute harmful code when opened. Some outputs have been hidden. Do you trust this notebook? [Learn more.](https://aka.ms/trusted-notebooks)'
);
export const trustNotebook = localize('DataScience.launchNotebookTrustPrompt.yes', 'Trust');
export const doNotTrustNotebook = localize('DataScience.launchNotebookTrustPrompt.no', 'Do not trust');
export const trustAllNotebooks = localize(
'DataScience.launchNotebookTrustPrompt.trustAllNotebooks',
'Trust all notebooks'
);
export const previewNotebookOnlySupportedInVSCInsiders = localize(
'DataScience.previewNotebookOnlySupportedInVSCInsiders',
'The Preview Notebook Editor is supported only in the Insiders version of Visual Studio Code.'
Expand Down
1 change: 0 additions & 1 deletion src/client/datascience/interactive-ipynb/digestStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { IFileSystem } from '../../common/platform/types';
import { IExtensionContext } from '../../common/types';
import { IDigestStorage } from '../types';

// NB: still need to implement automatic culling of least recently used entries
@injectable()
export class DigestStorage implements IDigestStorage {
public readonly key: Promise<string>;
Expand Down
10 changes: 9 additions & 1 deletion src/client/datascience/interactive-ipynb/nativeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as path from 'path';
import {
CancellationToken,
CancellationTokenSource,
commands,
Event,
EventEmitter,
Memento,
Expand Down Expand Up @@ -611,7 +612,11 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
}

private async launchNotebookTrustPrompt() {
const prompts = [localize.DataScience.trustNotebook(), localize.DataScience.doNotTrustNotebook()];
const prompts = [
localize.DataScience.trustNotebook(),
localize.DataScience.doNotTrustNotebook(),
localize.DataScience.trustAllNotebooks()
];
const selection = await this.applicationShell.showErrorMessage(
localize.DataScience.launchNotebookTrustPrompt(),
...prompts
Expand All @@ -636,6 +641,9 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
} catch (err) {
traceError(err);
}
} else if (selection === localize.DataScience.trustAllNotebooks()) {
// Take the user to the settings UI where they can manually turn on the alwaysTrustNotebooks setting
commands.executeCommand('workbench.action.openSettings', 'python.dataScience.alwaysTrustNotebooks');
}
}

Expand Down