Skip to content

Commit

Permalink
Add 'Marketplace' issue type to issue reporter, closes #118473
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel Macfarlane committed Mar 8, 2021
1 parent a8739f9 commit b20839c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.55.0",
"distro": "2173d6da3776d9f0e894d49e854ba495636e1b5d",
"distro": "0357427beb5cd348177cd1ed381cd740082966c4",
"author": {
"name": "Microsoft Corporation"
},
Expand Down
57 changes: 41 additions & 16 deletions src/vs/code/electron-sandbox/issue/issueReporterMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface IssueReporterConfiguration extends IWindowConfiguration {
commit: string | undefined;
date: string | undefined;
reportIssueUrl: string | undefined;
reportMarketplaceIssueUrl: string | undefined;
}
}

Expand Down Expand Up @@ -83,6 +84,7 @@ export class IssueReporter extends Disposable {
super();

this.initServices(configuration);
console.log(configuration);

const targetExtension = configuration.data.extensionId ? configuration.data.enabledExtensions.find(extension => extension.id === configuration.data.extensionId) : undefined;
this.issueReporterModel = new IssueReporterModel({
Expand Down Expand Up @@ -353,7 +355,8 @@ export class IssueReporter extends Disposable {
this.addEventListener('issue-title', 'input', (e: Event) => {
const title = (<HTMLInputElement>e.target).value;
const lengthValidationMessage = this.getElementById('issue-title-length-validation-error');
if (title && this.getIssueUrlWithTitle(title).length > MAX_URL_LENGTH) {
const issueUrl = this.getIssueUrl();
if (title && this.getIssueUrlWithTitle(title, issueUrl).length > MAX_URL_LENGTH) {
show(lengthValidationMessage);
} else {
hide(lengthValidationMessage);
Expand Down Expand Up @@ -468,6 +471,10 @@ export class IssueReporter extends Disposable {
return true;
}

if (issueType === IssueType.Marketplace) {
return true;
}

return false;
}

Expand Down Expand Up @@ -633,11 +640,18 @@ export class IssueReporter extends Disposable {

const typeSelect = this.getElementById('issue-type')! as HTMLSelectElement;
const { issueType } = this.issueReporterModel.getData();
reset(typeSelect,
makeOption(IssueType.Bug, localize('bugReporter', "Bug Report")),
makeOption(IssueType.FeatureRequest, localize('featureRequest', "Feature Request")),
makeOption(IssueType.PerformanceIssue, localize('performanceIssue', "Performance Issue"))
);
this.configuration.product.reportMarketplaceIssueUrl
? reset(typeSelect,
makeOption(IssueType.Bug, localize('bugReporter', "Bug Report")),
makeOption(IssueType.FeatureRequest, localize('featureRequest', "Feature Request")),
makeOption(IssueType.PerformanceIssue, localize('performanceIssue', "Performance Issue")),
makeOption(IssueType.Marketplace, localize('marketplaceIssue', "Extensions Marketplace Issue"))
)
: reset(typeSelect,
makeOption(IssueType.Bug, localize('bugReporter', "Bug Report")),
makeOption(IssueType.FeatureRequest, localize('featureRequest', "Feature Request")),
makeOption(IssueType.PerformanceIssue, localize('performanceIssue', "Performance Issue")),
);

typeSelect.value = issueType.toString();

Expand Down Expand Up @@ -751,6 +765,9 @@ export class IssueReporter extends Disposable {
if (fileOnExtension) {
show(extensionSelector);
}
} else if (issueType === IssueType.Marketplace) {
reset(descriptionTitle, localize('description', "Description"), $('span.required-input', undefined, '*'));
reset(descriptionSubtitle, localize('marketplaceDescription', "Please describe the feature you would like added to the marketplace, or steps to reliably reproduce the problem if you are reporting a bug. We support GitHub-flavored Markdown. You will be able to edit your issue and add screenshots when we preview it on GitHub."));
}
}

Expand All @@ -770,10 +787,14 @@ export class IssueReporter extends Disposable {

private validateInputs(): boolean {
let isValid = true;
['issue-title', 'description', 'issue-source'].forEach(elementId => {
['issue-title', 'description'].forEach(elementId => {
isValid = this.validateInput(elementId) && isValid;
});

if (this.issueReporterModel.getData().issueType !== IssueType.Marketplace) {
isValid = this.validateInput('issue-source') && isValid;
}

if (this.issueReporterModel.fileOnExtension()) {
isValid = this.validateInput('extension-selector') && isValid;
}
Expand Down Expand Up @@ -845,13 +866,13 @@ export class IssueReporter extends Disposable {
const issueTitle = (<HTMLInputElement>this.getElementById('issue-title')).value;
const issueBody = this.issueReporterModel.serialize();

const issueUrl = this.issueReporterModel.fileOnExtension() ? this.getExtensionGitHubUrl() : this.configuration.product.reportIssueUrl!;
const issueUrl = this.getIssueUrl();
const gitHubDetails = this.parseGitHubUrl(issueUrl);
if (this.configuration.data.githubAccessToken && gitHubDetails) {
return this.submitToGitHub(issueTitle, issueBody, gitHubDetails);
}

const baseUrl = this.getIssueUrlWithTitle((<HTMLInputElement>this.getElementById('issue-title')).value);
const baseUrl = this.getIssueUrlWithTitle((<HTMLInputElement>this.getElementById('issue-title')).value, issueUrl);
let url = baseUrl + `&body=${encodeURIComponent(issueBody)}`;

if (url.length > MAX_URL_LENGTH) {
Expand Down Expand Up @@ -881,6 +902,14 @@ export class IssueReporter extends Disposable {
});
}

private getIssueUrl(): string {
return this.issueReporterModel.fileOnExtension()
? this.getExtensionGitHubUrl()
: this.issueReporterModel.getData().issueType === IssueType.Marketplace
? this.configuration.product.reportMarketplaceIssueUrl!
: this.configuration.product.reportIssueUrl!;
}

private parseGitHubUrl(url: string): undefined | { repositoryName: string, owner: string } {
// Assumes a GitHub url to a particular repo, https://github.com/repositoryName/owner.
// Repository name and owner cannot contain '/'
Expand Down Expand Up @@ -909,16 +938,12 @@ export class IssueReporter extends Disposable {
return repositoryUrl;
}

private getIssueUrlWithTitle(issueTitle: string): string {
let repositoryUrl = this.configuration.product.reportIssueUrl;
private getIssueUrlWithTitle(issueTitle: string, repositoryUrl: string): string {
if (this.issueReporterModel.fileOnExtension()) {
const extensionGitHubUrl = this.getExtensionGitHubUrl();
if (extensionGitHubUrl) {
repositoryUrl = extensionGitHubUrl + '/issues/new';
}
repositoryUrl = repositoryUrl + '/issues/new';
}

const queryStringPrefix = this.configuration.product.reportIssueUrl && this.configuration.product.reportIssueUrl.indexOf('?') === -1 ? '?' : '&';
const queryStringPrefix = repositoryUrl.indexOf('?') === -1 ? '?' : '&';
return `${repositoryUrl}${queryStringPrefix}title=${encodeURIComponent(issueTitle)}`;
}

Expand Down
3 changes: 2 additions & 1 deletion src/vs/platform/issue/common/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export interface WindowData {
export const enum IssueType {
Bug,
PerformanceIssue,
FeatureRequest
FeatureRequest,
Marketplace
}

export interface IssueReporterStyles extends WindowStyles {
Expand Down
3 changes: 2 additions & 1 deletion src/vs/platform/issue/electron-main/issueMainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ export class IssueMainService implements ICommonIssueService {
version: !!product.darwinUniversalAssetId ? `${product.version} (Universal)` : product.version,
commit: product.commit,
date: product.date,
reportIssueUrl: product.reportIssueUrl
reportIssueUrl: product.reportIssueUrl,
reportMarketplaceIssueUrl: product.reportMarketplaceIssueUrl
}
};

Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/product/common/productService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export interface IProductConfiguration {
readonly twitterUrl?: string;
readonly requestFeatureUrl?: string;
readonly reportIssueUrl?: string;
readonly reportMarketplaceIssueUrl?: string;
readonly licenseUrl?: string;
readonly privacyStatementUrl?: string;
readonly telemetryOptOutUrl?: string;
Expand Down

0 comments on commit b20839c

Please sign in to comment.