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

Give Nuance items some basic descriptive text

Summary: Ref T10537. Ref T10538.

Test Plan: {F1164858}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10537, T10538

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

+90 -45
+11 -24
src/applications/nuance/controller/NuanceItemViewController.php
··· 15 15 } 16 16 17 17 $title = pht('Item %d', $item->getID()); 18 + $name = $item->getDisplayName(); 18 19 19 20 $crumbs = $this->buildApplicationCrumbs(); 20 21 $crumbs->addTextCrumb( ··· 23 24 $crumbs->addTextCrumb($title); 24 25 $crumbs->setBorder(true); 25 26 26 - $properties = $this->buildPropertyView($item); 27 27 $curtain = $this->buildCurtain($item); 28 + $content = $this->buildContent($item); 28 29 29 30 $header = id(new PHUIHeaderView()) 30 - ->setHeader($title); 31 + ->setHeader($name); 31 32 32 33 $view = id(new PHUITwoColumnView()) 33 34 ->setHeader($header) 34 35 ->setCurtain($curtain) 35 - ->addPropertySection(pht('DETAILS'), $properties); 36 + ->setMainColumn($content); 36 37 37 38 return $this->newPage() 38 39 ->setTitle($title) ··· 40 41 ->appendChild($view); 41 42 } 42 43 43 - private function buildPropertyView(NuanceItem $item) { 44 - $viewer = $this->getViewer(); 45 - 46 - $properties = id(new PHUIPropertyListView()) 47 - ->setUser($viewer); 48 - 49 - $properties->addProperty( 50 - pht('Date Created'), 51 - phabricator_datetime($item->getDateCreated(), $viewer)); 52 - 53 - $source = $item->getSource(); 54 - $definition = $source->getDefinition(); 55 - 56 - $definition->renderItemViewProperties( 57 - $viewer, 58 - $item, 59 - $properties); 60 - 61 - return $properties; 62 - } 63 - 64 44 private function buildCurtain(NuanceItem $item) { 65 45 $viewer = $this->getViewer(); 66 46 $id = $item->getID(); ··· 81 61 return $curtain; 82 62 } 83 63 64 + private function buildContent(NuanceItem $item) { 65 + $viewer = $this->getViewer(); 66 + $impl = $item->getImplementation(); 67 + 68 + $impl->setViewer($viewer); 69 + return $impl->buildItemView($item); 70 + } 84 71 85 72 }
+3
src/applications/nuance/cursor/NuanceGitHubRepositoryImportCursor.php
··· 158 158 159 159 $this->updatePolling($response, $now, true); 160 160 161 + // Reverse the new items so we insert them in chronological order. 162 + $new_items = array_reverse($new_items); 163 + 161 164 $source->openTransaction(); 162 165 foreach ($new_items as $new_item) { 163 166 $new_item->save();
+43
src/applications/nuance/item/NuanceGitHubEventItemType.php
··· 5 5 6 6 const ITEMTYPE = 'github.event'; 7 7 8 + public function getItemTypeDisplayName() { 9 + return pht('GitHub Event'); 10 + } 11 + 12 + public function getItemTypeDisplayIcon() { 13 + return 'fa-github'; 14 + } 15 + 16 + public function getItemDisplayName(NuanceItem $item) { 17 + $raw = $item->getItemProperty('api.raw', array()); 18 + 19 + $repo = idxv($raw, array('repo', 'name'), pht('<unknown/unknown>')); 20 + 21 + $type = idx($raw, 'type'); 22 + switch ($type) { 23 + case 'PushEvent': 24 + $head = idxv($raw, array('payload', 'head')); 25 + $head = substr($head, 0, 8); 26 + $name = pht('Push %s', $head); 27 + break; 28 + case 'IssuesEvent': 29 + $action = idxv($raw, array('payload', 'action')); 30 + $number = idxv($raw, array('payload', 'issue', 'number')); 31 + $name = pht('Issue #%d (%s)', $number, $action); 32 + break; 33 + case 'IssueCommentEvent': 34 + $action = idxv($raw, array('payload', 'action')); 35 + $number = idxv($raw, array('payload', 'issue', 'number')); 36 + $name = pht('Issue #%d (Comment, %s)', $number, $action); 37 + break; 38 + case 'PullRequestEvent': 39 + $action = idxv($raw, array('payload', 'action')); 40 + $number = idxv($raw, array('payload', 'pull_request', 'number')); 41 + $name = pht('Pull Request #%d (%s)', $number, $action); 42 + break; 43 + default: 44 + $name = pht('Unknown Event ("%s")', $type); 45 + break; 46 + } 47 + 48 + return pht('GitHub %s %s', $repo, $name); 49 + } 50 + 8 51 public function canUpdateItems() { 9 52 return true; 10 53 }
+26
src/applications/nuance/item/NuanceItemType.php
··· 3 3 abstract class NuanceItemType 4 4 extends Phobject { 5 5 6 + private $viewer; 7 + 8 + public function setViewer(PhabricatorUser $viewer) { 9 + $this->viewer = $viewer; 10 + return $this; 11 + } 12 + 13 + public function getViewer() { 14 + return $this->viewer; 15 + } 16 + 6 17 public function canUpdateItems() { 7 18 return false; 8 19 } 20 + 21 + final public function buildItemView(NuanceItem $item) { 22 + return $this->newItemView($item); 23 + } 24 + 25 + protected function newItemView() { 26 + return null; 27 + } 28 + 29 + public function getItemTypeDisplayIcon() { 30 + return null; 31 + } 32 + 33 + abstract public function getItemTypeDisplayName(); 34 + abstract public function getItemDisplayName(NuanceItem $item); 9 35 10 36 final public function updateItem(NuanceItem $item) { 11 37 if (!$this->canUpdateItems()) {
+1 -1
src/applications/nuance/phid/NuanceItemPHIDType.php
··· 33 33 foreach ($handles as $phid => $handle) { 34 34 $item = $objects[$phid]; 35 35 36 - $handle->setName($item->getLabel($viewer)); 36 + $handle->setName($item->getItemDisplayName()); 37 37 $handle->setURI($item->getURI()); 38 38 } 39 39 }
+5 -1
src/applications/nuance/query/NuanceItemSearchEngine.php
··· 61 61 $list = new PHUIObjectItemListView(); 62 62 $list->setUser($viewer); 63 63 foreach ($items as $item) { 64 + $impl = $item->getImplementation(); 65 + 64 66 $view = id(new PHUIObjectItemView()) 65 67 ->setObjectName(pht('Item %d', $item->getID())) 66 68 ->setHeader($item->getDisplayName()) 67 69 ->setHref($item->getURI()); 68 70 69 - $view->addIcon('none', $item->getItemType()); 71 + $view->addIcon( 72 + $impl->getItemTypeDisplayIcon(), 73 + $impl->getItemTypeDisplayName()); 70 74 71 75 $list->addItem($view); 72 76 }
-7
src/applications/nuance/source/NuancePhabricatorFormSourceDefinition.php
··· 72 72 return $box; 73 73 } 74 74 75 - public function renderItemViewProperties( 76 - PhabricatorUser $viewer, 77 - NuanceItem $item, 78 - PHUIPropertyListView $view) { 79 - $this->renderItemCommonProperties($viewer, $item, $view); 80 - } 81 - 82 75 public function renderItemEditProperties( 83 76 PhabricatorUser $viewer, 84 77 NuanceItem $item,
-7
src/applications/nuance/source/NuanceSourceDefinition.php
··· 193 193 return $item; 194 194 } 195 195 196 - public function renderItemViewProperties( 197 - PhabricatorUser $viewer, 198 - NuanceItem $item, 199 - PHUIPropertyListView $view) { 200 - return; 201 - } 202 - 203 196 public function renderItemEditProperties( 204 197 PhabricatorUser $viewer, 205 198 NuanceItem $item,
+1 -5
src/applications/nuance/storage/NuanceItem.php
··· 87 87 return '/nuance/item/view/'.$this->getID().'/'; 88 88 } 89 89 90 - public function getLabel(PhabricatorUser $viewer) { 91 - return pht('TODO: An Item'); 92 - } 93 - 94 90 public function getRequestor() { 95 91 return $this->assertAttached($this->requestor); 96 92 } ··· 144 140 } 145 141 146 142 public function getDisplayName() { 147 - return pht('An Item'); 143 + return $this->getImplementation()->getItemDisplayName($this); 148 144 } 149 145 150 146 public function scheduleUpdate() {