Skip to content

Commit

Permalink
Add submit update message field for multi-selected commits
Browse files Browse the repository at this point in the history
Summary:
Like previous diff, but add it when you have multiple commits selected.

This is slightly hairy, because we try to save your edited messages, and yet the keying is by hash. So if you change your selection at all (or a succession happens), you'd lose your message.

I really don't think it should be a big deal—these update messages are supposed to be brief and simply explain what you changed, unlike the summary/ test plan.

Reviewed By: quark-zju

Differential Revision: D49339371

fbshipit-source-id: 47113d097e5e672e85f61365aadd23b8cd7272ae
  • Loading branch information
evangrayk authored and facebook-github-bot committed Sep 16, 2023
1 parent 8a7fce2 commit d228b2d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions addons/isl/src/CommitInfoView/CommitInfoView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export function MultiCommitInfo({selectedCommits}: {selectedCommits: Array<Commi
const provider = useRecoilValue(codeReviewProvider);
const diffSummaries = useRecoilValue(allDiffSummaries);
const shouldSubmitAsDraft = useRecoilValue(submitAsDraft);
const commitsWithDiffs = selectedCommits.filter(commit => commit.diffId != null);
const [updateMessage, setUpdateMessage] = useRecoilState(
// Combine hashes to key the typed update message.
// This is kind of volatile, since if you change your selection at all, the message will be cleared.
diffUpdateMessagesState(selectedCommits.map(commit => commit.hash).join(',')),
);
const submittable =
(diffSummaries.value != null
? provider?.getSubmittableDiffs(selectedCommits, diffSummaries.value)
Expand All @@ -129,6 +135,9 @@ export function MultiCommitInfo({selectedCommits}: {selectedCommits: Array<Commi
))}
</div>
<div className="commit-info-actions-bar">
{commitsWithDiffs.length === 0 ? null : (
<SubmitUpdateMessageInput commits={selectedCommits} />
)}
<div className="commit-info-actions-bar-left">
<SubmitAsDraftCheckbox commitsToBeSubmit={selectedCommits} />
</div>
Expand All @@ -139,8 +148,11 @@ export function MultiCommitInfo({selectedCommits}: {selectedCommits: Array<Commi
contextKey={'submit-selected'}
appearance="secondary"
runOperation={() => {
// clear update message on submit
setUpdateMessage('');
return unwrap(provider).submitOperation(selectedCommits, {
draft: shouldSubmitAsDraft,
updateMessage: updateMessage || undefined,
});
}}>
<T>Submit Selected Commits</T>
Expand Down
1 change: 1 addition & 0 deletions addons/isl/src/SubmitUpdateMessageInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function SubmitUpdateMessageInput({commits}: {commits: Array<CommitInfo>}
}
return (
<VSCodeTextField
style={{width: '100%'}}
value={message}
onChange={e => setMessage((e.target as HTMLInputElement).value)}>
<T>Update Message</T>
Expand Down

0 comments on commit d228b2d

Please sign in to comment.