@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Show commits and revisions on tasks in a tabular view instead of handle lists

Summary: Depends on D20882. Ref T13440. Instead of lists of "Differential Revisions" and "Commits", show all changes related to the task in a tabular view.

Test Plan: {F6989816}

Maniphest Tasks: T13440

Differential Revision: https://secure.phabricator.com/D20883

+273 -50
+273 -50
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 179 179 ->addTabGroup($tab_group); 180 180 } 181 181 182 + $changes_view = $this->newChangesView($task, $edges); 183 + 182 184 $view = id(new PHUITwoColumnView()) 183 185 ->setHeader($header) 184 186 ->setCurtain($curtain) 185 187 ->setMainColumn( 186 188 array( 189 + $changes_view, 187 190 $tab_view, 188 191 $timeline, 189 192 $comment_view, ··· 395 398 $source)); 396 399 } 397 400 398 - $edge_types = array( 399 - ManiphestTaskHasRevisionEdgeType::EDGECONST 400 - => pht('Differential Revisions'), 401 - ); 402 - 403 - $revisions_commits = array(); 404 - 405 - $commit_phids = array_keys( 406 - $edges[ManiphestTaskHasCommitEdgeType::EDGECONST]); 407 - if ($commit_phids) { 408 - $commit_drev = DiffusionCommitHasRevisionEdgeType::EDGECONST; 409 - $drev_edges = id(new PhabricatorEdgeQuery()) 410 - ->withSourcePHIDs($commit_phids) 411 - ->withEdgeTypes(array($commit_drev)) 412 - ->execute(); 413 - 414 - foreach ($commit_phids as $phid) { 415 - $revisions_commits[$phid] = $handles->renderHandle($phid) 416 - ->setShowHovercard(true); 417 - $revision_phid = key($drev_edges[$phid][$commit_drev]); 418 - $revision_handle = $handles->getHandleIfExists($revision_phid); 419 - if ($revision_handle) { 420 - $task_drev = ManiphestTaskHasRevisionEdgeType::EDGECONST; 421 - unset($edges[$task_drev][$revision_phid]); 422 - $revisions_commits[$phid] = hsprintf( 423 - '%s / %s', 424 - $revision_handle->renderHovercardLink($revision_handle->getName()), 425 - $revisions_commits[$phid]); 426 - } 427 - } 428 - } 429 - 430 - foreach ($edge_types as $edge_type => $edge_name) { 431 - if (!$edges[$edge_type]) { 432 - continue; 433 - } 434 - 435 - $edge_handles = $viewer->loadHandles(array_keys($edges[$edge_type])); 436 - 437 - $edge_list = $edge_handles->renderList(); 438 - 439 - $view->addProperty($edge_name, $edge_list); 440 - } 441 - 442 - if ($revisions_commits) { 443 - $view->addProperty( 444 - pht('Commits'), 445 - phutil_implode_html(phutil_tag('br'), $revisions_commits)); 446 - } 447 - 448 401 $field_list->appendFieldsToPropertyList( 449 402 $task, 450 403 $viewer, ··· 592 545 } 593 546 594 547 return $handles->newSublist($phids); 548 + } 549 + 550 + private function newChangesView(ManiphestTask $task, array $edges) { 551 + $viewer = $this->getViewer(); 552 + 553 + $revision_type = ManiphestTaskHasRevisionEdgeType::EDGECONST; 554 + $commit_type = ManiphestTaskHasCommitEdgeType::EDGECONST; 555 + 556 + $revision_phids = idx($edges, $revision_type, array()); 557 + $revision_phids = array_keys($revision_phids); 558 + $revision_phids = array_fuse($revision_phids); 559 + 560 + $commit_phids = idx($edges, $commit_type, array()); 561 + $commit_phids = array_keys($commit_phids); 562 + $commit_phids = array_fuse($commit_phids); 563 + 564 + if (!$revision_phids && !$commit_phids) { 565 + return null; 566 + } 567 + 568 + if ($commit_phids) { 569 + $link_type = DiffusionCommitHasRevisionEdgeType::EDGECONST; 570 + $link_query = id(new PhabricatorEdgeQuery()) 571 + ->withSourcePHIDs($commit_phids) 572 + ->withEdgeTypes(array($link_type)); 573 + $link_query->execute(); 574 + 575 + $commits = id(new DiffusionCommitQuery()) 576 + ->setViewer($viewer) 577 + ->withPHIDs($commit_phids) 578 + ->execute(); 579 + $commits = mpull($commits, null, 'getPHID'); 580 + } else { 581 + $commits = array(); 582 + } 583 + 584 + if ($revision_phids) { 585 + $revisions = id(new DifferentialRevisionQuery()) 586 + ->setViewer($viewer) 587 + ->withPHIDs($revision_phids) 588 + ->execute(); 589 + $revisions = mpull($revisions, null, 'getPHID'); 590 + } else { 591 + $revisions = array(); 592 + } 593 + 594 + $handle_phids = array(); 595 + $any_linked = false; 596 + 597 + $tail = array(); 598 + foreach ($commit_phids as $commit_phid) { 599 + $handle_phids[] = $commit_phid; 600 + 601 + $link_phids = $link_query->getDestinationPHIDs(array($commit_phid)); 602 + foreach ($link_phids as $link_phid) { 603 + $handle_phids[] = $link_phid; 604 + unset($revision_phids[$link_phid]); 605 + $any_linked = true; 606 + } 607 + 608 + $commit = idx($commits, $commit_phid); 609 + if ($commit) { 610 + $repository_phid = $commit->getRepository()->getPHID(); 611 + $handle_phids[] = $repository_phid; 612 + } else { 613 + $repository_phid = null; 614 + } 615 + 616 + $status_view = null; 617 + if ($commit) { 618 + $status = $commit->getAuditStatusObject(); 619 + if (!$status->isNoAudit()) { 620 + $status_view = id(new PHUITagView()) 621 + ->setType(PHUITagView::TYPE_SHADE) 622 + ->setIcon($status->getIcon()) 623 + ->setColor($status->getColor()) 624 + ->setName($status->getName()); 625 + 626 + } 627 + } 628 + 629 + $object_link = null; 630 + if ($commit) { 631 + $commit_monogram = $commit->getDisplayName(); 632 + $commit_monogram = phutil_tag( 633 + 'span', 634 + array( 635 + 'class' => 'object-name', 636 + ), 637 + $commit_monogram); 638 + 639 + $commit_link = javelin_tag( 640 + 'a', 641 + array( 642 + 'href' => $commit->getURI(), 643 + 'sigil' => 'hovercard', 644 + 'meta' => array( 645 + 'hoverPHID' => $commit->getPHID(), 646 + ), 647 + ), 648 + $commit->getSummary()); 649 + 650 + $object_link = array( 651 + $commit_monogram, 652 + ' ', 653 + $commit_link, 654 + ); 655 + } 656 + 657 + $tail[] = array( 658 + 'objectPHID' => $commit_phid, 659 + 'objectLink' => $object_link, 660 + 'repositoryPHID' => $repository_phid, 661 + 'revisionPHIDs' => $link_phids, 662 + 'status' => $status_view, 663 + ); 664 + } 665 + 666 + $head = array(); 667 + foreach ($revision_phids as $revision_phid) { 668 + $handle_phids[] = $revision_phid; 669 + 670 + $revision = idx($revisions, $revision_phid); 671 + if ($revision) { 672 + $repository_phid = $revision->getRepositoryPHID(); 673 + $handle_phids[] = $repository_phid; 674 + } else { 675 + $repository_phid = null; 676 + } 677 + 678 + if ($revision) { 679 + $icon = $revision->getStatusIcon(); 680 + $color = $revision->getStatusIconColor(); 681 + $name = $revision->getStatusDisplayName(); 682 + 683 + $status_view = id(new PHUITagView()) 684 + ->setType(PHUITagView::TYPE_SHADE) 685 + ->setIcon($icon) 686 + ->setColor($color) 687 + ->setName($name); 688 + } else { 689 + $status_view = null; 690 + } 691 + 692 + $object_link = null; 693 + if ($revision) { 694 + $revision_monogram = $revision->getMonogram(); 695 + $revision_monogram = phutil_tag( 696 + 'span', 697 + array( 698 + 'class' => 'object-name', 699 + ), 700 + $revision_monogram); 701 + 702 + $revision_link = javelin_tag( 703 + 'a', 704 + array( 705 + 'href' => $revision->getURI(), 706 + 'sigil' => 'hovercard', 707 + 'meta' => array( 708 + 'hoverPHID' => $revision->getPHID(), 709 + ), 710 + ), 711 + $revision->getTitle()); 712 + 713 + $object_link = array( 714 + $revision_monogram, 715 + ' ', 716 + $revision_link, 717 + ); 718 + } 719 + 720 + $head[] = array( 721 + 'objectPHID' => $revision_phid, 722 + 'objectLink' => $object_link, 723 + 'repositoryPHID' => $repository_phid, 724 + 'revisionPHIDs' => array(), 725 + 'status' => $status_view, 726 + ); 727 + } 728 + 729 + $objects = array_merge($head, $tail); 730 + $handles = $viewer->loadHandles($handle_phids); 731 + 732 + $rows = array(); 733 + foreach ($objects as $object) { 734 + $object_phid = $object['objectPHID']; 735 + $handle = $handles[$object_phid]; 736 + 737 + $object_link = $object['objectLink']; 738 + if ($object_link === null) { 739 + $object_link = $handle->renderLink(); 740 + } 741 + 742 + $object_icon = id(new PHUIIconView()) 743 + ->setIcon($handle->getIcon()); 744 + 745 + $repository_link = null; 746 + $repository_phid = $object['repositoryPHID']; 747 + if ($repository_phid) { 748 + $repository_link = $handles[$repository_phid]->renderLink(); 749 + } 750 + 751 + $status_view = $object['status']; 752 + 753 + $revision_tags = array(); 754 + foreach ($object['revisionPHIDs'] as $link_phid) { 755 + $revision_handle = $handles[$link_phid]; 756 + 757 + $revision_name = $revision_handle->getName(); 758 + $revision_tags[] = $revision_handle 759 + ->renderHovercardLink($revision_name); 760 + } 761 + $revision_tags = phutil_implode_html( 762 + phutil_tag('br'), 763 + $revision_tags); 764 + 765 + $rows[] = array( 766 + $object_icon, 767 + $status_view, 768 + $repository_link, 769 + $revision_tags, 770 + $object_link, 771 + ); 772 + } 773 + 774 + $changes_table = id(new AphrontTableView($rows)) 775 + ->setNoDataString(pht('This task has no related commits or revisions.')) 776 + ->setHeaders( 777 + array( 778 + null, 779 + null, 780 + pht('Repository'), 781 + null, 782 + pht('Revision/Commit'), 783 + )) 784 + ->setColumnClasses( 785 + array( 786 + 'center', 787 + null, 788 + null, 789 + null, 790 + 'wide pri object-link', 791 + )) 792 + ->setColumnVisibility( 793 + array( 794 + true, 795 + true, 796 + true, 797 + $any_linked, 798 + true, 799 + )) 800 + ->setDeviceVisibility( 801 + array( 802 + false, 803 + true, 804 + false, 805 + false, 806 + true, 807 + )); 808 + 809 + $changes_header = id(new PHUIHeaderView()) 810 + ->setHeader(pht('Revisions and Commits')); 811 + 812 + $changes_view = id(new PHUIObjectBoxView()) 813 + ->setHeader($changes_header) 814 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 815 + ->setTable($changes_table); 816 + 817 + return $changes_view; 595 818 } 596 819 597 820