forked from microsoft/vscode-python-environments
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
73 lines (68 loc) · 2.71 KB
/
utils.ts
File metadata and controls
73 lines (68 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { window } from 'vscode';
import { InstallPermissionEnum, SimpleResponseEnum } from './packageManagement';
export type SettingsPackageTrust = {
[key: string]: InstallPermissionEnum.AlwaysAllow | InstallPermissionEnum.AlwaysAsk;
};
export const ALWAYS_ALLOW = 'Always allow installs';
export const ALWAYS_ASK = 'Always ask before installing';
export const INSTALL_NO_CONFIGURE = 'Install without configuring permissions';
export const YES_INSTALL = 'Yes, Install';
export const NO_INSTALL = 'Do Not Install';
export function promptForInstallPermissions(extensionName: string, packages: string): Thenable<InstallPermissionEnum> {
return new Promise((resolve) => {
window
.showInformationMessage(
'Would you like to set permissions for future package installs from the ' + extensionName + ' extension?',
{
detail: `package/s: "${packages}"`,
modal: true,
},
ALWAYS_ASK,
ALWAYS_ALLOW,
INSTALL_NO_CONFIGURE,
)
.then((selectedOption) => {
switch (selectedOption) {
case ALWAYS_ALLOW:
resolve(InstallPermissionEnum.AlwaysAllow);
break;
case ALWAYS_ASK:
resolve(InstallPermissionEnum.AlwaysAsk);
break;
case INSTALL_NO_CONFIGURE:
resolve(InstallPermissionEnum.InstallNoConfigure);
break;
default:
resolve(InstallPermissionEnum.Cancel);
break;
}
});
});
}
export function promptForAlwaysAsk(extensionName: string, packages: string): Thenable<string | undefined> {
return new Promise((resolve) => {
window
.showInformationMessage(
'Do you want to install the following package/s from the ' + extensionName + ' extension?',
{
detail: `package/s: "${packages}"`,
modal: true,
},
YES_INSTALL,
NO_INSTALL,
)
.then((selectedOption) => {
switch (selectedOption) {
case YES_INSTALL:
resolve(SimpleResponseEnum.YesInstall);
break;
case NO_INSTALL:
resolve(SimpleResponseEnum.NoInstall);
break;
default:
resolve(SimpleResponseEnum.Cancel);
break;
}
});
});
}