Skip to content
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

show contributed issues in quick access #206303

Merged
merged 12 commits into from
Mar 7, 2024
1 change: 1 addition & 0 deletions src/vs/code/electron-sandbox/issue/issueReporterModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface IssueReporterData {
extensionsDisabled?: boolean;
fileOnExtension?: boolean;
fileOnMarketplace?: boolean;
fileOnProduct?: boolean;
selectedExtension?: IssueReporterExtensionData;
actualSearchResults?: ISettingSearchResult[];
query?: string;
Expand Down
10 changes: 9 additions & 1 deletion src/vs/code/electron-sandbox/issue/issueReporterService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ export class IssueReporter extends Disposable {
selectedExtension: targetExtension
});

const fileOnMarketplace = configuration.data.issueSource === IssueSource.Marketplace;
const fileOnProduct = configuration.data.issueSource === IssueSource.VSCode;
this.issueReporterModel.update({ fileOnMarketplace, fileOnProduct });

//TODO: Handle case where extension is not activated
const issueReporterElement = this.getElementById('issue-reporter');
if (issueReporterElement) {
Expand Down Expand Up @@ -743,13 +747,17 @@ export class IssueReporter extends Disposable {

private setSourceOptions(): void {
const sourceSelect = this.getElementById('issue-source')! as HTMLSelectElement;
const { issueType, fileOnExtension, selectedExtension } = this.issueReporterModel.getData();
const { issueType, fileOnExtension, selectedExtension, fileOnMarketplace, fileOnProduct } = this.issueReporterModel.getData();
let selected = sourceSelect.selectedIndex;
if (selected === -1) {
if (fileOnExtension !== undefined) {
selected = fileOnExtension ? 2 : 1;
} else if (selectedExtension?.isBuiltin) {
selected = 1;
} else if (fileOnMarketplace) {
selected = 3;
} else if (fileOnProduct) {
selected = 1;
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/vs/platform/issue/common/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export const enum IssueType {
FeatureRequest
}

export enum IssueSource {
VSCode = 'vscode',
Extension = 'extension',
Marketplace = 'marketplace'
}

export interface IssueReporterStyles extends WindowStyles {
textLinkColor?: string;
textLinkActiveForeground?: string;
Expand Down Expand Up @@ -65,6 +71,7 @@ export interface IssueReporterData extends WindowData {
styles: IssueReporterStyles;
enabledExtensions: IssueReporterExtensionData[];
issueType?: IssueType;
issueSource?: IssueSource;
extensionId?: string;
experiments?: string;
restrictedMode: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
type: 'boolean',
description: localize('extensionsDeferredStartupFinishedActivation', "When enabled, extensions which declare the `onStartupFinished` activation event will be activated after a timeout."),
default: false
},
'extensions.experimental.quickAcessExtensions': {
justschen marked this conversation as resolved.
Show resolved Hide resolved
type: 'boolean',
description: localize('extensionsInQuickAccess', "When enabled, extensions can be searched for via Quick Access and report issues from there."),
default: true
}
}
});
Expand Down
156 changes: 156 additions & 0 deletions src/vs/workbench/contrib/issue/browser/issueQuickAccess.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { PickerQuickAccessProvider, IPickerQuickAccessItem, FastAndSlowPicks, Picks, TriggerAction } from 'vs/platform/quickinput/browser/pickerQuickAccess';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IMenuService, MenuId, MenuItemAction, SubmenuItemAction } from 'vs/platform/actions/common/actions';
import { matchesFuzzy } from 'vs/base/common/filters';
import { IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput';
import { localize } from 'vs/nls';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IRelaxedExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { ThemeIcon } from 'vs/base/common/themables';
import { Codicon } from 'vs/base/common/codicons';
import { IssueSource } from 'vs/platform/issue/common/issue';
import { IProductService } from 'vs/platform/product/common/productService';

export class IssueQuickAccess extends PickerQuickAccessProvider<IPickerQuickAccessItem> {

static PREFIX = 'issue ';

constructor(
@IMenuService private readonly menuService: IMenuService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@ICommandService private readonly commandService: ICommandService,
@IExtensionService private readonly extensionService: IExtensionService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IProductService private readonly productService: IProductService
) {
super(IssueQuickAccess.PREFIX, { canAcceptInBackground: true });
}

protected override _getPicks(filter: string): Picks<IPickerQuickAccessItem> | FastAndSlowPicks<IPickerQuickAccessItem> | Promise<Picks<IPickerQuickAccessItem> | FastAndSlowPicks<IPickerQuickAccessItem>> | null {
if (this.configurationService.getValue<string>('extensions.experimental.quickAcessExtensions')) {
justschen marked this conversation as resolved.
Show resolved Hide resolved
const issuePicks: Array<IPickerQuickAccessItem | IQuickPickSeparator> = [];
const extensionIdList: Array<string> = [];
justschen marked this conversation as resolved.
Show resolved Hide resolved

// add regular open issue reporter button
const createTerminalLabel1 = this.productService.quality === 'stable' ? localize("workbench.action.openIssueReporter", "Visual Studio Code") : localize("workbench.action.openIssueReporterInsiders", "Visual Studio Code: Insiders");
justschen marked this conversation as resolved.
Show resolved Hide resolved
issuePicks.push({
label: `$(plus) ${createTerminalLabel1}`,
justschen marked this conversation as resolved.
Show resolved Hide resolved
ariaLabel: createTerminalLabel1,
accept: () => this.commandService.executeCommand('workbench.action.openIssueReporter', { issueSource: IssueSource.VSCode })
});

if (issuePicks.length > 0) {
issuePicks.push({ type: 'separator' });
}

const createTerminalLabel2 = localize("workbench.action.openIssueReporter2", "Extension Marketplace");
issuePicks.push({
label: `$(plus) ${createTerminalLabel2}`,
ariaLabel: createTerminalLabel2,
accept: () => this.commandService.executeCommand('workbench.action.openIssueReporter', { issueSource: IssueSource.Marketplace })
});



if (issuePicks.length > 0) {
justschen marked this conversation as resolved.
Show resolved Hide resolved
issuePicks.push({ type: 'separator', label: localize('extensions', "Extensions: Custom Reporting") });
}
// creates menu from contributed
const menu = this.menuService.createMenu(MenuId.IssueReporter, this.contextKeyService);

// render menu and dispose
const actions = menu.getActions({ renderShortTitle: true }).flatMap(entry => entry[1]);


// create picks from contributed menu
actions.forEach(action => {
if ('source' in action.item && action.item.source) {
extensionIdList.push(action.item?.source?.id);
}

const pick = this._createPick(filter, action);
if (pick) {
issuePicks.push(pick);
}
});

if (issuePicks.length > 0) {
issuePicks.push({ type: 'separator', label: localize('otherExtensions', "Other Extensions") });
}

// create picks from extensions
this.extensionService.extensions.forEach(extension => {
if (!extension.isBuiltin) {
justschen marked this conversation as resolved.
Show resolved Hide resolved
const pick = this._createPick(filter, undefined, extension);
const id = extension.identifier.value;
if (pick) {
if (extensionIdList.includes(id)) {
return;
}
else {
issuePicks.push(pick);
}
}
extensionIdList.push(id);
}
});

return issuePicks;
}
return null;
}

private _createPick(filter: string, action?: MenuItemAction | SubmenuItemAction | undefined, extension?: IRelaxedExtensionDescription): IPickerQuickAccessItem | undefined {
if (action && 'source' in action.item && action.item.source) {
const label = action.item.source?.title;
const highlights = matchesFuzzy(filter, label, true);
if (highlights) {
return {
Comment on lines +99 to +104
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking. I feel like this function could be 2 different functions for actions or extensions... or you if setting a couple variables instead and then return a common object:

const buttons = [{
	iconClass: ThemeIcon.asClassName(Codicon.info),
	tooltip: localize('contributedIssuePage', "Open Extension Page")
}];

let label: string;
let trigger: THE_TRIGGER_TYPE;
let accept: THE_ACCEPT_TYPE;
if (action ....) {
    label = action.item.source?.title;
    trigger = () => {
        this.commandService.executeCommand('extension.open', action.item.source.id);
        return TriggerAction.CLOSE_PICKER;
    };
    accept = () => action.run();
} else if (extension) {
    label = extension.displayName ?? extension.name;
    trigger = () => {
        this.commandService.executeCommand('extension.open', extension.identifier.value);
 	return TriggerAction.CLOSE_PICKER;
    };
    accept = () => this.commandService.executeCommand('workbench.action.openIssueReporter', extension.identifier.value);
} else {
    // could this ever happen?
    return undefined;
}

return {
    label,
    highlights: { label: matchesFuzzy(filter, label, true) },
    buttons,
    trigger,
    accept
};

label,
highlights: { label: highlights },
buttons: [{
iconClass: ThemeIcon.asClassName(Codicon.info),
tooltip: localize('contributedIssuePage', "Open Extension Page")
}],
trigger: () => {
if ('source' in action.item && action.item.source) {
this.commandService.executeCommand('extension.open', action.item.source.id);
}
return TriggerAction.CLOSE_PICKER;
},
accept: (keyMod, event) => {
action.run();
}
};
}
} else if (extension && extension.displayName && extension.identifier.value) {
justschen marked this conversation as resolved.
Show resolved Hide resolved
const highlights = matchesFuzzy(filter, extension.displayName, true);
if (highlights) {
return {
label: extension.displayName,
highlights: { label: highlights },
buttons: [{
iconClass: ThemeIcon.asClassName(Codicon.info),
tooltip: localize('contributedIssuePage', "Open Extension Page")
}],
trigger: () => {
this.commandService.executeCommand('extension.open', extension.identifier.value);
return TriggerAction.CLOSE_PICKER;
},
accept: (keyMod, event) => {
this.commandService.executeCommand('workbench.action.openIssueReporter', extension.identifier.value);
}

};
}
}
return undefined;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { INativeHostService } from 'vs/platform/native/common/native';
import { IProgressService, ProgressLocation } from 'vs/platform/progress/common/progress';
import { IIssueMainService, IssueType } from 'vs/platform/issue/common/issue';
import { IQuickAccessRegistry, Extensions as QuickAccessExtensions } from 'vs/platform/quickinput/common/quickAccess';
import { IssueQuickAccess } from 'vs/workbench/contrib/issue/browser/issueQuickAccess';

//#region Issue Contribution

Expand Down Expand Up @@ -134,4 +136,16 @@ CommandsRegistry.registerCommand('_issues.getSystemStatus', (accessor) => {
return accessor.get(IIssueMainService).getSystemStatus();
});

// Register quick access for contributed issues
Registry.as<IQuickAccessRegistry>(QuickAccessExtensions.Quickaccess).registerQuickAccessProvider({
justschen marked this conversation as resolved.
Show resolved Hide resolved
ctor: IssueQuickAccess,
prefix: IssueQuickAccess.PREFIX,
contextKey: 'inReportIssuePicker',
placeholder: localize('tasksQuickAccessPlaceholder', "Type the name of an extension to report on."),
helpEntries: [{
description: localize('startDebuggingHelp', "Open Issue Reporter"),
commandId: 'workbench.action.openIssueReporter',
commandCenterOrder: 50
}]
});
//#endregion