fix(web): review summary only says optional when it is (#18451)
This commit is contained in:
1 parent
ce6f8ce36e
commit
7897a695e3
2 files changed
+42
-35
No files matched your search
@@ -154,7 +154,7 @@ export function PullRequestReviewSheet({
|
||||
/>
|
||||
}
|
||||
>
|
||||
{reviewing && offered.length ? (
|
||||
{reviewing && offered.length > 1 ? (
|
||||
<SegmentedControl
|
||||
options={offered.map((option) => ({ value: option.value, label: option.title }))}
|
||||
selected={verdict?.value ?? "comment"}
|
||||
|
||||
@@ -116,10 +116,17 @@ export function PullRequestReviewForm({
|
||||
};
|
||||
|
||||
// Forgejo requires a summary when requesting changes, even with inline comments.
|
||||
const canSubmit = (verdict: PullRequestReviewVerdict) =>
|
||||
const canSubmit = (verdict: PullRequestReviewVerdict, summary: string) =>
|
||||
verdict === "request-changes" && requestChangesSummaryRequired
|
||||
? body.trim().length > 0
|
||||
: verdict === "approve" || body.trim().length > 0 || comments.length > 0;
|
||||
? summary.trim().length > 0
|
||||
: verdict === "approve" || summary.trim().length > 0 || comments.length > 0;
|
||||
// The placeholder asks for exactly what the submit button is waiting on.
|
||||
const placeholder =
|
||||
selectedVerdict === undefined || canSubmit(selectedVerdict.value, "")
|
||||
? "Summarize your review (optional)"
|
||||
: selectedVerdict.value === "request-changes" && requestChangesSummaryRequired
|
||||
? "Summarize your review (required to request changes)"
|
||||
: "Summarize your review or add line comments";
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -127,42 +134,42 @@ export function PullRequestReviewForm({
|
||||
ref={textareaRef}
|
||||
rows={3}
|
||||
value={body}
|
||||
placeholder={
|
||||
requestChangesSummaryRequired && verdicts.includes("request-changes")
|
||||
? "Summarize your review (required to request changes)"
|
||||
: "Summarize your review (optional)"
|
||||
}
|
||||
placeholder={placeholder}
|
||||
aria-label="Review summary"
|
||||
onChange={(event) => setSummary(reviewKey, event.target.value)}
|
||||
/>
|
||||
<div className="mt-2 flex justify-between gap-2">
|
||||
<Select
|
||||
value={selectedVerdict?.value ?? null}
|
||||
disabled={pending}
|
||||
onValueChange={(value) => {
|
||||
if (value !== null) setRequestedVerdict(value);
|
||||
}}
|
||||
>
|
||||
<SelectTrigger size="xs" className="w-auto min-w-0" aria-label="Review verdict">
|
||||
<span className="flex items-center gap-1.5">
|
||||
{selectedVerdict?.icon}
|
||||
{selectedVerdict?.label}
|
||||
</span>
|
||||
</SelectTrigger>
|
||||
<SelectPopup side="top" alignItemWithTrigger={false}>
|
||||
{offered.map((verdict) => (
|
||||
<SelectItem key={verdict.value} value={verdict.value}>
|
||||
<span className="flex items-center gap-1.5">
|
||||
{verdict.icon}
|
||||
{verdict.label}
|
||||
</span>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectPopup>
|
||||
</Select>
|
||||
<div className="mt-2 flex justify-end gap-2">
|
||||
{offered.length > 1 ? (
|
||||
<Select
|
||||
value={selectedVerdict?.value ?? null}
|
||||
disabled={pending}
|
||||
onValueChange={(value) => {
|
||||
if (value !== null) setRequestedVerdict(value);
|
||||
}}
|
||||
>
|
||||
<SelectTrigger size="xs" className="mr-auto w-auto min-w-0" aria-label="Review verdict">
|
||||
<span className="flex items-center gap-1.5">
|
||||
{selectedVerdict?.icon}
|
||||
{selectedVerdict?.label}
|
||||
</span>
|
||||
</SelectTrigger>
|
||||
<SelectPopup side="top" alignItemWithTrigger={false}>
|
||||
{offered.map((verdict) => (
|
||||
<SelectItem key={verdict.value} value={verdict.value}>
|
||||
<span className="flex items-center gap-1.5">
|
||||
{verdict.icon}
|
||||
{verdict.label}
|
||||
</span>
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectPopup>
|
||||
</Select>
|
||||
) : null}
|
||||
<Button
|
||||
size="xs"
|
||||
disabled={pending || selectedVerdict === undefined || !canSubmit(selectedVerdict.value)}
|
||||
disabled={
|
||||
pending || selectedVerdict === undefined || !canSubmit(selectedVerdict.value, body)
|
||||
}
|
||||
onClick={() => {
|
||||
if (selectedVerdict !== undefined) void submit(selectedVerdict);
|
||||
}}
|
||||
|
||||
Reference in new issue
Block a user