1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 22:10:55 +01:00

Make Harbormaster build plan datasource more browsable

Summary: Ref T5750.

Test Plan:
  - Browsed plans in Harbormaster.
  - Browsed plans in typeahead browser.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5750

Differential Revision: https://secure.phabricator.com/D12435
This commit is contained in:
epriestley 2015-04-16 08:32:39 -07:00
parent 4fc5f8e297
commit 5eb496bb3e
4 changed files with 59 additions and 6 deletions

View file

@ -6,6 +6,7 @@ final class HarbormasterBuildPlanQuery
private $ids;
private $phids;
private $statuses;
private $datasourceQuery;
public function withIDs(array $ids) {
$this->ids = $ids;
@ -22,6 +23,11 @@ final class HarbormasterBuildPlanQuery
return $this;
}
public function withDatasourceQuery($query) {
$this->datasourceQuery = $query;
return $this;
}
protected function loadPage() {
$table = new HarbormasterBuildPlan();
$conn_r = $table->establishConnection('r');
@ -61,6 +67,13 @@ final class HarbormasterBuildPlanQuery
$this->statuses);
}
if (strlen($this->datasourceQuery)) {
$where[] = qsprintf(
$conn_r,
'name LIKE %>',
$this->datasourceQuery);
}
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
@ -70,4 +83,31 @@ final class HarbormasterBuildPlanQuery
return 'PhabricatorHarbormasterApplication';
}
public function getOrderableColumns() {
return parent::getOrderableColumns() + array(
'name' => array(
'column' => 'name',
'type' => 'string',
'reverse' => true,
),
);
}
public function getPagingValueMap($cursor, array $keys) {
$plan = $this->loadCursorObject($cursor);
return array(
'id' => $plan->getID(),
'name' => $plan->getName(),
);
}
public function getBuiltinOrders() {
return array(
'name' => array(
'vector' => array('name', 'id'),
'name' => pht('Name'),
),
) + parent::getBuiltinOrders();
}
}

View file

@ -18,11 +18,14 @@ final class HarbormasterBuildPlanSearchEngine
'status',
$this->readListFromRequest($request, 'status'));
$this->saveQueryOrder($saved, $request);
return $saved;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
$query = id(new HarbormasterBuildPlanQuery());
$this->setQueryOrder($query, $saved);
$status = $saved->getParameter('status', array());
if ($status) {
@ -34,9 +37,9 @@ final class HarbormasterBuildPlanSearchEngine
public function buildSearchForm(
AphrontFormView $form,
PhabricatorSavedQuery $saved_query) {
PhabricatorSavedQuery $saved) {
$status = $saved_query->getParameter('status', array());
$status = $saved->getParameter('status', array());
$form
->appendChild(
@ -52,6 +55,11 @@ final class HarbormasterBuildPlanSearchEngine
HarbormasterBuildPlan::STATUS_DISABLED,
pht('Disabled'),
in_array(HarbormasterBuildPlan::STATUS_DISABLED, $status)));
$this->appendOrderFieldsToForm(
$form,
$saved,
new HarbormasterBuildPlanQuery());
}
protected function getURI($path) {

View file

@ -23,13 +23,16 @@ final class HarbormasterBuildPlan extends HarbormasterDAO
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'name' => 'sort128',
'planStatus' => 'text32',
),
self::CONFIG_KEY_SCHEMA => array(
'key_status' => array(
'columns' => array('planStatus'),
),
'key_name' => array(
'columns' => array('name'),
),
),
) + parent::getConfiguration();
}

View file

@ -17,9 +17,11 @@ final class HarbormasterBuildPlanDatasource
$results = array();
$plans = id(new HarbormasterBuildPlanQuery())
->setViewer($viewer)
->execute();
$query = id(new HarbormasterBuildPlanQuery())
->setOrder('name')
->withDatasourceQuery($raw_query);
$plans = $this->executeQuery($query);
foreach ($plans as $plan) {
$closed = null;
if ($plan->isDisabled()) {