mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-26 13:39:08 +01:00
Summary: Fixes T4187. Ref T1049. Allows build plans to be enabled or disabled. Test Plan: Enabled and disabled build plans. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4187, T1049 Differential Revision: https://secure.phabricator.com/D7822
82 lines
1.9 KiB
PHP
82 lines
1.9 KiB
PHP
<?php
|
|
|
|
final class HarbormasterBuildPlanSearchEngine
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
|
$saved = new PhabricatorSavedQuery();
|
|
|
|
$saved->setParameter(
|
|
'status',
|
|
$this->readListFromRequest($request, 'status'));
|
|
|
|
return $saved;
|
|
}
|
|
|
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
|
$query = id(new HarbormasterBuildPlanQuery());
|
|
|
|
$status = $saved->getParameter('status', array());
|
|
if ($status) {
|
|
$query->withStatuses($status);
|
|
}
|
|
|
|
return $query;
|
|
}
|
|
|
|
public function buildSearchForm(
|
|
AphrontFormView $form,
|
|
PhabricatorSavedQuery $saved_query) {
|
|
|
|
$status = $saved_query->getParameter('status', array());
|
|
|
|
$form
|
|
->appendChild(
|
|
id(new AphrontFormCheckboxControl())
|
|
->setLabel('Status')
|
|
->addCheckbox(
|
|
'status[]',
|
|
HarbormasterBuildPlan::STATUS_ACTIVE,
|
|
pht('Active'),
|
|
in_array(HarbormasterBuildPlan::STATUS_ACTIVE, $status))
|
|
->addCheckbox(
|
|
'status[]',
|
|
HarbormasterBuildPlan::STATUS_DISABLED,
|
|
pht('Disabled'),
|
|
in_array(HarbormasterBuildPlan::STATUS_DISABLED, $status)));
|
|
|
|
}
|
|
|
|
protected function getURI($path) {
|
|
return '/harbormaster/plan/'.$path;
|
|
}
|
|
|
|
public function getBuiltinQueryNames() {
|
|
$names = array(
|
|
'active' => pht('Active Plans'),
|
|
'all' => pht('All Plans'),
|
|
);
|
|
|
|
return $names;
|
|
}
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
$query = $this->newSavedQuery();
|
|
$query->setQueryKey($query_key);
|
|
|
|
switch ($query_key) {
|
|
case 'active':
|
|
return $query->setParameter(
|
|
'status',
|
|
array(
|
|
HarbormasterBuildPlan::STATUS_ACTIVE,
|
|
));
|
|
case 'all':
|
|
return $query;
|
|
}
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
}
|
|
|
|
}
|