Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@
"deprecationMessage": "Use the setting 'githubPullRequests.defaultCreateOption' instead.",
"description": "%githubPullRequests.createDraft%"
},
"githubPullRequests.showPullRequestCancelConfirmation": {
"type": "boolean",
"default": true,
"description": "%githubPullRequests.showPullRequestCancelConfirmation%"
},
"githubPullRequests.logLevel": {
"type": "string",
"enum": [
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"githubPullRequests.defaultCreateOption.createDraft": "The pull request will be created as a draft.",
"githubPullRequests.defaultCreateOption.createAutoMerge": "The pull request will be created with auto-merge enabled. The merge method selected will be the default for the repo or the value of `githubPullRequests.defaultMergeMethod` if set.",
"githubPullRequests.createDraft": "Whether the \"Draft\" checkbox will be checked by default when creating a pull request.",
"githubPullRequests.showPullRequestCancelConfirmation": "Show a confirmation dialog when canceling pull request creation if the description has been edited.",
"githubPullRequests.logLevel.description": "Logging for GitHub Pull Request extension. The log is emitted to the output channel named GitHub Pull Request.",
"githubPullRequests.logLevel.markdownDeprecationMessage": {
"message": "Log level is now controlled by the [Developer: Set Log Level...](command:workbench.action.setLogLevel) command. You can set the log level for the current session and also the default log level from there.",
Expand Down
1 change: 1 addition & 0 deletions src/common/settingKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const QUERIES = 'queries';
export const PULL_REQUEST_LABELS = 'labelCreated';
export const FOCUSED_MODE = 'focusedMode';
export const CREATE_DRAFT = 'createDraft';
export const SHOW_PULL_REQUEST_CANCEL_CONFIRMATION = 'showPullRequestCancelConfirmation';
export const QUICK_DIFF = 'quickDiff';
export const SET_AUTO_MERGE = 'setAutoMerge';
export const SHOW_PULL_REQUEST_NUMBER_IN_TREE = 'showPullRequestNumberInTree';
Expand Down
22 changes: 20 additions & 2 deletions src/github/createPRViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import {
PR_SETTINGS_NAMESPACE,
PULL_REQUEST_DESCRIPTION,
PULL_REQUEST_LABELS,
PUSH_BRANCH
PUSH_BRANCH,
SHOW_PULL_REQUEST_CANCEL_CONFIRMATION
} from '../common/settingKeys';
import { ITelemetry } from '../common/telemetry';
import { asPromise, compareIgnoreCase, formatError, promiseWithTimeout } from '../common/utils';
Expand Down Expand Up @@ -561,10 +562,27 @@ export abstract class BaseCreatePullRequestViewProvider<T extends BasePullReques
}

private async cancel(message: IRequestMessage<CreatePullRequestNew>) {
if (message.args.body && message.args.body.length > 0
&& vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<boolean>(SHOW_PULL_REQUEST_CANCEL_CONFIRMATION, true)) {
const discard = vscode.l10n.t('Discard');
const dontAskAgain = vscode.l10n.t('Don\'t Ask Again');
const result = await vscode.window.showWarningMessage(
vscode.l10n.t('Are you sure you want to cancel creating this pull request?'),
{ modal: true, detail: vscode.l10n.t('Your pull request title and description will be lost.') },
discard,
dontAskAgain
);
if (result !== discard && result !== dontAskAgain) {
return this._replyMessage(message, { cancelled: false });
}
if (result === dontAskAgain) {
await vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).update(SHOW_PULL_REQUEST_CANCEL_CONFIRMATION, false, vscode.ConfigurationTarget.Global);
}
}
this._onDone.fire(undefined);
// Re-fetch the automerge info so that it's updated for next time.
await this.getMergeConfiguration(message.args.owner, message.args.repo, true);
return this._replyMessage(message, undefined);
return this._replyMessage(message, { cancelled: true });
}

private async openDescriptionSettings(): Promise<void> {
Expand Down
12 changes: 9 additions & 3 deletions webviews/common/createContextNew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,16 @@ export class CreatePRContextNew {
}
};

public cancelCreate = (): Promise<void> => {
public cancelCreate = async (): Promise<void> => {
const args = this.copyParams();
vscode.setState(defaultCreateParams);
return this.postMessage({ command: 'pr.cancelCreate', args });
const result = await this.postMessage({ command: 'pr.cancelCreate', args }) as { cancelled?: boolean } | undefined;
// Only clear persisted state if the extension explicitly confirmed the
// cancellation. Otherwise (e.g. the user declined the confirmation
// dialog, or the message did not get a response) preserve the user's
// in-progress title/description.
if (result?.cancelled === true) {
vscode.setState(defaultCreateParams);
}
};

public updateState = (params: Partial<CreateParamsNew>, reset: boolean = false): void => {
Expand Down