1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02:00

Slightly improve Buildable list in Harbormaster

Summary:
Ref T10457. This makes diffs/revisions show the revision as the buildable title, and commits show the commit as the title.

Previously, the title was "Buildable X".

Also makes icons/colors/labels more consitent.

Test Plan: {F1131885}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10457

Differential Revision: https://secure.phabricator.com/D15355
This commit is contained in:
epriestley 2016-02-26 12:20:47 -08:00
parent 220ac48801
commit fdca684814
6 changed files with 55 additions and 9 deletions

View file

@ -429,6 +429,15 @@ final class DifferentialDiff
/* -( HarbormasterBuildableInterface )------------------------------------- */
public function getHarbormasterBuildableDisplayPHID() {
$container_phid = $this->getHarbormasterContainerPHID();
if ($container_phid) {
return $container_phid;
}
return $this->getHarbormasterBuildablePHID();
}
public function getHarbormasterBuildablePHID() {
return $this->getPHID();
}

View file

@ -432,6 +432,10 @@ final class DifferentialRevision extends DifferentialDAO
/* -( HarbormasterBuildableInterface )------------------------------------- */
public function getHarbormasterBuildableDisplayPHID() {
return $this->getHarbormasterContainerPHID();
}
public function getHarbormasterBuildablePHID() {
return $this->loadActiveDiff()->getPHID();
}

View file

@ -2,6 +2,19 @@
interface HarbormasterBuildableInterface {
/**
* Get the object PHID which best identifies this buildable to humans.
*
* This object is the primary object associated with the buildable in the
* UI. The most human-readable object for a buildable varies: for example,
* for diffs the container (the revision) is more meaningful than the
* buildable (the diff), but for commits the buildable (the commit) is more
* meaningful than the container (the repository).
*
* @return phid Related object PHID most meaningful for human viewers.
*/
public function getHarbormasterBuildableDisplayPHID();
public function getHarbormasterBuildablePHID();
public function getHarbormasterContainerPHID();

View file

@ -185,6 +185,9 @@ final class HarbormasterBuildableSearchEngine
$phids = array();
foreach ($buildables as $buildable) {
$phids[] = $buildable->getBuildableObject()
->getHarbormasterBuildableDisplayPHID();
$phids[] = $buildable->getContainerPHID();
$phids[] = $buildable->getBuildablePHID();
}
@ -195,18 +198,26 @@ final class HarbormasterBuildableSearchEngine
foreach ($buildables as $buildable) {
$id = $buildable->getID();
$display_phid = $buildable->getBuildableObject()
->getHarbormasterBuildableDisplayPHID();
$container_phid = $buildable->getContainerPHID();
$buildable_phid = $buildable->getBuildablePHID();
$item = id(new PHUIObjectItemView())
->setHeader(pht('Buildable %d', $buildable->getID()));
->setObjectName(pht('Buildable %d', $buildable->getID()));
if ($container_phid) {
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) {
if ($buildable_phid && ($buildable_phid != $display_phid)) {
$handle = $handles[$buildable_phid];
$item->addAttribute($handle->getFullName());
}
@ -217,14 +228,15 @@ final class HarbormasterBuildableSearchEngine
$item->addIcon('fa-wrench grey', pht('Manual'));
}
$item->setStatusIcon('fa-wrench '.
HarbormasterBuildable::getBuildableStatusColor(
$buildable->getBuildableStatus()));
$item->addByline(HarbormasterBuildable::getBuildableStatusName(
$buildable->getBuildableStatus()));
$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();

View file

@ -302,6 +302,10 @@ final class HarbormasterBuildable extends HarbormasterDAO
/* -( HarbormasterBuildableInterface )------------------------------------- */
public function getHarbormasterBuildableDisplayPHID() {
return $this->getBuildableObject()->getHarbormasterBuildableDisplayPHID();
}
public function getHarbormasterBuildablePHID() {
// NOTE: This is essentially just for convenience, as it allows you create
// a copy of a buildable by specifying `B123` without bothering to go

View file

@ -370,6 +370,10 @@ final class PhabricatorRepositoryCommit
/* -( HarbormasterBuildableInterface )------------------------------------- */
public function getHarbormasterBuildableDisplayPHID() {
return $this->getHarbormasterBuildablePHID();
}
public function getHarbormasterBuildablePHID() {
return $this->getPHID();
}