Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15436284
D15445.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D15445.diff
View Options
diff --git a/src/applications/nuance/controller/NuanceItemViewController.php b/src/applications/nuance/controller/NuanceItemViewController.php
--- a/src/applications/nuance/controller/NuanceItemViewController.php
+++ b/src/applications/nuance/controller/NuanceItemViewController.php
@@ -15,6 +15,7 @@
}
$title = pht('Item %d', $item->getID());
+ $name = $item->getDisplayName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
@@ -23,16 +24,16 @@
$crumbs->addTextCrumb($title);
$crumbs->setBorder(true);
- $properties = $this->buildPropertyView($item);
$curtain = $this->buildCurtain($item);
+ $content = $this->buildContent($item);
$header = id(new PHUIHeaderView())
- ->setHeader($title);
+ ->setHeader($name);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
- ->addPropertySection(pht('DETAILS'), $properties);
+ ->setMainColumn($content);
return $this->newPage()
->setTitle($title)
@@ -40,27 +41,6 @@
->appendChild($view);
}
- private function buildPropertyView(NuanceItem $item) {
- $viewer = $this->getViewer();
-
- $properties = id(new PHUIPropertyListView())
- ->setUser($viewer);
-
- $properties->addProperty(
- pht('Date Created'),
- phabricator_datetime($item->getDateCreated(), $viewer));
-
- $source = $item->getSource();
- $definition = $source->getDefinition();
-
- $definition->renderItemViewProperties(
- $viewer,
- $item,
- $properties);
-
- return $properties;
- }
-
private function buildCurtain(NuanceItem $item) {
$viewer = $this->getViewer();
$id = $item->getID();
@@ -81,5 +61,12 @@
return $curtain;
}
+ private function buildContent(NuanceItem $item) {
+ $viewer = $this->getViewer();
+ $impl = $item->getImplementation();
+
+ $impl->setViewer($viewer);
+ return $impl->buildItemView($item);
+ }
}
diff --git a/src/applications/nuance/cursor/NuanceGitHubRepositoryImportCursor.php b/src/applications/nuance/cursor/NuanceGitHubRepositoryImportCursor.php
--- a/src/applications/nuance/cursor/NuanceGitHubRepositoryImportCursor.php
+++ b/src/applications/nuance/cursor/NuanceGitHubRepositoryImportCursor.php
@@ -158,6 +158,9 @@
$this->updatePolling($response, $now, true);
+ // Reverse the new items so we insert them in chronological order.
+ $new_items = array_reverse($new_items);
+
$source->openTransaction();
foreach ($new_items as $new_item) {
$new_item->save();
diff --git a/src/applications/nuance/item/NuanceGitHubEventItemType.php b/src/applications/nuance/item/NuanceGitHubEventItemType.php
--- a/src/applications/nuance/item/NuanceGitHubEventItemType.php
+++ b/src/applications/nuance/item/NuanceGitHubEventItemType.php
@@ -5,6 +5,49 @@
const ITEMTYPE = 'github.event';
+ public function getItemTypeDisplayName() {
+ return pht('GitHub Event');
+ }
+
+ public function getItemTypeDisplayIcon() {
+ return 'fa-github';
+ }
+
+ public function getItemDisplayName(NuanceItem $item) {
+ $raw = $item->getItemProperty('api.raw', array());
+
+ $repo = idxv($raw, array('repo', 'name'), pht('<unknown/unknown>'));
+
+ $type = idx($raw, 'type');
+ switch ($type) {
+ case 'PushEvent':
+ $head = idxv($raw, array('payload', 'head'));
+ $head = substr($head, 0, 8);
+ $name = pht('Push %s', $head);
+ break;
+ case 'IssuesEvent':
+ $action = idxv($raw, array('payload', 'action'));
+ $number = idxv($raw, array('payload', 'issue', 'number'));
+ $name = pht('Issue #%d (%s)', $number, $action);
+ break;
+ case 'IssueCommentEvent':
+ $action = idxv($raw, array('payload', 'action'));
+ $number = idxv($raw, array('payload', 'issue', 'number'));
+ $name = pht('Issue #%d (Comment, %s)', $number, $action);
+ break;
+ case 'PullRequestEvent':
+ $action = idxv($raw, array('payload', 'action'));
+ $number = idxv($raw, array('payload', 'pull_request', 'number'));
+ $name = pht('Pull Request #%d (%s)', $number, $action);
+ break;
+ default:
+ $name = pht('Unknown Event ("%s")', $type);
+ break;
+ }
+
+ return pht('GitHub %s %s', $repo, $name);
+ }
+
public function canUpdateItems() {
return true;
}
diff --git a/src/applications/nuance/item/NuanceItemType.php b/src/applications/nuance/item/NuanceItemType.php
--- a/src/applications/nuance/item/NuanceItemType.php
+++ b/src/applications/nuance/item/NuanceItemType.php
@@ -3,10 +3,36 @@
abstract class NuanceItemType
extends Phobject {
+ private $viewer;
+
+ public function setViewer(PhabricatorUser $viewer) {
+ $this->viewer = $viewer;
+ return $this;
+ }
+
+ public function getViewer() {
+ return $this->viewer;
+ }
+
public function canUpdateItems() {
return false;
}
+ final public function buildItemView(NuanceItem $item) {
+ return $this->newItemView($item);
+ }
+
+ protected function newItemView() {
+ return null;
+ }
+
+ public function getItemTypeDisplayIcon() {
+ return null;
+ }
+
+ abstract public function getItemTypeDisplayName();
+ abstract public function getItemDisplayName(NuanceItem $item);
+
final public function updateItem(NuanceItem $item) {
if (!$this->canUpdateItems()) {
throw new Exception(
diff --git a/src/applications/nuance/phid/NuanceItemPHIDType.php b/src/applications/nuance/phid/NuanceItemPHIDType.php
--- a/src/applications/nuance/phid/NuanceItemPHIDType.php
+++ b/src/applications/nuance/phid/NuanceItemPHIDType.php
@@ -33,7 +33,7 @@
foreach ($handles as $phid => $handle) {
$item = $objects[$phid];
- $handle->setName($item->getLabel($viewer));
+ $handle->setName($item->getItemDisplayName());
$handle->setURI($item->getURI());
}
}
diff --git a/src/applications/nuance/query/NuanceItemSearchEngine.php b/src/applications/nuance/query/NuanceItemSearchEngine.php
--- a/src/applications/nuance/query/NuanceItemSearchEngine.php
+++ b/src/applications/nuance/query/NuanceItemSearchEngine.php
@@ -61,12 +61,16 @@
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($items as $item) {
+ $impl = $item->getImplementation();
+
$view = id(new PHUIObjectItemView())
->setObjectName(pht('Item %d', $item->getID()))
->setHeader($item->getDisplayName())
->setHref($item->getURI());
- $view->addIcon('none', $item->getItemType());
+ $view->addIcon(
+ $impl->getItemTypeDisplayIcon(),
+ $impl->getItemTypeDisplayName());
$list->addItem($view);
}
diff --git a/src/applications/nuance/source/NuancePhabricatorFormSourceDefinition.php b/src/applications/nuance/source/NuancePhabricatorFormSourceDefinition.php
--- a/src/applications/nuance/source/NuancePhabricatorFormSourceDefinition.php
+++ b/src/applications/nuance/source/NuancePhabricatorFormSourceDefinition.php
@@ -72,13 +72,6 @@
return $box;
}
- public function renderItemViewProperties(
- PhabricatorUser $viewer,
- NuanceItem $item,
- PHUIPropertyListView $view) {
- $this->renderItemCommonProperties($viewer, $item, $view);
- }
-
public function renderItemEditProperties(
PhabricatorUser $viewer,
NuanceItem $item,
diff --git a/src/applications/nuance/source/NuanceSourceDefinition.php b/src/applications/nuance/source/NuanceSourceDefinition.php
--- a/src/applications/nuance/source/NuanceSourceDefinition.php
+++ b/src/applications/nuance/source/NuanceSourceDefinition.php
@@ -193,13 +193,6 @@
return $item;
}
- public function renderItemViewProperties(
- PhabricatorUser $viewer,
- NuanceItem $item,
- PHUIPropertyListView $view) {
- return;
- }
-
public function renderItemEditProperties(
PhabricatorUser $viewer,
NuanceItem $item,
diff --git a/src/applications/nuance/storage/NuanceItem.php b/src/applications/nuance/storage/NuanceItem.php
--- a/src/applications/nuance/storage/NuanceItem.php
+++ b/src/applications/nuance/storage/NuanceItem.php
@@ -87,10 +87,6 @@
return '/nuance/item/view/'.$this->getID().'/';
}
- public function getLabel(PhabricatorUser $viewer) {
- return pht('TODO: An Item');
- }
-
public function getRequestor() {
return $this->assertAttached($this->requestor);
}
@@ -144,7 +140,7 @@
}
public function getDisplayName() {
- return pht('An Item');
+ return $this->getImplementation()->getItemDisplayName($this);
}
public function scheduleUpdate() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 26, 1:07 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7390688
Default Alt Text
D15445.diff (8 KB)
Attached To
Mode
D15445: Give Nuance items some basic descriptive text
Attached
Detach File
Event Timeline
Log In to Comment