Skip to content

Commit 1a2a6dd

Browse files
committed
fix: address comments
1 parent 3ac27f3 commit 1a2a6dd

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

src/common/localize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,6 @@ export namespace EnvViewStrings {
148148
export namespace PermissionsCommon {
149149
export const allow = l10n.t('Allow');
150150
export const deny = l10n.t('Deny');
151-
export const ask = l10n.t('Ask');
152-
export const setPermissions = l10n.t('Set Permissions');
151+
export const confirmEachTime = l10n.t('Confirm each time');
152+
export const updatePermissions = l10n.t('Update permissions');
153153
}

src/features/permissions/packageManagerPermissions.ts

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,16 @@ function getPackageListAsString(packages: string[]): string {
7171

7272
async function configureFirstTimePermissions(extensionId: string, pm: PackageManagerPermissions) {
7373
const response = await showInformationMessage(
74-
l10n.t(
75-
'The extension {0} wants to install, upgrade, or uninstall packages from your Python environments',
76-
extensionId,
77-
),
74+
l10n.t('The {0} extension wants to make changes to packages in your Python environments', extensionId),
7875
{ modal: true },
7976
{
80-
title: PermissionsCommon.ask,
77+
title: PermissionsCommon.confirmEachTime,
8178
isCloseAffordance: true,
8279
},
8380
{ title: PermissionsCommon.allow },
8481
{ title: PermissionsCommon.deny },
8582
);
86-
if (response?.title === PermissionsCommon.ask) {
83+
if (response?.title === PermissionsCommon.confirmEachTime) {
8784
await pm.setPermissions(extensionId, 'Ask');
8885
traceLog('Package management permissions set to "ask" for extension: ', extensionId);
8986
return true;
@@ -114,15 +111,23 @@ export async function checkPackageManagementPermissions(
114111
} else if (currentPermission === 'Deny') {
115112
traceLog(`Package management permissions denied for extension: ${extensionId}`);
116113
setImmediate(async () => {
117-
const response = await showWarningMessage(
118-
l10n.t(
119-
'The extension `{0}` is not allowed to {1} packages into your Python environment.',
120-
extensionId,
121-
mode,
122-
),
123-
PermissionsCommon.setPermissions,
114+
let message = l10n.t(
115+
'The extension `{0}` is not permitted to install packages into your Python environment.',
116+
extensionId,
124117
);
125-
if (response === PermissionsCommon.setPermissions) {
118+
if (mode === 'uninstall') {
119+
message = l10n.t(
120+
'The extension `{0}` is not permitted to uninstall packages from your Python environment.',
121+
extensionId,
122+
);
123+
} else if (mode === 'changes') {
124+
message = l10n.t(
125+
'The extension `{0}` is not permitted to make changes to your Python environment.',
126+
extensionId,
127+
);
128+
}
129+
const response = await showWarningMessage(message, PermissionsCommon.updatePermissions);
130+
if (response === PermissionsCommon.updatePermissions) {
126131
handlePermissionsCommand(pm, extensionId);
127132
}
128133
});
@@ -166,19 +171,19 @@ export async function handlePermissionsCommand(pm: PermissionsManager<Permission
166171

167172
const response = await showInformationMessage(
168173
l10n.t(
169-
'Set permissions for the extension {0} to install, upgrade, or uninstall packages from your Python environments',
174+
'Set permissions for the {0} extension to make changes to packages in your Python environments',
170175
extensionId,
171176
),
172177
{
173178
modal: true,
174179
detail: currentPermission ? l10n.t('Current permission: {0}', currentPermission) : undefined,
175180
},
176-
PermissionsCommon.ask,
181+
PermissionsCommon.confirmEachTime,
177182
PermissionsCommon.allow,
178183
PermissionsCommon.deny,
179184
);
180185

181-
if (response === PermissionsCommon.ask) {
186+
if (response === PermissionsCommon.confirmEachTime) {
182187
await pm.setPermissions(extensionId, 'Ask');
183188
traceLog('Package management permissions set to "ask" for extension: ', extensionId);
184189
} else if (response === PermissionsCommon.allow) {

0 commit comments

Comments
 (0)