Page MenuHomePhabricator

D14155.diff
No OneTemporary

D14155.diff

diff --git a/src/applications/drydock/constants/DrydockLeaseStatus.php b/src/applications/drydock/constants/DrydockLeaseStatus.php
--- a/src/applications/drydock/constants/DrydockLeaseStatus.php
+++ b/src/applications/drydock/constants/DrydockLeaseStatus.php
@@ -9,8 +9,8 @@
const STATUS_BROKEN = 'broken';
const STATUS_DESTROYED = 'destroyed';
- public static function getNameForStatus($status) {
- $map = array(
+ public static function getStatusMap() {
+ return array(
self::STATUS_PENDING => pht('Pending'),
self::STATUS_ACQUIRED => pht('Acquired'),
self::STATUS_ACTIVE => pht('Active'),
@@ -18,19 +18,15 @@
self::STATUS_BROKEN => pht('Broken'),
self::STATUS_DESTROYED => pht('Destroyed'),
);
+ }
+ public static function getNameForStatus($status) {
+ $map = self::getStatusMap();
return idx($map, $status, pht('Unknown'));
}
public static function getAllStatuses() {
- return array(
- self::STATUS_PENDING,
- self::STATUS_ACQUIRED,
- self::STATUS_ACTIVE,
- self::STATUS_RELEASED,
- self::STATUS_BROKEN,
- self::STATUS_DESTROYED,
- );
+ return array_keys(self::getStatusMap());
}
}
diff --git a/src/applications/drydock/constants/DrydockResourceStatus.php b/src/applications/drydock/constants/DrydockResourceStatus.php
--- a/src/applications/drydock/constants/DrydockResourceStatus.php
+++ b/src/applications/drydock/constants/DrydockResourceStatus.php
@@ -8,26 +8,23 @@
const STATUS_BROKEN = 'broken';
const STATUS_DESTROYED = 'destroyed';
- public static function getNameForStatus($status) {
- $map = array(
+ public static function getStatusMap() {
+ return array(
self::STATUS_PENDING => pht('Pending'),
self::STATUS_ACTIVE => pht('Active'),
self::STATUS_RELEASED => pht('Released'),
self::STATUS_BROKEN => pht('Broken'),
self::STATUS_DESTROYED => pht('Destroyed'),
);
+ }
+ public static function getNameForStatus($status) {
+ $map = self::getStatusMap();
return idx($map, $status, pht('Unknown'));
}
public static function getAllStatuses() {
- return array(
- self::STATUS_PENDING,
- self::STATUS_ACTIVE,
- self::STATUS_RELEASED,
- self::STATUS_BROKEN,
- self::STATUS_DESTROYED,
- );
+ return array_keys(self::getStatusMap());
}
}
diff --git a/src/applications/drydock/customfield/DrydockBlueprintCoreCustomField.php b/src/applications/drydock/customfield/DrydockBlueprintCoreCustomField.php
--- a/src/applications/drydock/customfield/DrydockBlueprintCoreCustomField.php
+++ b/src/applications/drydock/customfield/DrydockBlueprintCoreCustomField.php
@@ -9,6 +9,12 @@
}
public function createFields($object) {
+ // If this is a generic object without an attached implementation (for
+ // example, via ApplicationSearch), just don't build any custom fields.
+ if (!$object->hasImplementation()) {
+ return array();
+ }
+
$impl = $object->getImplementation();
$specs = $impl->getFieldSpecifications();
diff --git a/src/applications/drydock/query/DrydockBlueprintQuery.php b/src/applications/drydock/query/DrydockBlueprintQuery.php
--- a/src/applications/drydock/query/DrydockBlueprintQuery.php
+++ b/src/applications/drydock/query/DrydockBlueprintQuery.php
@@ -85,21 +85,4 @@
return $where;
}
- public function getOrderableColumns() {
- // TODO: Blueprints implement CustomFields, but can not be ordered by
- // custom field classes because the custom fields are not global. There
- // is no graceful way to handle this in ApplicationSearch at the moment.
- // Just brute force around it until we can clean this up.
-
- return array(
- 'id' => array(
- 'table' => $this->getPrimaryTableAlias(),
- 'column' => 'id',
- 'reverse' => false,
- 'type' => 'int',
- 'unique' => true,
- ),
- );
- }
-
}
diff --git a/src/applications/drydock/query/DrydockBlueprintSearchEngine.php b/src/applications/drydock/query/DrydockBlueprintSearchEngine.php
--- a/src/applications/drydock/query/DrydockBlueprintSearchEngine.php
+++ b/src/applications/drydock/query/DrydockBlueprintSearchEngine.php
@@ -11,17 +11,19 @@
return 'PhabricatorDrydockApplication';
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- return new PhabricatorSavedQuery();
+ public function newQuery() {
+ return id(new DrydockBlueprintQuery());
}
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- return new DrydockBlueprintQuery();
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
+
+ return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved) {}
+ protected function buildCustomSearchFields() {
+ return array();
+ }
protected function getURI($path) {
return '/drydock/blueprint/'.$path;
diff --git a/src/applications/drydock/query/DrydockLeaseSearchEngine.php b/src/applications/drydock/query/DrydockLeaseSearchEngine.php
--- a/src/applications/drydock/query/DrydockLeaseSearchEngine.php
+++ b/src/applications/drydock/query/DrydockLeaseSearchEngine.php
@@ -11,46 +11,27 @@
return 'PhabricatorDrydockApplication';
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
-
- $saved->setParameter(
- 'statuses',
- $this->readListFromRequest($request, 'statuses'));
-
- return $saved;
+ public function newQuery() {
+ return new DrydockLeaseQuery();
}
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- $query = id(new DrydockLeaseQuery());
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
- $statuses = $saved->getParameter('statuses', array());
- if ($statuses) {
- $query->withStatuses($statuses);
+ if ($map['statuses']) {
+ $query->withStatuses($map['statuses']);
}
return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved) {
-
- $statuses = $saved->getParameter('statuses', array());
-
- $status_control = id(new AphrontFormCheckboxControl())
- ->setLabel(pht('Status'));
- foreach (DrydockLeaseStatus::getAllStatuses() as $status) {
- $status_control->addCheckbox(
- 'statuses[]',
- $status,
- DrydockLeaseStatus::getNameForStatus($status),
- in_array($status, $statuses));
- }
-
- $form
- ->appendChild($status_control);
-
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorSearchCheckboxesField())
+ ->setLabel(pht('Statuses'))
+ ->setKey('statuses')
+ ->setOptions(DrydockLeaseStatus::getStatusMap()),
+ );
}
protected function getURI($path) {
diff --git a/src/applications/drydock/query/DrydockResourceSearchEngine.php b/src/applications/drydock/query/DrydockResourceSearchEngine.php
--- a/src/applications/drydock/query/DrydockResourceSearchEngine.php
+++ b/src/applications/drydock/query/DrydockResourceSearchEngine.php
@@ -11,45 +11,27 @@
return 'PhabricatorDrydockApplication';
}
- public function buildSavedQueryFromRequest(AphrontRequest $request) {
- $saved = new PhabricatorSavedQuery();
-
- $saved->setParameter(
- 'statuses',
- $this->readListFromRequest($request, 'statuses'));
-
- return $saved;
+ public function newQuery() {
+ return new DrydockResourceQuery();
}
- public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- $query = id(new DrydockResourceQuery());
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
- $statuses = $saved->getParameter('statuses', array());
- if ($statuses) {
- $query->withStatuses($statuses);
+ if ($map['statuses']) {
+ $query->withStatuses($map['statuses']);
}
return $query;
}
- public function buildSearchForm(
- AphrontFormView $form,
- PhabricatorSavedQuery $saved) {
-
- $statuses = $saved->getParameter('statuses', array());
-
- $status_control = id(new AphrontFormCheckboxControl())
- ->setLabel(pht('Status'));
- foreach (DrydockResourceStatus::getAllStatuses() as $status) {
- $status_control->addCheckbox(
- 'statuses[]',
- $status,
- DrydockResourceStatus::getNameForStatus($status),
- in_array($status, $statuses));
- }
-
- $form
- ->appendChild($status_control);
+ protected function buildCustomSearchFields() {
+ return array(
+ id(new PhabricatorSearchCheckboxesField())
+ ->setLabel(pht('Statuses'))
+ ->setKey('statuses')
+ ->setOptions(DrydockResourceStatus::getStatusMap()),
+ );
}
protected function getURI($path) {
diff --git a/src/applications/drydock/storage/DrydockBlueprint.php b/src/applications/drydock/storage/DrydockBlueprint.php
--- a/src/applications/drydock/storage/DrydockBlueprint.php
+++ b/src/applications/drydock/storage/DrydockBlueprint.php
@@ -64,6 +64,10 @@
return $this;
}
+ public function hasImplementation() {
+ return ($this->implementation !== self::ATTACHABLE);
+ }
+
public function getDetail($key, $default = null) {
return idx($this->details, $key, $default);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 9:21 AM (16 h, 21 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6913403
Default Alt Text
D14155.diff (9 KB)

Event Timeline