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
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: false
}
}
});
Expand Down
119 changes: 94 additions & 25 deletions src/vs/workbench/contrib/issue/browser/issueQuickAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { PickerQuickAccessProvider, IPickerQuickAccessItem, FastAndSlowPicks, Picks } from 'vs/platform/quickinput/browser/pickerQuickAccess';
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';

export class IssueQuickAccess extends PickerQuickAccessProvider<IPickerQuickAccessItem> {

Expand All @@ -18,55 +23,119 @@ export class IssueQuickAccess extends PickerQuickAccessProvider<IPickerQuickAcce
constructor(
@IMenuService private readonly menuService: IMenuService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@ICommandService private readonly commandService: ICommandService
@ICommandService private readonly commandService: ICommandService,
@IExtensionService private readonly extensionService: IExtensionService,
@IConfigurationService private readonly configurationService: IConfigurationService
) {
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

const issuePicks: Array<IPickerQuickAccessItem | IQuickPickSeparator> = [];
// creates menu from contributed
const menu = this.menuService.createMenu(MenuId.IssueReporter, this.contextKeyService);

// 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]);

// render menu and dispose
const actions = menu.getActions({ renderShortTitle: true }).flatMap(entry => entry[1]);
actions.forEach(action => {
const pick = this._createPick(action, filter);
if (pick) {
issuePicks.push(pick);
// Get contributed extensions.
actions.forEach(action => {
if ('source' in action.item && action.item.source) {
extensionIdList.push(action.item?.source?.id);
}
});

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

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

if (issuePicks.length > 0) {
issuePicks.push({ type: 'separator' });
}
// create picks from contributed menu
actions.forEach(action => {
const pick = this._createPick(filter, action);
if (pick) {
issuePicks.push(pick);
}
});

const createTerminalLabel = localize("workbench.action.openIssueReporter", "Open Issue Reporter");
issuePicks.push({
label: `$(plus) ${createTerminalLabel}`,
ariaLabel: createTerminalLabel,
accept: () => this.commandService.executeCommand('workbench.action.openIssueReporter')
});
return issuePicks;
if (issuePicks.length > 0) {
issuePicks.push({ type: 'separator' });
}

// add regular open issue reporter button
const createTerminalLabel = localize("workbench.action.openIssueReporter", "Open Issue Reporter");
issuePicks.push({
label: `$(plus) ${createTerminalLabel}`,
ariaLabel: createTerminalLabel,
accept: () => this.commandService.executeCommand('workbench.action.openIssueReporter')
});
return issuePicks;
}
return null;
}

private _createPick(action: MenuItemAction | SubmenuItemAction, filter: string): IPickerQuickAccessItem | undefined {
if (action.item && 'source' in action.item && action.item.source?.title) {
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 {
label,
highlights: { label: highlights },
buttons: [{
iconClass: ThemeIcon.asClassName(Codicon.arrowRight),
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.arrowRight),
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;
}

}