Skip to content

Commit f339ffd

Browse files
test
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
1 parent d1a922e commit f339ffd

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

code/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2405,15 +2405,13 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
24052405
return new MarkdownString().appendText(nls.localize('disallowed', "This extension is disallowed to be installed."));
24062406
}
24072407

2408-
// Check if extension is allowed first (before checking platform compatibility)
24092408
if (extension.gallery) {
2409+
// Check if extension is allowed first (before checking platform compatibility or signing)
24102410
const allowedResult = this.allowedExtensionsService.isAllowed({ id: extension.gallery.identifier.id, publisherDisplayName: extension.gallery.publisherDisplayName });
24112411
if (allowedResult !== true) {
24122412
return new MarkdownString(nls.localize('extension not allowed to install', "This extension cannot be installed because it is not in the allowed list."));
24132413
}
2414-
}
24152414

2416-
if (extension.gallery) {
24172415
if (!extension.gallery.isSigned && shouldRequireRepositorySignatureFor(extension.private, await this.extensionGalleryManifestService.getExtensionGalleryManifest())) {
24182416
return new MarkdownString().appendText(nls.localize('not signed', "This extension is not signed."));
24192417
}
@@ -2433,7 +2431,32 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
24332431
return true;
24342432
}
24352433

2436-
return localResult ?? remoteResult ?? webResult ?? new MarkdownString().appendText(nls.localize('cannot be installed', "Cannot install the '{0}' extension because it is not available in this setup.", extension.displayName ?? extension.identifier.id));
2434+
// If any of the canInstall checks returned a message about not being allowed, prioritize that
2435+
// Otherwise return platform compatibility or other messages
2436+
const allResults: IMarkdownString[] = [];
2437+
const isMarkdownString = (r: true | IMarkdownString | undefined): r is IMarkdownString => {
2438+
return r !== undefined && r !== true;
2439+
};
2440+
if (isMarkdownString(localResult)) {
2441+
allResults.push(localResult);
2442+
}
2443+
if (isMarkdownString(remoteResult)) {
2444+
allResults.push(remoteResult);
2445+
}
2446+
if (isMarkdownString(webResult)) {
2447+
allResults.push(webResult);
2448+
}
2449+
2450+
const notAllowedResult = allResults.find(r => r.value.includes('not in the allowed list') || r.value.includes('not allowed'));
2451+
if (notAllowedResult) {
2452+
return new MarkdownString(nls.localize('extension not allowed to install', "This extension cannot be installed because it is not in the allowed list."));
2453+
}
2454+
2455+
// Return the first error message, or a generic message if none
2456+
if (allResults.length > 0) {
2457+
return allResults[0];
2458+
}
2459+
return new MarkdownString().appendText(nls.localize('cannot be installed', "Cannot install the '{0}' extension because it is not available in this setup.", extension.displayName ?? extension.identifier.id));
24372460
}
24382461

24392462
if (extension.resourceExtension && await this.extensionManagementService.canInstall(extension.resourceExtension) === true) {

0 commit comments

Comments
 (0)