|
1 |
| -import { Button, ButtonGroup, Icon, IconButton, Stack, Text as ChakraText, Tooltip } from '@chakra-ui/react'; |
| 1 | +import { Button, ButtonGroup, Icon, IconButton, SimpleGrid, Text as ChakraText, Tooltip } from '@chakra-ui/react'; |
2 | 2 | import React from 'react';
|
3 | 3 | import { FaCheck, FaFlag, FaQuestion, FaRobot, FaTimes, FaTrash, FaUser, FaWrench } from 'react-icons/fa';
|
4 | 4 | import { useAppDispatch, useAppSelector } from '../../app/hooks';
|
@@ -101,7 +101,7 @@ export const AnnotationView: React.FC<AnnotationViewProps> = function ({ target
|
101 | 101 | }
|
102 | 102 |
|
103 | 103 | return (
|
104 |
| - <Stack maxW="fit-content"> |
| 104 | + <SimpleGrid spacing={2} columns={3} templateColumns="max-content max-content max-content"> |
105 | 105 | {boundaryAnnotation && (
|
106 | 106 | <AnnotationTag
|
107 | 107 | type="boundary"
|
@@ -247,7 +247,7 @@ export const AnnotationView: React.FC<AnnotationViewProps> = function ({ target
|
247 | 247 | reportable
|
248 | 248 | />
|
249 | 249 | )}
|
250 |
| - </Stack> |
| 250 | + </SimpleGrid> |
251 | 251 | );
|
252 | 252 | };
|
253 | 253 |
|
@@ -371,109 +371,115 @@ const AnnotationTag: React.FC<AnnotationTagProps> = function ({
|
371 | 371 |
|
372 | 372 | // Render
|
373 | 373 | return (
|
374 |
| - <ButtonGroup size="sm" variant="outline" isAttached> |
375 |
| - <Tooltip label={`${authorText}Click to delete.`}> |
376 |
| - <IconButton |
377 |
| - icon={<FaTrash />} |
378 |
| - aria-label="Delete annotation" |
379 |
| - colorScheme="red" |
380 |
| - disabled={!isValidUsername || isReviewed} |
381 |
| - onClick={onDelete} |
382 |
| - /> |
383 |
| - </Tooltip> |
384 |
| - <Tooltip label={`${authorText}Click to change.`}> |
385 |
| - <Button |
386 |
| - leftIcon={<FaWrench />} |
387 |
| - rightIcon={rightIcon} |
388 |
| - flexGrow={1} |
389 |
| - borderLeft="none" |
390 |
| - justifyContent="flex-start" |
391 |
| - disabled={!onEdit || !isValidUsername || isReviewed} |
392 |
| - onClick={onEdit} |
393 |
| - > |
394 |
| - @{type} |
395 |
| - {name && ( |
396 |
| - <ChakraText as="span" fontWeight="normal" justifySelf="flex-end"> |
397 |
| - : {name} {annotation.isRemoved} |
398 |
| - </ChakraText> |
399 |
| - )} |
400 |
| - </Button> |
401 |
| - </Tooltip> |
402 |
| - {(reviewResult === ReviewResult.Correct || (isReviewed && !reviewResult)) && ( |
403 |
| - <Tooltip label={`Marked as correct by ${reviewer}. Click to undo.`}> |
404 |
| - <Button |
405 |
| - size="sm" |
406 |
| - variant="solid" |
407 |
| - colorScheme="green" |
408 |
| - rightIcon={<Icon as={FaCheck} />} |
409 |
| - disabled={!isValidUsername} |
410 |
| - onClick={() => onReview(ReviewResult.Correct)} |
411 |
| - > |
412 |
| - Correct |
413 |
| - </Button> |
414 |
| - </Tooltip> |
415 |
| - )} |
416 |
| - {reviewResult === ReviewResult.Unsure && ( |
417 |
| - <Tooltip label={`Marked as unsure by ${reviewer}. Click to undo.`}> |
418 |
| - <Button |
419 |
| - size="sm" |
420 |
| - variant="solid" |
421 |
| - colorScheme="yellow" |
422 |
| - rightIcon={<Icon as={FaQuestion} />} |
423 |
| - disabled={!isValidUsername} |
424 |
| - onClick={() => onReview(ReviewResult.Unsure)} |
425 |
| - > |
426 |
| - Unsure |
427 |
| - </Button> |
| 374 | + <> |
| 375 | + <ButtonGroup size="sm" variant="outline" isAttached> |
| 376 | + <Tooltip label={`${authorText}Click to delete.`}> |
| 377 | + <IconButton |
| 378 | + icon={<FaTrash />} |
| 379 | + aria-label="Delete annotation" |
| 380 | + colorScheme="red" |
| 381 | + disabled={!isValidUsername || isReviewed} |
| 382 | + onClick={onDelete} |
| 383 | + /> |
428 | 384 | </Tooltip>
|
429 |
| - )} |
430 |
| - {reviewResult === ReviewResult.Wrong && ( |
431 |
| - <Tooltip label={`Marked as wrong by ${reviewer}. Click to undo.`}> |
| 385 | + <Tooltip label={`${authorText}Click to change.`}> |
432 | 386 | <Button
|
433 |
| - size="sm" |
434 |
| - variant="solid" |
435 |
| - colorScheme="red" |
436 |
| - rightIcon={<Icon as={FaTimes} />} |
437 |
| - disabled={!isValidUsername} |
438 |
| - onClick={() => onReview(ReviewResult.Wrong)} |
| 387 | + leftIcon={<FaWrench />} |
| 388 | + rightIcon={rightIcon} |
| 389 | + flexGrow={1} |
| 390 | + borderLeft="none" |
| 391 | + justifyContent="flex-start" |
| 392 | + disabled={!onEdit || !isValidUsername || isReviewed} |
| 393 | + onClick={onEdit} |
439 | 394 | >
|
440 |
| - Wrong |
| 395 | + @{type} |
| 396 | + {name && ( |
| 397 | + <ChakraText as="span" fontWeight="normal" justifySelf="flex-end"> |
| 398 | + : {name} {annotation.isRemoved} |
| 399 | + </ChakraText> |
| 400 | + )} |
441 | 401 | </Button>
|
442 | 402 | </Tooltip>
|
443 |
| - )} |
444 |
| - {!isReviewed && ( |
445 |
| - <> |
446 |
| - <Tooltip label={`${authorText}Click to mark as correct.`}> |
447 |
| - <Button size="sm" variant="outline" disabled={!isValidUsername} onClick={onMarkAsCorrect}> |
448 |
| - Mark as Correct |
| 403 | + </ButtonGroup> |
| 404 | + <ButtonGroup size="sm" variant="outline" isAttached> |
| 405 | + {(reviewResult === ReviewResult.Correct || (isReviewed && !reviewResult)) && ( |
| 406 | + <Tooltip label={`Marked as correct by ${reviewer}. Click to undo.`}> |
| 407 | + <Button |
| 408 | + size="sm" |
| 409 | + variant="solid" |
| 410 | + colorScheme="green" |
| 411 | + rightIcon={<Icon as={FaCheck} />} |
| 412 | + disabled={!isValidUsername} |
| 413 | + onClick={() => onReview(ReviewResult.Correct)} |
| 414 | + > |
| 415 | + Correct |
449 | 416 | </Button>
|
450 | 417 | </Tooltip>
|
451 |
| - <Tooltip label={`${authorText}Click to mark as unsure.`}> |
452 |
| - <Button size="sm" variant="outline" disabled={!isValidUsername} onClick={onMarkAsUnsure}> |
453 |
| - Mark as Unsure |
| 418 | + )} |
| 419 | + {reviewResult === ReviewResult.Unsure && ( |
| 420 | + <Tooltip label={`Marked as unsure by ${reviewer}. Click to undo.`}> |
| 421 | + <Button |
| 422 | + size="sm" |
| 423 | + variant="solid" |
| 424 | + colorScheme="yellow" |
| 425 | + rightIcon={<Icon as={FaQuestion} />} |
| 426 | + disabled={!isValidUsername} |
| 427 | + onClick={() => onReview(ReviewResult.Unsure)} |
| 428 | + > |
| 429 | + Unsure |
454 | 430 | </Button>
|
455 | 431 | </Tooltip>
|
456 |
| - <Tooltip label={`${authorText}Click to mark as wrong.`}> |
457 |
| - <Button size="sm" variant="outline" disabled={!isValidUsername} onClick={onMarkAsWrong}> |
458 |
| - Mark as Wrong |
| 432 | + )} |
| 433 | + {reviewResult === ReviewResult.Wrong && ( |
| 434 | + <Tooltip label={`Marked as wrong by ${reviewer}. Click to undo.`}> |
| 435 | + <Button |
| 436 | + size="sm" |
| 437 | + variant="solid" |
| 438 | + colorScheme="red" |
| 439 | + rightIcon={<Icon as={FaTimes} />} |
| 440 | + disabled={!isValidUsername} |
| 441 | + onClick={() => onReview(ReviewResult.Wrong)} |
| 442 | + > |
| 443 | + Wrong |
459 | 444 | </Button>
|
460 | 445 | </Tooltip>
|
461 |
| - </> |
462 |
| - )} |
| 446 | + )} |
| 447 | + {!isReviewed && ( |
| 448 | + <> |
| 449 | + <Tooltip label={`${authorText}Click to mark as correct.`}> |
| 450 | + <Button size="sm" variant="outline" disabled={!isValidUsername} onClick={onMarkAsCorrect}> |
| 451 | + Mark as Correct |
| 452 | + </Button> |
| 453 | + </Tooltip> |
| 454 | + <Tooltip label={`${authorText}Click to mark as unsure.`}> |
| 455 | + <Button size="sm" variant="outline" disabled={!isValidUsername} onClick={onMarkAsUnsure}> |
| 456 | + Mark as Unsure |
| 457 | + </Button> |
| 458 | + </Tooltip> |
| 459 | + <Tooltip label={`${authorText}Click to mark as wrong.`}> |
| 460 | + <Button size="sm" variant="outline" disabled={!isValidUsername} onClick={onMarkAsWrong}> |
| 461 | + Mark as Wrong |
| 462 | + </Button> |
| 463 | + </Tooltip> |
| 464 | + </> |
| 465 | + )} |
| 466 | + </ButtonGroup> |
463 | 467 | {isReportable && (
|
464 | 468 | <Tooltip label="Report a wrong autogenerated annotation.">
|
465 | 469 | <IconButton
|
466 | 470 | icon={<FaFlag />}
|
467 | 471 | aria-label="Report Wrong Annotation"
|
468 | 472 | colorScheme="orange"
|
| 473 | + size="sm" |
| 474 | + variant="outline" |
469 | 475 | disabled={reviewResult === ReviewResult.Correct || !isValidUsername}
|
470 | 476 | onClick={() => {
|
471 | 477 | window.open(wrongAnnotationURL(type, annotation), '_blank');
|
472 | 478 | }}
|
473 | 479 | />
|
474 | 480 | </Tooltip>
|
475 | 481 | )}
|
476 |
| - </ButtonGroup> |
| 482 | + </> |
477 | 483 | );
|
478 | 484 | };
|
479 | 485 |
|
|
0 commit comments