Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/event/HarbormasterUIEventListener.php
| Show All 18 Lines | private function handlePropertyEvent($ui_event) { | ||||
| $user = $ui_event->getUser(); | $user = $ui_event->getUser(); | ||||
| $object = $ui_event->getValue('object'); | $object = $ui_event->getValue('object'); | ||||
| if (!$object || !$object->getPHID()) { | if (!$object || !$object->getPHID()) { | ||||
| // No object, or the object has no PHID yet.. | // No object, or the object has no PHID yet.. | ||||
| return; | return; | ||||
| } | } | ||||
| $target = null; | if ($object instanceof HarbormasterBuildable) { | ||||
| if ($object instanceof PhabricatorRepositoryCommit) { | // Although HarbormasterBuildable implements the correct interface, it | ||||
| $target = $object; | // does not make sense to show a build's build status. In the best case | ||||
| } elseif ($object instanceof DifferentialRevision) { | // it is meaningless, and in the worst case it's confusing. | ||||
| $target = $object->loadActiveDiff(); | return; | ||||
| } else { | } | ||||
| if (!($object instanceof HarbormasterBuildableInterface)) { | |||||
| return; | |||||
| } | |||||
| $buildable_phid = $object->getBuildablePHID(); | |||||
| if (!$buildable_phid) { | |||||
| return; | return; | ||||
| } | } | ||||
| if (!$this->canUseApplication($ui_event->getUser())) { | if (!$this->canUseApplication($ui_event->getUser())) { | ||||
| return; | return; | ||||
| } | } | ||||
| $buildables = id(new HarbormasterBuildableQuery()) | $buildables = id(new HarbormasterBuildableQuery()) | ||||
| ->setViewer($user) | ->setViewer($user) | ||||
| ->withBuildablePHIDs(array($target->getPHID())) | ->withManualBuildables(false) | ||||
| ->withBuildablePHIDs(array($buildable_phid)) | |||||
| ->execute(); | ->execute(); | ||||
| if (!$buildables) { | if (!$buildables) { | ||||
| return; | return; | ||||
| } | } | ||||
| $builds = id(new HarbormasterBuildQuery()) | $builds = id(new HarbormasterBuildQuery()) | ||||
| ->setViewer($user) | ->setViewer($user) | ||||
| ->withBuildablePHIDs(mpull($buildables, 'getPHID')) | ->withBuildablePHIDs(mpull($buildables, 'getPHID')) | ||||
| ->execute(); | ->execute(); | ||||
| if (!$builds) { | if (!$builds) { | ||||
| return; | return; | ||||
| } | } | ||||
| $build_handles = id(new PhabricatorHandleQuery()) | $build_handles = id(new PhabricatorHandleQuery()) | ||||
| ->setViewer($user) | ->setViewer($user) | ||||
| ->withPHIDs(mpull($builds, 'getPHID')) | ->withPHIDs(mpull($builds, 'getPHID')) | ||||
| ->execute(); | ->execute(); | ||||
| $status_view = new PHUIStatusListView(); | $status_view = new PHUIStatusListView(); | ||||
| foreach ($builds as $build) { | foreach ($builds as $build) { | ||||
| $item = new PHUIStatusItemView(); | $item = new PHUIStatusItemView(); | ||||
| $item->setTarget( | $item->setTarget($build_handles[$build->getPHID()]->renderLink()); | ||||
| $build_handles[$build->getPHID()]->renderLink()); | |||||
| switch ($build->getBuildStatus()) { | switch ($build->getBuildStatus()) { | ||||
| case HarbormasterBuild::STATUS_INACTIVE: | case HarbormasterBuild::STATUS_INACTIVE: | ||||
| $item->setIcon('open-dark', pht('Inactive')); | $item->setIcon('open-dark', pht('Inactive')); | ||||
| break; | break; | ||||
| case HarbormasterBuild::STATUS_PENDING: | case HarbormasterBuild::STATUS_PENDING: | ||||
| $item->setIcon('open-blue', pht('Pending')); | $item->setIcon('open-blue', pht('Pending')); | ||||
| break; | break; | ||||
| Show All 32 Lines | |||||