mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +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:
parent
4fc5f8e297
commit
5eb496bb3e
4 changed files with 59 additions and 6 deletions
|
@ -6,6 +6,7 @@ final class HarbormasterBuildPlanQuery
|
||||||
private $ids;
|
private $ids;
|
||||||
private $phids;
|
private $phids;
|
||||||
private $statuses;
|
private $statuses;
|
||||||
|
private $datasourceQuery;
|
||||||
|
|
||||||
public function withIDs(array $ids) {
|
public function withIDs(array $ids) {
|
||||||
$this->ids = $ids;
|
$this->ids = $ids;
|
||||||
|
@ -22,6 +23,11 @@ final class HarbormasterBuildPlanQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withDatasourceQuery($query) {
|
||||||
|
$this->datasourceQuery = $query;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function loadPage() {
|
protected function loadPage() {
|
||||||
$table = new HarbormasterBuildPlan();
|
$table = new HarbormasterBuildPlan();
|
||||||
$conn_r = $table->establishConnection('r');
|
$conn_r = $table->establishConnection('r');
|
||||||
|
@ -61,6 +67,13 @@ final class HarbormasterBuildPlanQuery
|
||||||
$this->statuses);
|
$this->statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strlen($this->datasourceQuery)) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'name LIKE %>',
|
||||||
|
$this->datasourceQuery);
|
||||||
|
}
|
||||||
|
|
||||||
$where[] = $this->buildPagingClause($conn_r);
|
$where[] = $this->buildPagingClause($conn_r);
|
||||||
|
|
||||||
return $this->formatWhereClause($where);
|
return $this->formatWhereClause($where);
|
||||||
|
@ -70,4 +83,31 @@ final class HarbormasterBuildPlanQuery
|
||||||
return 'PhabricatorHarbormasterApplication';
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,14 @@ final class HarbormasterBuildPlanSearchEngine
|
||||||
'status',
|
'status',
|
||||||
$this->readListFromRequest($request, 'status'));
|
$this->readListFromRequest($request, 'status'));
|
||||||
|
|
||||||
|
$this->saveQueryOrder($saved, $request);
|
||||||
|
|
||||||
return $saved;
|
return $saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
||||||
$query = id(new HarbormasterBuildPlanQuery());
|
$query = id(new HarbormasterBuildPlanQuery());
|
||||||
|
$this->setQueryOrder($query, $saved);
|
||||||
|
|
||||||
$status = $saved->getParameter('status', array());
|
$status = $saved->getParameter('status', array());
|
||||||
if ($status) {
|
if ($status) {
|
||||||
|
@ -34,9 +37,9 @@ final class HarbormasterBuildPlanSearchEngine
|
||||||
|
|
||||||
public function buildSearchForm(
|
public function buildSearchForm(
|
||||||
AphrontFormView $form,
|
AphrontFormView $form,
|
||||||
PhabricatorSavedQuery $saved_query) {
|
PhabricatorSavedQuery $saved) {
|
||||||
|
|
||||||
$status = $saved_query->getParameter('status', array());
|
$status = $saved->getParameter('status', array());
|
||||||
|
|
||||||
$form
|
$form
|
||||||
->appendChild(
|
->appendChild(
|
||||||
|
@ -52,6 +55,11 @@ final class HarbormasterBuildPlanSearchEngine
|
||||||
HarbormasterBuildPlan::STATUS_DISABLED,
|
HarbormasterBuildPlan::STATUS_DISABLED,
|
||||||
pht('Disabled'),
|
pht('Disabled'),
|
||||||
in_array(HarbormasterBuildPlan::STATUS_DISABLED, $status)));
|
in_array(HarbormasterBuildPlan::STATUS_DISABLED, $status)));
|
||||||
|
|
||||||
|
$this->appendOrderFieldsToForm(
|
||||||
|
$form,
|
||||||
|
$saved,
|
||||||
|
new HarbormasterBuildPlanQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getURI($path) {
|
protected function getURI($path) {
|
||||||
|
|
|
@ -23,13 +23,16 @@ final class HarbormasterBuildPlan extends HarbormasterDAO
|
||||||
return array(
|
return array(
|
||||||
self::CONFIG_AUX_PHID => true,
|
self::CONFIG_AUX_PHID => true,
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
self::CONFIG_COLUMN_SCHEMA => array(
|
||||||
'name' => 'text255',
|
'name' => 'sort128',
|
||||||
'planStatus' => 'text32',
|
'planStatus' => 'text32',
|
||||||
),
|
),
|
||||||
self::CONFIG_KEY_SCHEMA => array(
|
self::CONFIG_KEY_SCHEMA => array(
|
||||||
'key_status' => array(
|
'key_status' => array(
|
||||||
'columns' => array('planStatus'),
|
'columns' => array('planStatus'),
|
||||||
),
|
),
|
||||||
|
'key_name' => array(
|
||||||
|
'columns' => array('name'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,11 @@ final class HarbormasterBuildPlanDatasource
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
$plans = id(new HarbormasterBuildPlanQuery())
|
$query = id(new HarbormasterBuildPlanQuery())
|
||||||
->setViewer($viewer)
|
->setOrder('name')
|
||||||
->execute();
|
->withDatasourceQuery($raw_query);
|
||||||
|
|
||||||
|
$plans = $this->executeQuery($query);
|
||||||
foreach ($plans as $plan) {
|
foreach ($plans as $plan) {
|
||||||
$closed = null;
|
$closed = null;
|
||||||
if ($plan->isDisabled()) {
|
if ($plan->isDisabled()) {
|
||||||
|
|
Loading…
Reference in a new issue