mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-25 06:50:55 +01:00
Show external build links in applications
Summary: Fixes T8659. This isn't //explicitly// documented but I'm going to wait for a bit until the "Harbormaster" doc splits into internal/external builds to add docs for it. There's other similar stuff coming soon anyway. Test Plan: {F716439} {F716440} Reviewers: chad Reviewed By: chad Maniphest Tasks: T8659 Differential Revision: https://secure.phabricator.com/D13903
This commit is contained in:
parent
57b0353034
commit
74bf0d6ec6
5 changed files with 118 additions and 66 deletions
|
@ -46,6 +46,15 @@ final class HarbormasterURIArtifact extends HarbormasterArtifact {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderArtifactSummary(PhabricatorUser $viewer) {
|
public function renderArtifactSummary(PhabricatorUser $viewer) {
|
||||||
|
return $this->renderLink();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isExternalLink() {
|
||||||
|
$artifact = $this->getBuildArtifact();
|
||||||
|
return (bool)$artifact->getProperty('ui.external', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderLink() {
|
||||||
$artifact = $this->getBuildArtifact();
|
$artifact = $this->getBuildArtifact();
|
||||||
$uri = $artifact->getProperty('uri');
|
$uri = $artifact->getProperty('uri');
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,18 @@ final class HarbormasterBuildViewController
|
||||||
$messages = array();
|
$messages = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($build_targets) {
|
||||||
|
$artifacts = id(new HarbormasterBuildArtifactQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withBuildTargetPHIDs(mpull($build_targets, 'getPHID'))
|
||||||
|
->execute();
|
||||||
|
$artifacts = msort($artifacts, 'getArtifactKey');
|
||||||
|
$artifacts = mgroup($artifacts, 'getBuildTargetPHID');
|
||||||
|
} else {
|
||||||
|
$artifacts = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$targets = array();
|
$targets = array();
|
||||||
foreach ($build_targets as $build_target) {
|
foreach ($build_targets as $build_target) {
|
||||||
$header = id(new PHUIHeaderView())
|
$header = id(new PHUIHeaderView())
|
||||||
|
@ -77,6 +89,27 @@ final class HarbormasterBuildViewController
|
||||||
->setHeader($header);
|
->setHeader($header);
|
||||||
|
|
||||||
$properties = new PHUIPropertyListView();
|
$properties = new PHUIPropertyListView();
|
||||||
|
|
||||||
|
$target_artifacts = idx($artifacts, $build_target->getPHID(), array());
|
||||||
|
|
||||||
|
$links = array();
|
||||||
|
$type_uri = HarbormasterURIArtifact::ARTIFACTCONST;
|
||||||
|
foreach ($target_artifacts as $artifact) {
|
||||||
|
if ($artifact->getArtifactType() == $type_uri) {
|
||||||
|
$impl = $artifact->getArtifactImplementation();
|
||||||
|
if ($impl->isExternalLink()) {
|
||||||
|
$links[] = $impl->renderLink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($links) {
|
||||||
|
$links = phutil_implode_html(phutil_tag('br'), $links);
|
||||||
|
$properties->addProperty(
|
||||||
|
pht('External Link'),
|
||||||
|
$links);
|
||||||
|
}
|
||||||
|
|
||||||
$status_view = new PHUIStatusListView();
|
$status_view = new PHUIStatusListView();
|
||||||
|
|
||||||
$item = new PHUIStatusItemView();
|
$item = new PHUIStatusItemView();
|
||||||
|
@ -177,9 +210,9 @@ final class HarbormasterBuildViewController
|
||||||
$properties->addRawContent($this->buildProperties($variables));
|
$properties->addRawContent($this->buildProperties($variables));
|
||||||
$target_box->addPropertyList($properties, pht('Variables'));
|
$target_box->addPropertyList($properties, pht('Variables'));
|
||||||
|
|
||||||
$artifacts = $this->buildArtifacts($build_target);
|
$artifacts_tab = $this->buildArtifacts($build_target, $target_artifacts);
|
||||||
$properties = new PHUIPropertyListView();
|
$properties = new PHUIPropertyListView();
|
||||||
$properties->addRawContent($artifacts);
|
$properties->addRawContent($artifacts_tab);
|
||||||
$target_box->addPropertyList($properties, pht('Artifacts'));
|
$target_box->addPropertyList($properties, pht('Artifacts'));
|
||||||
|
|
||||||
$build_messages = idx($messages, $build_target->getPHID(), array());
|
$build_messages = idx($messages, $build_target->getPHID(), array());
|
||||||
|
@ -218,16 +251,11 @@ final class HarbormasterBuildViewController
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildArtifacts(HarbormasterBuildTarget $build_target) {
|
private function buildArtifacts(
|
||||||
|
HarbormasterBuildTarget $build_target,
|
||||||
|
array $artifacts) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$artifacts = id(new HarbormasterBuildArtifactQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withBuildTargetPHIDs(array($build_target->getPHID()))
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$artifacts = msort($artifacts, 'getArtifactKey');
|
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($artifacts as $artifact) {
|
foreach ($artifacts as $artifact) {
|
||||||
$impl = $artifact->getArtifactImplementation();
|
$impl = $artifact->getArtifactImplementation();
|
||||||
|
|
|
@ -16,7 +16,7 @@ final class HarbormasterUIEventListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private function handlePropertyEvent($ui_event) {
|
private function handlePropertyEvent($ui_event) {
|
||||||
$user = $ui_event->getUser();
|
$viewer = $ui_event->getUser();
|
||||||
$object = $ui_event->getValue('object');
|
$object = $ui_event->getValue('object');
|
||||||
|
|
||||||
if (!$object || !$object->getPHID()) {
|
if (!$object || !$object->getPHID()) {
|
||||||
|
@ -52,10 +52,11 @@ final class HarbormasterUIEventListener
|
||||||
}
|
}
|
||||||
|
|
||||||
$buildable = id(new HarbormasterBuildableQuery())
|
$buildable = id(new HarbormasterBuildableQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withManualBuildables(false)
|
->withManualBuildables(false)
|
||||||
->withBuildablePHIDs(array($buildable_phid))
|
->withBuildablePHIDs(array($buildable_phid))
|
||||||
->needBuilds(true)
|
->needBuilds(true)
|
||||||
|
->needTargets(true)
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$buildable) {
|
if (!$buildable) {
|
||||||
return;
|
return;
|
||||||
|
@ -63,10 +64,26 @@ final class HarbormasterUIEventListener
|
||||||
|
|
||||||
$builds = $buildable->getBuilds();
|
$builds = $buildable->getBuilds();
|
||||||
|
|
||||||
$build_handles = id(new PhabricatorHandleQuery())
|
$targets = array();
|
||||||
->setViewer($user)
|
foreach ($builds as $build) {
|
||||||
->withPHIDs(mpull($builds, 'getPHID'))
|
foreach ($build->getBuildTargets() as $target) {
|
||||||
->execute();
|
$targets[] = $target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($targets) {
|
||||||
|
$artifacts = id(new HarbormasterBuildArtifactQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withBuildTargetPHIDs(mpull($targets, 'getPHID'))
|
||||||
|
->withArtifactTypes(
|
||||||
|
array(
|
||||||
|
HarbormasterURIArtifact::ARTIFACTCONST,
|
||||||
|
))
|
||||||
|
->execute();
|
||||||
|
$artifacts = mgroup($artifacts, 'getBuildTargetPHID');
|
||||||
|
} else {
|
||||||
|
$artifacts = array();
|
||||||
|
}
|
||||||
|
|
||||||
$status_view = new PHUIStatusListView();
|
$status_view = new PHUIStatusListView();
|
||||||
|
|
||||||
|
@ -87,6 +104,7 @@ final class HarbormasterUIEventListener
|
||||||
|
|
||||||
$target = phutil_tag('strong', array(), $target);
|
$target = phutil_tag('strong', array(), $target);
|
||||||
|
|
||||||
|
|
||||||
$status_view
|
$status_view
|
||||||
->addItem(
|
->addItem(
|
||||||
id(new PHUIStatusItemView())
|
id(new PHUIStatusItemView())
|
||||||
|
@ -95,7 +113,23 @@ final class HarbormasterUIEventListener
|
||||||
|
|
||||||
foreach ($builds as $build) {
|
foreach ($builds as $build) {
|
||||||
$item = new PHUIStatusItemView();
|
$item = new PHUIStatusItemView();
|
||||||
$item->setTarget($build_handles[$build->getPHID()]->renderLink());
|
$item->setTarget($viewer->renderHandle($build->getPHID()));
|
||||||
|
|
||||||
|
$links = array();
|
||||||
|
foreach ($build->getBuildTargets() as $build_target) {
|
||||||
|
$uris = idx($artifacts, $build_target->getPHID(), array());
|
||||||
|
foreach ($uris as $uri) {
|
||||||
|
$impl = $uri->getArtifactImplementation();
|
||||||
|
if ($impl->isExternalLink()) {
|
||||||
|
$links[] = $impl->renderLink();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($links) {
|
||||||
|
$links = phutil_implode_html(" \xC2\xB7 ", $links);
|
||||||
|
$item->setNote($links);
|
||||||
|
}
|
||||||
|
|
||||||
$status = $build->getBuildStatus();
|
$status = $build->getBuildStatus();
|
||||||
$status_name = HarbormasterBuild::getBuildStatusName($status);
|
$status_name = HarbormasterBuild::getBuildStatusName($status);
|
||||||
|
@ -104,7 +138,6 @@ final class HarbormasterUIEventListener
|
||||||
|
|
||||||
$item->setIcon($icon, $color, $status_name);
|
$item->setIcon($icon, $color, $status_name);
|
||||||
|
|
||||||
|
|
||||||
$status_view->addItem($item);
|
$status_view->addItem($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,19 +40,12 @@ final class HarbormasterBuildQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function newResultObject() {
|
||||||
|
return new HarbormasterBuild();
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadPage() {
|
protected function loadPage() {
|
||||||
$table = new HarbormasterBuild();
|
return $this->loadStandardPage($this->newResultObject());
|
||||||
$conn_r = $table->establishConnection('r');
|
|
||||||
|
|
||||||
$data = queryfx_all(
|
|
||||||
$conn_r,
|
|
||||||
'SELECT * FROM %T %Q %Q %Q',
|
|
||||||
$table->getTableName(),
|
|
||||||
$this->buildWhereClause($conn_r),
|
|
||||||
$this->buildOrderClause($conn_r),
|
|
||||||
$this->buildLimitClause($conn_r));
|
|
||||||
|
|
||||||
return $table->loadAllFromArray($data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function willFilterPage(array $page) {
|
protected function willFilterPage(array $page) {
|
||||||
|
@ -136,47 +129,45 @@ final class HarbormasterBuildQuery
|
||||||
return $page;
|
return $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
||||||
$where = array();
|
$where = parent::buildWhereClauseParts($conn);
|
||||||
|
|
||||||
if ($this->ids !== null) {
|
if ($this->ids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'id IN (%Ld)',
|
'id IN (%Ld)',
|
||||||
$this->ids);
|
$this->ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->phids !== null) {
|
if ($this->phids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'phid in (%Ls)',
|
'phid in (%Ls)',
|
||||||
$this->phids);
|
$this->phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->buildStatuses !== null) {
|
if ($this->buildStatuses !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'buildStatus in (%Ls)',
|
'buildStatus in (%Ls)',
|
||||||
$this->buildStatuses);
|
$this->buildStatuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->buildablePHIDs !== null) {
|
if ($this->buildablePHIDs !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'buildablePHID IN (%Ls)',
|
'buildablePHID IN (%Ls)',
|
||||||
$this->buildablePHIDs);
|
$this->buildablePHIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->buildPlanPHIDs !== null) {
|
if ($this->buildPlanPHIDs !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'buildPlanPHID IN (%Ls)',
|
'buildPlanPHID IN (%Ls)',
|
||||||
$this->buildPlanPHIDs);
|
$this->buildPlanPHIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
$where[] = $this->buildPagingClause($conn_r);
|
return $where;
|
||||||
|
|
||||||
return $this->formatWhereClause($where);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getQueryApplicationClass() {
|
public function getQueryApplicationClass() {
|
||||||
|
|
|
@ -34,55 +34,46 @@ final class HarbormasterBuildTargetQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadPage() {
|
public function newResultObject() {
|
||||||
$table = new HarbormasterBuildTarget();
|
return new HarbormasterBuildTarget();
|
||||||
$conn_r = $table->establishConnection('r');
|
|
||||||
|
|
||||||
$data = queryfx_all(
|
|
||||||
$conn_r,
|
|
||||||
'SELECT * FROM %T %Q %Q %Q',
|
|
||||||
$table->getTableName(),
|
|
||||||
$this->buildWhereClause($conn_r),
|
|
||||||
$this->buildOrderClause($conn_r),
|
|
||||||
$this->buildLimitClause($conn_r));
|
|
||||||
|
|
||||||
return $table->loadAllFromArray($data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
|
protected function loadPage() {
|
||||||
$where = array();
|
return $this->loadStandardPage($this->newResultObject());
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->ids) {
|
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
|
||||||
|
$where = parent::buildWhereClauseParts($conn);
|
||||||
|
|
||||||
|
if ($this->ids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'id IN (%Ld)',
|
'id IN (%Ld)',
|
||||||
$this->ids);
|
$this->ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->phids) {
|
if ($this->phids !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'phid in (%Ls)',
|
'phid in (%Ls)',
|
||||||
$this->phids);
|
$this->phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->buildPHIDs) {
|
if ($this->buildPHIDs !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'buildPHID in (%Ls)',
|
'buildPHID in (%Ls)',
|
||||||
$this->buildPHIDs);
|
$this->buildPHIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->buildGenerations) {
|
if ($this->buildGenerations !== null) {
|
||||||
$where[] = qsprintf(
|
$where[] = qsprintf(
|
||||||
$conn_r,
|
$conn,
|
||||||
'buildGeneration in (%Ld)',
|
'buildGeneration in (%Ld)',
|
||||||
$this->buildGenerations);
|
$this->buildGenerations);
|
||||||
}
|
}
|
||||||
|
|
||||||
$where[] = $this->buildPagingClause($conn_r);
|
return $where;
|
||||||
|
|
||||||
return $this->formatWhereClause($where);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function didFilterPage(array $page) {
|
protected function didFilterPage(array $page) {
|
||||||
|
|
Loading…
Reference in a new issue