|
1 | 1 | import { Form, Link, usePage } from '@inertiajs/react'; |
2 | 2 | import { ChartBar, Clock3 } from 'lucide-react'; |
3 | | -import type { KeyboardEvent } from 'react'; |
| 3 | +import type { DragEvent, KeyboardEvent } from 'react'; |
4 | 4 | import { useEffect, useRef, useState } from 'react'; |
5 | 5 | import CommitController from '@/actions/App/Http/Controllers/CommitController'; |
6 | 6 | import ScheduledCommitController from '@/actions/App/Http/Controllers/ScheduledCommitController'; |
@@ -205,12 +205,20 @@ function CommitComposerBody({ |
205 | 205 | maxLength: isIssue ? maxBodyLength : maxRawBodyLength, |
206 | 206 | }); |
207 | 207 |
|
| 208 | + const cancelFileDrop = (event: DragEvent<HTMLElement>) => { |
| 209 | + if (event.dataTransfer.types.includes('Files')) { |
| 210 | + event.preventDefault(); |
| 211 | + } |
| 212 | + }; |
| 213 | + |
208 | 214 | return ( |
209 | 215 | <div |
210 | 216 | className={cn('relative flex', { 'min-h-0': isInDialog })} |
211 | | - {...(poll === null ? attachments.dropzone : {})} |
| 217 | + {...(poll === null && !isIssue |
| 218 | + ? attachments.dropzone |
| 219 | + : { onDragOver: cancelFileDrop, onDrop: cancelFileDrop })} |
212 | 220 | > |
213 | | - {attachments.isDraggingFiles && ( |
| 221 | + {!isIssue && attachments.isDraggingFiles && ( |
214 | 222 | <ImageDropOverlay className="inset-2" /> |
215 | 223 | )} |
216 | 224 | <GraphRail |
@@ -284,7 +292,9 @@ function CommitComposerBody({ |
284 | 292 | value={body} |
285 | 293 | onValueChange={issue.change} |
286 | 294 | onPaste={ |
287 | | - poll === null ? attachments.onPaste : undefined |
| 295 | + poll === null && !isIssue |
| 296 | + ? attachments.onPaste |
| 297 | + : undefined |
288 | 298 | } |
289 | 299 | onKeyDown={(event) => |
290 | 300 | preview.handleShortcut(event) || |
@@ -364,18 +374,22 @@ function CommitComposerBody({ |
364 | 374 | /> |
365 | 375 | <InputError message={error} /> |
366 | 376 |
|
367 | | - {!preview.isPreviewing && ( |
| 377 | + {!isIssue && !preview.isPreviewing && ( |
368 | 378 | <ImagePickerPreviews |
369 | 379 | images={attachments.images} |
370 | 380 | descriptions={attachments.descriptions} |
371 | 381 | onDescribe={attachments.describe} |
372 | 382 | onRemove={attachments.remove} |
373 | 383 | /> |
374 | 384 | )} |
375 | | - <InputError |
376 | | - message={attachments.error ?? imageErrorFrom(errors)} |
377 | | - className="mt-1" |
378 | | - /> |
| 385 | + {!isIssue && ( |
| 386 | + <InputError |
| 387 | + message={ |
| 388 | + attachments.error ?? imageErrorFrom(errors) |
| 389 | + } |
| 390 | + className="mt-1" |
| 391 | + /> |
| 392 | + )} |
379 | 393 |
|
380 | 394 | {poll && ( |
381 | 395 | <div className="mt-2 grid"> |
@@ -645,15 +659,21 @@ export function CommitComposer({ |
645 | 659 | poll === null && |
646 | 660 | !isScheduling, |
647 | 661 | initialKind: initialIssue, |
| 662 | + onStart: () => { |
| 663 | + attachments.clear(); |
| 664 | + }, |
648 | 665 | onCreated: () => { |
649 | 666 | drop(); |
| 667 | + attachments.clear(); |
650 | 668 | focusBody(id); |
651 | 669 | }, |
652 | 670 | }); |
653 | 671 |
|
654 | 672 | const isCommittable = |
655 | 673 | !attachments.reading && |
656 | | - (hasImages || characterCount(body.trim()) >= minBodyLength) && |
| 674 | + (issue.command !== null |
| 675 | + ? characterCount(body.trim()) >= minBodyLength |
| 676 | + : hasImages || characterCount(body.trim()) >= minBodyLength) && |
657 | 677 | (issue.command !== null |
658 | 678 | ? characterCount(body) |
659 | 679 | : bodyCharacterCount(body)) <= maxBodyLength && |
|
0 commit comments