Skip to content

Commit 03ded1c

Browse files
authored
Reduce visual complexity of trust prompt (#12839) (#12847)
1 parent 8bab9c2 commit 03ded1c

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

package.nls.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
"DataScience.openExportFileNo": "No",
3333
"DataScience.failedExportMessage": "Export failed.",
3434
"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.",
35-
"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)",
35+
"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)",
3636
"DataScience.launchNotebookTrustPrompt.yes": "Trust",
3737
"DataScience.launchNotebookTrustPrompt.no": "Do not trust",
38+
"DataScience.launchNotebookTrustPrompt.trustAllNotebooks": "Trust all notebooks",
3839
"python.command.python.viewLanguageServerOutput.title": "Show Language Server Output",
3940
"python.command.python.selectAndRunTestMethod.title": "Run Test Method ...",
4041
"python.command.python.selectAndDebugTestMethod.title": "Debug Test Method ...",

src/client/common/utils/localize.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,10 +1024,14 @@ export namespace DataScience {
10241024
);
10251025
export const launchNotebookTrustPrompt = localize(
10261026
'DataScience.launchNotebookTrustPrompt',
1027-
'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)'
1027+
'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)'
10281028
);
10291029
export const trustNotebook = localize('DataScience.launchNotebookTrustPrompt.yes', 'Trust');
10301030
export const doNotTrustNotebook = localize('DataScience.launchNotebookTrustPrompt.no', 'Do not trust');
1031+
export const trustAllNotebooks = localize(
1032+
'DataScience.launchNotebookTrustPrompt.trustAllNotebooks',
1033+
'Trust all notebooks'
1034+
);
10311035
export const previewNotebookOnlySupportedInVSCInsiders = localize(
10321036
'DataScience.previewNotebookOnlySupportedInVSCInsiders',
10331037
'The Preview Notebook Editor is supported only in the Insiders version of Visual Studio Code.'

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { IFileSystem } from '../../common/platform/types';
99
import { IExtensionContext } from '../../common/types';
1010
import { IDigestStorage } from '../types';
1111

12-
// NB: still need to implement automatic culling of least recently used entries
1312
@injectable()
1413
export class DigestStorage implements IDigestStorage {
1514
public readonly key: Promise<string>;

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as path from 'path';
66
import {
77
CancellationToken,
88
CancellationTokenSource,
9+
commands,
910
Event,
1011
EventEmitter,
1112
Memento,
@@ -611,7 +612,11 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
611612
}
612613

613614
private async launchNotebookTrustPrompt() {
614-
const prompts = [localize.DataScience.trustNotebook(), localize.DataScience.doNotTrustNotebook()];
615+
const prompts = [
616+
localize.DataScience.trustNotebook(),
617+
localize.DataScience.doNotTrustNotebook(),
618+
localize.DataScience.trustAllNotebooks()
619+
];
615620
const selection = await this.applicationShell.showErrorMessage(
616621
localize.DataScience.launchNotebookTrustPrompt(),
617622
...prompts
@@ -636,6 +641,9 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
636641
} catch (err) {
637642
traceError(err);
638643
}
644+
} else if (selection === localize.DataScience.trustAllNotebooks()) {
645+
// Take the user to the settings UI where they can manually turn on the alwaysTrustNotebooks setting
646+
commands.executeCommand('workbench.action.openSettings', 'python.dataScience.alwaysTrustNotebooks');
639647
}
640648
}
641649

0 commit comments

Comments
 (0)