@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 more detailed hints about draft revisions in the UI

Summary: Ref T2543. When revisions are in the draft state, tell the user what we're waiting for or why they aren't moving forward.

Test Plan: {F5228840}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T2543

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

+145 -47
+2
src/__phutil_library_map__.php
··· 444 444 'DifferentialDiffTransactionQuery' => 'applications/differential/query/DifferentialDiffTransactionQuery.php', 445 445 'DifferentialDiffViewController' => 'applications/differential/controller/DifferentialDiffViewController.php', 446 446 'DifferentialDoorkeeperRevisionFeedStoryPublisher' => 'applications/differential/doorkeeper/DifferentialDoorkeeperRevisionFeedStoryPublisher.php', 447 + 'DifferentialDraftField' => 'applications/differential/customfield/DifferentialDraftField.php', 447 448 'DifferentialExactUserFunctionDatasource' => 'applications/differential/typeahead/DifferentialExactUserFunctionDatasource.php', 448 449 'DifferentialFieldParseException' => 'applications/differential/exception/DifferentialFieldParseException.php', 449 450 'DifferentialFieldValidationException' => 'applications/differential/exception/DifferentialFieldValidationException.php', ··· 5451 5452 'DifferentialDiffTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 5452 5453 'DifferentialDiffViewController' => 'DifferentialController', 5453 5454 'DifferentialDoorkeeperRevisionFeedStoryPublisher' => 'DoorkeeperFeedStoryPublisher', 5455 + 'DifferentialDraftField' => 'DifferentialCoreCustomField', 5454 5456 'DifferentialExactUserFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 5455 5457 'DifferentialFieldParseException' => 'Exception', 5456 5458 'DifferentialFieldValidationException' => 'Exception',
+90
src/applications/differential/customfield/DifferentialDraftField.php
··· 1 + <?php 2 + 3 + final class DifferentialDraftField 4 + extends DifferentialCoreCustomField { 5 + 6 + public function getFieldKey() { 7 + return 'differential:draft'; 8 + } 9 + 10 + public function getFieldName() { 11 + return pht('Draft'); 12 + } 13 + 14 + public function getFieldDescription() { 15 + return pht('Show a warning about draft revisions.'); 16 + } 17 + 18 + protected function readValueFromRevision( 19 + DifferentialRevision $revision) { 20 + return null; 21 + } 22 + 23 + public function shouldAppearInPropertyView() { 24 + return true; 25 + } 26 + 27 + public function renderPropertyViewValue() { 28 + return null; 29 + } 30 + 31 + public function getWarningsForRevisionHeader(array $handles) { 32 + $viewer = $this->getViewer(); 33 + $revision = $this->getObject(); 34 + 35 + if (!$revision->isDraft()) { 36 + return array(); 37 + } 38 + 39 + $warnings = array(); 40 + 41 + $blocking_map = array( 42 + HarbormasterBuildStatus::STATUS_FAILED, 43 + HarbormasterBuildStatus::STATUS_ABORTED, 44 + HarbormasterBuildStatus::STATUS_ERROR, 45 + HarbormasterBuildStatus::STATUS_PAUSED, 46 + HarbormasterBuildStatus::STATUS_DEADLOCKED, 47 + ); 48 + $blocking_map = array_fuse($blocking_map); 49 + 50 + $builds = $revision->loadActiveBuilds($viewer); 51 + 52 + $waiting = array(); 53 + $blocking = array(); 54 + foreach ($builds as $build) { 55 + if (isset($blocking_map[$build->getBuildStatus()])) { 56 + $blocking[] = $build; 57 + } else { 58 + $waiting[] = $build; 59 + } 60 + } 61 + 62 + $blocking_list = $viewer->renderHandleList(mpull($blocking, 'getPHID')) 63 + ->setAsInline(true); 64 + $waiting_list = $viewer->renderHandleList(mpull($waiting, 'getPHID')) 65 + ->setAsInline(true); 66 + 67 + if ($blocking) { 68 + $warnings[] = pht( 69 + 'This draft revision will not be submitted for review because %s '. 70 + 'build(s) failed: %s.', 71 + phutil_count($blocking), 72 + $blocking_list); 73 + $warnings[] = pht( 74 + 'Fix build failures and update the revision.'); 75 + } else if ($waiting) { 76 + $warnings[] = pht( 77 + 'This draft revision will be sent for review once %s '. 78 + 'build(s) pass: %s.', 79 + phutil_count($waiting), 80 + $waiting_list); 81 + } else { 82 + $warnings[] = pht( 83 + 'This is a draft revision that has not yet been submitted for '. 84 + 'review.'); 85 + } 86 + 87 + return $warnings; 88 + } 89 + 90 + }
+1 -47
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 1570 1570 1571 1571 private function hasActiveBuilds($object) { 1572 1572 $viewer = $this->requireActor(); 1573 - $diff = $object->getActiveDiff(); 1574 1573 1575 - $buildables = id(new HarbormasterBuildableQuery()) 1576 - ->setViewer($viewer) 1577 - ->withContainerPHIDs(array($object->getPHID())) 1578 - ->withBuildablePHIDs(array($diff->getPHID())) 1579 - ->withManualBuildables(false) 1580 - ->execute(); 1581 - if (!$buildables) { 1582 - return false; 1583 - } 1584 - 1585 - $builds = id(new HarbormasterBuildQuery()) 1586 - ->setViewer($viewer) 1587 - ->withBuildablePHIDs(mpull($buildables, 'getPHID')) 1588 - ->withBuildStatuses( 1589 - array( 1590 - HarbormasterBuildStatus::STATUS_INACTIVE, 1591 - HarbormasterBuildStatus::STATUS_PENDING, 1592 - HarbormasterBuildStatus::STATUS_BUILDING, 1593 - HarbormasterBuildStatus::STATUS_FAILED, 1594 - HarbormasterBuildStatus::STATUS_ABORTED, 1595 - HarbormasterBuildStatus::STATUS_ERROR, 1596 - HarbormasterBuildStatus::STATUS_PAUSED, 1597 - HarbormasterBuildStatus::STATUS_DEADLOCKED, 1598 - )) 1599 - ->needBuildTargets(true) 1600 - ->execute(); 1574 + $builds = $object->loadActiveBuilds($viewer); 1601 1575 if (!$builds) { 1602 - return false; 1603 - } 1604 - 1605 - $active = array(); 1606 - foreach ($builds as $key => $build) { 1607 - foreach ($build->getBuildTargets() as $target) { 1608 - if ($target->isAutotarget()) { 1609 - // Ignore autotargets when looking for active of failed builds. If 1610 - // local tests fail and you continue anyway, you don't need to 1611 - // double-confirm them. 1612 - continue; 1613 - } 1614 - 1615 - // This build has at least one real target that's doing something. 1616 - $active[$key] = $build; 1617 - break; 1618 - } 1619 - } 1620 - 1621 - if (!$active) { 1622 1576 return false; 1623 1577 } 1624 1578
+52
src/applications/differential/storage/DifferentialRevision.php
··· 708 708 return false; 709 709 } 710 710 711 + public function loadActiveBuilds(PhabricatorUser $viewer) { 712 + $diff = $this->getActiveDiff(); 713 + 714 + $buildables = id(new HarbormasterBuildableQuery()) 715 + ->setViewer($viewer) 716 + ->withContainerPHIDs(array($this->getPHID())) 717 + ->withBuildablePHIDs(array($diff->getPHID())) 718 + ->withManualBuildables(false) 719 + ->execute(); 720 + if (!$buildables) { 721 + return array(); 722 + } 723 + 724 + $builds = id(new HarbormasterBuildQuery()) 725 + ->setViewer($viewer) 726 + ->withBuildablePHIDs(mpull($buildables, 'getPHID')) 727 + ->withBuildStatuses( 728 + array( 729 + HarbormasterBuildStatus::STATUS_INACTIVE, 730 + HarbormasterBuildStatus::STATUS_PENDING, 731 + HarbormasterBuildStatus::STATUS_BUILDING, 732 + HarbormasterBuildStatus::STATUS_FAILED, 733 + HarbormasterBuildStatus::STATUS_ABORTED, 734 + HarbormasterBuildStatus::STATUS_ERROR, 735 + HarbormasterBuildStatus::STATUS_PAUSED, 736 + HarbormasterBuildStatus::STATUS_DEADLOCKED, 737 + )) 738 + ->needBuildTargets(true) 739 + ->execute(); 740 + if (!$builds) { 741 + return array(); 742 + } 743 + 744 + $active = array(); 745 + foreach ($builds as $key => $build) { 746 + foreach ($build->getBuildTargets() as $target) { 747 + if ($target->isAutotarget()) { 748 + // Ignore autotargets when looking for active of failed builds. If 749 + // local tests fail and you continue anyway, you don't need to 750 + // double-confirm them. 751 + continue; 752 + } 753 + 754 + // This build has at least one real target that's doing something. 755 + $active[$key] = $build; 756 + break; 757 + } 758 + } 759 + 760 + return $active; 761 + } 762 + 711 763 712 764 /* -( HarbormasterBuildableInterface )------------------------------------- */ 713 765