mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 22:40:55 +01:00
Allow Nuance items to provide curtain panels, link to imported tasks, parse comments
Summary: Ref T10537. - Let nuance items render custom curtain panels. - Add a custom panel linking to the imported task, if one exists. - Actually extract comments properly. Test Plan: Unit tests, plus: {F1193800} {F1193801} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10537 Differential Revision: https://secure.phabricator.com/D15537
This commit is contained in:
parent
a4270e5413
commit
da1ebac8d8
7 changed files with 47 additions and 3 deletions
|
@ -76,6 +76,10 @@ final class NuanceItemViewController extends NuanceController {
|
|||
$curtain->addAction($action);
|
||||
}
|
||||
|
||||
foreach ($impl->getItemCurtainPanels($item) as $panel) {
|
||||
$curtain->addPanel($panel);
|
||||
}
|
||||
|
||||
return $curtain;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,13 @@ final class NuanceGitHubRawEvent extends Phobject {
|
|||
}
|
||||
|
||||
public function getComment() {
|
||||
return 'TODO: Actually extract comment text.';
|
||||
if (!$this->isIssueEvent() && !$this->isPullRequestEvent()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$raw = $this->raw;
|
||||
|
||||
return idxv($raw, array('payload', 'comment', 'body'));
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
|
|
|
@ -51,6 +51,7 @@ final class NuanceGitHubRawEventTestCase
|
|||
'id' => $event->getID(),
|
||||
'uri' => $event->getURI(),
|
||||
'title.full' => $event->getEventFullTitle(),
|
||||
'comment' => $event->getComment(),
|
||||
);
|
||||
|
||||
// Only verify the keys which are actually present in the test. This
|
||||
|
|
|
@ -160,5 +160,6 @@
|
|||
"pull.number": 2,
|
||||
"id": 3740938746,
|
||||
"uri": "https://github.com/epriestley/poems/pull/2#issuecomment-194282800",
|
||||
"title.full": "GitHub epriestley/poems Pull Request #2 (Comment)"
|
||||
"title.full": "GitHub epriestley/poems Pull Request #2 (Comment)",
|
||||
"comment": "wub wub"
|
||||
}
|
||||
|
|
|
@ -97,5 +97,6 @@
|
|||
"issue.number": 1,
|
||||
"id": 3733510485,
|
||||
"uri": "https://github.com/epriestley/poems/issues/1#issuecomment-193528669",
|
||||
"title.full": "GitHub epriestley/poems Issue #1 (Comment)"
|
||||
"title.full": "GitHub epriestley/poems Issue #1 (Comment)",
|
||||
"comment": "comment on issue"
|
||||
}
|
||||
|
|
|
@ -154,6 +154,29 @@ final class NuanceGitHubEventItemType
|
|||
return $actions;
|
||||
}
|
||||
|
||||
public function getItemCurtainPanels(NuanceItem $item) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$panels = array();
|
||||
|
||||
$xobj = $this->getExternalObject($item);
|
||||
if ($xobj) {
|
||||
$xobj_phid = $xobj->getPHID();
|
||||
|
||||
$task = id(new ManiphestTaskQuery())
|
||||
->setViewer($viewer)
|
||||
->withBridgedObjectPHIDs(array($xobj_phid))
|
||||
->executeOne();
|
||||
if ($task) {
|
||||
$panels[] = $this->newCurtainPanel($item)
|
||||
->setHeaderText(pht('Imported As'))
|
||||
->appendChild($viewer->renderHandle($task->getPHID()));
|
||||
}
|
||||
}
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
protected function handleAction(NuanceItem $item, $action) {
|
||||
$viewer = $this->getViewer();
|
||||
$controller = $this->getController();
|
||||
|
|
|
@ -44,6 +44,10 @@ abstract class NuanceItemType
|
|||
return array();
|
||||
}
|
||||
|
||||
public function getItemCurtainPanels(NuanceItem $item) {
|
||||
return array();
|
||||
}
|
||||
|
||||
abstract public function getItemTypeDisplayName();
|
||||
abstract public function getItemDisplayName(NuanceItem $item);
|
||||
|
||||
|
@ -82,6 +86,10 @@ abstract class NuanceItemType
|
|||
->setHref($action_uri);
|
||||
}
|
||||
|
||||
final protected function newCurtainPanel(NuanceItem $item) {
|
||||
return id(new PHUICurtainPanelView());
|
||||
}
|
||||
|
||||
final public function buildActionResponse(NuanceItem $item, $action) {
|
||||
$response = $this->handleAction($item, $action);
|
||||
|
||||
|
|
Loading…
Reference in a new issue