private function handlePropertyEvent($ui_event) { $user = $ui_event->getUser(); $object = $ui_event->getValue('object'); if (!$object || !$object->getPHID()) { // No object, or the object has no PHID yet.. return; } if ($object instanceof HarbormasterBuildable) { // Although HarbormasterBuildable implements the correct interface, it // does not make sense to show a build's build status. In the best case // it is meaningless, and in the worst case it's confusing. return; } if ($object instanceof DifferentialRevision) { // TODO: This is a bit hacky and we could probably find a cleaner fix // eventually, but we show build status on each diff, immediately below // this property list, so it's redundant to show it on the revision view. return; } if (!$object instanceof HarbormasterBuildableInterface) { return; } $buildable_phid = $object->getHarbormasterBuildablePHID(); if (!$buildable_phid) { return; } if (!$this->canUseApplication($ui_event->getUser())) { return; } $buildable = id(new HarbormasterBuildableQuery())->setViewer($user)->withManualBuildables(false)->withBuildablePHIDs(array($buildable_phid))->needBuilds(true)->executeOne(); if (!$buildable) { return; } $builds = $buildable->getBuilds(); $build_handles = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(mpull($builds, 'getPHID'))->execute(); $status_view = new PHUIStatusListView(); $buildable_status = $buildable->getBuildableStatus(); $buildable_icon = HarbormasterBuildable::getBuildableStatusIcon($buildable_status); $buildable_color = HarbormasterBuildable::getBuildableStatusColor($buildable_status); $buildable_name = HarbormasterBuildable::getBuildableStatusName($buildable_status); $target = phutil_tag('a', array('href' => '/' . $buildable->getMonogram()), pht('Buildable %d', $buildable->getID())); $target = phutil_tag('strong', array(), $target); $status_view->addItem(id(new PHUIStatusItemView())->setIcon($buildable_icon, $buildable_color, $buildable_name)->setTarget($target)); foreach ($builds as $build) { $item = new PHUIStatusItemView(); $item->setTarget($build_handles[$build->getPHID()]->renderLink()); $status = $build->getBuildStatus(); $status_name = HarbormasterBuild::getBuildStatusName($status); $icon = HarbormasterBuild::getBuildStatusIcon($status); $color = HarbormasterBuild::getBuildStatusColor($status); $item->setIcon($icon, $color, $status_name); $status_view->addItem($item); } $view = $ui_event->getValue('view'); $view->addProperty(pht('Build Status'), $status_view); }
protected function execute(ConduitAPIRequest $request) { $viewer = $request->getUser(); $query = id(new HarbormasterBuildableQuery())->setViewer($viewer); $ids = $request->getValue('ids'); if ($ids !== null) { $query->withIDs($ids); } $phids = $request->getValue('phids'); if ($phids !== null) { $query->withPHIDs($phids); } $buildable_phids = $request->getValue('buildablePHIDs'); if ($buildable_phids !== null) { $query->withBuildablePHIDs($buildable_phids); } $container_phids = $request->getValue('containerPHIDs'); if ($container_phids !== null) { $query->withContainerPHIDs($container_phids); } $manual = $request->getValue('manualBuildables'); if ($manual !== null) { $query->withManualBuildables($manual); } $pager = $this->newPager($request); $buildables = $query->executeWithCursorPager($pager); $data = array(); foreach ($buildables as $buildable) { $monogram = $buildable->getMonogram(); $status = $buildable->getBuildableStatus(); $status_name = HarbormasterBuildable::getBuildableStatusName($status); $data[] = array('id' => $buildable->getID(), 'phid' => $buildable->getPHID(), 'monogram' => $monogram, 'uri' => PhabricatorEnv::getProductionURI('/' . $monogram), 'buildableStatus' => $status, 'buildableStatusName' => $status_name, 'buildablePHID' => $buildable->getBuildablePHID(), 'containerPHID' => $buildable->getContainerPHID(), 'isManualBuildable' => (bool) $buildable->getIsManualBuildable()); } $results = array('data' => $data); $results = $this->addPagerResults($results, $pager); return $results; }
public function render() { $drequest = $this->getDiffusionRequest(); $handles = $this->handles; $graph = null; if ($this->parents) { $graph = $this->renderGraph(); } $show_builds = PhabricatorApplication::isClassInstalledForViewer('PhabricatorHarbormasterApplication', $this->getUser()); $rows = array(); $ii = 0; foreach ($this->history as $history) { $epoch = $history->getEpoch(); if ($epoch) { $date = phabricator_date($epoch, $this->user); $time = phabricator_time($epoch, $this->user); } else { $date = null; $time = null; } $data = $history->getCommitData(); $author_phid = $committer = $committer_phid = null; if ($data) { $author_phid = $data->getCommitDetail('authorPHID'); $committer_phid = $data->getCommitDetail('committerPHID'); $committer = $data->getCommitDetail('committer'); } if ($author_phid && isset($handles[$author_phid])) { $author = $handles[$author_phid]->renderLink(); } else { $author = self::renderName($history->getAuthorName()); } $different_committer = false; if ($committer_phid) { $different_committer = $committer_phid != $author_phid; } else { if ($committer != '') { $different_committer = $committer != $history->getAuthorName(); } } if ($different_committer) { if ($committer_phid && isset($handles[$committer_phid])) { $committer = $handles[$committer_phid]->renderLink(); } else { $committer = self::renderName($committer); } $author = hsprintf('%s/%s', $author, $committer); } // We can show details once the message and change have been imported. $partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE | PhabricatorRepositoryCommit::IMPORTED_CHANGE; $commit = $history->getCommit(); if ($commit && $commit->isPartiallyImported($partial_import) && $data) { $summary = AphrontTableView::renderSingleDisplayLine($history->getSummary()); } else { $summary = phutil_tag('em', array(), "Importing…"); } $build = null; if ($show_builds) { $buildable_lookup = $this->loadBuildablesOnDemand(); $buildable = idx($buildable_lookup, $commit->getPHID()); if ($buildable !== null) { $icon = HarbormasterBuildable::getBuildableStatusIcon($buildable->getBuildableStatus()); $color = HarbormasterBuildable::getBuildableStatusColor($buildable->getBuildableStatus()); $name = HarbormasterBuildable::getBuildableStatusName($buildable->getBuildableStatus()); $icon_view = id(new PHUIIconView())->setIconFont($icon . ' ' . $color); $tooltip_view = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $name)), $icon_view); Javelin::initBehavior('phabricator-tooltips'); $href_view = phutil_tag('a', array('href' => '/' . $buildable->getMonogram()), $tooltip_view); $build = $href_view; $has_any_build = true; } } $rows[] = array($graph ? $graph[$ii++] : null, self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $build, $commit ? self::linkRevision(idx($this->revisions, $commit->getPHID())) : null, $author, $summary, $date, $time); } $view = new AphrontTableView($rows); $view->setHeaders(array('', pht('Commit'), '', pht('Revision'), pht('Author/Committer'), pht('Details'), pht('Date'), pht('Time'))); $view->setColumnClasses(array('threads', 'n', 'icon', 'n', '', 'wide', '', 'right')); $view->setColumnVisibility(array($graph ? true : false)); $view->setDeviceVisibility(array($graph ? true : false, true, true, true, false, true, false, false)); return $view->render(); }
protected final function renderBuildable(HarbormasterBuildable $buildable) { $status = $buildable->getBuildableStatus(); $icon = HarbormasterBuildable::getBuildableStatusIcon($status); $color = HarbormasterBuildable::getBuildableStatusColor($status); $name = HarbormasterBuildable::getBuildableStatusName($status); $icon_view = id(new PHUIIconView())->setIcon($icon . ' ' . $color); $tooltip_view = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $name)), $icon_view); Javelin::initBehavior('phabricator-tooltips'); return phutil_tag('a', array('href' => '/' . $buildable->getMonogram()), $tooltip_view); }
protected function renderResultList(array $buildables, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($buildables, 'HarbormasterBuildable'); $viewer = $this->requireViewer(); $list = new PHUIObjectItemListView(); foreach ($buildables as $buildable) { $id = $buildable->getID(); $item = id(new PHUIObjectItemView())->setHeader(pht('Buildable %d', $buildable->getID())); if ($buildable->getContainerHandle() !== null) { $item->addAttribute($buildable->getContainerHandle()->getName()); } if ($buildable->getBuildableHandle() !== null) { $item->addAttribute($buildable->getBuildableHandle()->getFullName()); } if ($id) { $item->setHref("/B{$id}"); } if ($buildable->getIsManualBuildable()) { $item->addIcon('fa-wrench grey', pht('Manual')); } $item->setBarColor(HarbormasterBuildable::getBuildableStatusColor($buildable->getBuildableStatus())); $item->addByline(HarbormasterBuildable::getBuildableStatusName($buildable->getBuildableStatus())); $list->addItem($item); } return $list; }
protected function renderResultList(array $buildables, PhabricatorSavedQuery $query, array $handles) { assert_instances_of($buildables, 'HarbormasterBuildable'); $viewer = $this->requireViewer(); $phids = array(); foreach ($buildables as $buildable) { $phids[] = $buildable->getBuildableObject()->getHarbormasterBuildableDisplayPHID(); $phids[] = $buildable->getContainerPHID(); $phids[] = $buildable->getBuildablePHID(); } $handles = $viewer->loadHandles($phids); $list = new PHUIObjectItemListView(); foreach ($buildables as $buildable) { $id = $buildable->getID(); $display_phid = $buildable->getBuildableObject()->getHarbormasterBuildableDisplayPHID(); $container_phid = $buildable->getContainerPHID(); $buildable_phid = $buildable->getBuildablePHID(); $item = id(new PHUIObjectItemView())->setObjectName(pht('Buildable %d', $buildable->getID())); if ($display_phid) { $handle = $handles[$display_phid]; $item->setHeader($handle->getFullName()); } if ($container_phid && $container_phid != $display_phid) { $handle = $handles[$container_phid]; $item->addAttribute($handle->getName()); } if ($buildable_phid && $buildable_phid != $display_phid) { $handle = $handles[$buildable_phid]; $item->addAttribute($handle->getFullName()); } $item->setHref($buildable->getURI()); if ($buildable->getIsManualBuildable()) { $item->addIcon('fa-wrench grey', pht('Manual')); } $status = $buildable->getBuildableStatus(); $status_icon = HarbormasterBuildable::getBuildableStatusIcon($status); $status_color = HarbormasterBuildable::getBuildableStatusColor($status); $status_label = HarbormasterBuildable::getBuildableStatusName($status); $item->setStatusIcon("{$status_icon} {$status_color}", $status_label); $list->addItem($item); } $result = new PhabricatorApplicationSearchResultView(); $result->setObjectList($list); $result->setNoDataString(pht('No buildables found.')); return $result; }