@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.

Add a Phrequent curtain extension

Summary: Fixes T10546. Some day, decades from now, we can revisit this when we iterate on Phrequent. Just don't regress for no real reason in the meantime, since it's easy enough to keep it working in reasonable shape.

Test Plan: {F1169096}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10546

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

+89
+2
src/__phutil_library_map__.php
··· 3794 3794 'PhragmentZIPController' => 'applications/phragment/controller/PhragmentZIPController.php', 3795 3795 'PhrequentConduitAPIMethod' => 'applications/phrequent/conduit/PhrequentConduitAPIMethod.php', 3796 3796 'PhrequentController' => 'applications/phrequent/controller/PhrequentController.php', 3797 + 'PhrequentCurtainExtension' => 'applications/phrequent/engineextension/PhrequentCurtainExtension.php', 3797 3798 'PhrequentDAO' => 'applications/phrequent/storage/PhrequentDAO.php', 3798 3799 'PhrequentListController' => 'applications/phrequent/controller/PhrequentListController.php', 3799 3800 'PhrequentPopConduitAPIMethod' => 'applications/phrequent/conduit/PhrequentPopConduitAPIMethod.php', ··· 8498 8499 'PhragmentZIPController' => 'PhragmentController', 8499 8500 'PhrequentConduitAPIMethod' => 'ConduitAPIMethod', 8500 8501 'PhrequentController' => 'PhabricatorController', 8502 + 'PhrequentCurtainExtension' => 'PHUICurtainExtension', 8501 8503 'PhrequentDAO' => 'PhabricatorLiskDAO', 8502 8504 'PhrequentListController' => 'PhrequentController', 8503 8505 'PhrequentPopConduitAPIMethod' => 'PhrequentConduitAPIMethod',
+87
src/applications/phrequent/engineextension/PhrequentCurtainExtension.php
··· 1 + <?php 2 + 3 + final class PhrequentCurtainExtension 4 + extends PHUICurtainExtension { 5 + 6 + const EXTENSIONKEY = 'phrequent.time'; 7 + 8 + public function shouldEnableForObject($object) { 9 + return ($object instanceof PhrequentTrackableInterface); 10 + } 11 + 12 + public function getExtensionApplication() { 13 + return new PhabricatorPhrequentApplication(); 14 + } 15 + 16 + public function buildCurtainPanel($object) { 17 + $viewer = $this->getViewer(); 18 + 19 + $events = id(new PhrequentUserTimeQuery()) 20 + ->setViewer($viewer) 21 + ->withObjectPHIDs(array($object->getPHID())) 22 + ->needPreemptingEvents(true) 23 + ->execute(); 24 + $event_groups = mgroup($events, 'getUserPHID'); 25 + 26 + if (!$events) { 27 + return; 28 + } 29 + 30 + $handles = $viewer->loadHandles(array_keys($event_groups)); 31 + $status_view = new PHUIStatusListView(); 32 + 33 + foreach ($event_groups as $user_phid => $event_group) { 34 + $item = new PHUIStatusItemView(); 35 + $item->setTarget($handles[$user_phid]->renderLink()); 36 + 37 + $state = 'stopped'; 38 + foreach ($event_group as $event) { 39 + if ($event->getDateEnded() === null) { 40 + if ($event->isPreempted()) { 41 + $state = 'suspended'; 42 + } else { 43 + $state = 'active'; 44 + break; 45 + } 46 + } 47 + } 48 + 49 + switch ($state) { 50 + case 'active': 51 + $item->setIcon( 52 + PHUIStatusItemView::ICON_CLOCK, 53 + 'green', 54 + pht('Working Now')); 55 + break; 56 + case 'suspended': 57 + $item->setIcon( 58 + PHUIStatusItemView::ICON_CLOCK, 59 + 'yellow', 60 + pht('Interrupted')); 61 + break; 62 + case 'stopped': 63 + $item->setIcon( 64 + PHUIStatusItemView::ICON_CLOCK, 65 + 'bluegrey', 66 + pht('Not Working Now')); 67 + break; 68 + } 69 + 70 + $block = new PhrequentTimeBlock($event_group); 71 + $item->setNote( 72 + phutil_format_relative_time( 73 + $block->getTimeSpentOnObject( 74 + $object->getPHID(), 75 + time()))); 76 + 77 + $status_view->addItem($item); 78 + } 79 + 80 + 81 + return $this->newPanel() 82 + ->setHeaderText(pht('Time Spent')) 83 + ->setOrder(40000) 84 + ->appendChild($status_view); 85 + } 86 + 87 + }