Page MenuHomePhabricator

D10874.id.diff
No OneTemporary

D10874.id.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -798,6 +798,7 @@
'DrydockBlueprintCoreCustomField' => 'applications/drydock/customfield/DrydockBlueprintCoreCustomField.php',
'DrydockBlueprintCreateController' => 'applications/drydock/controller/DrydockBlueprintCreateController.php',
'DrydockBlueprintCustomField' => 'applications/drydock/customfield/DrydockBlueprintCustomField.php',
+ 'DrydockBlueprintDatasource' => 'applications/drydock/typeahead/DrydockBlueprintDatasource.php',
'DrydockBlueprintEditController' => 'applications/drydock/controller/DrydockBlueprintEditController.php',
'DrydockBlueprintEditor' => 'applications/drydock/editor/DrydockBlueprintEditor.php',
'DrydockBlueprintImplementation' => 'applications/drydock/blueprint/DrydockBlueprintImplementation.php',
@@ -822,6 +823,7 @@
'DrydockInterface' => 'applications/drydock/interface/DrydockInterface.php',
'DrydockLease' => 'applications/drydock/storage/DrydockLease.php',
'DrydockLeaseController' => 'applications/drydock/controller/DrydockLeaseController.php',
+ 'DrydockLeaseDatasource' => 'applications/drydock/typeahead/DrydockLeaseDatasource.php',
'DrydockLeaseListController' => 'applications/drydock/controller/DrydockLeaseListController.php',
'DrydockLeaseListView' => 'applications/drydock/view/DrydockLeaseListView.php',
'DrydockLeasePHIDType' => 'applications/drydock/phid/DrydockLeasePHIDType.php',
@@ -847,6 +849,7 @@
'DrydockResource' => 'applications/drydock/storage/DrydockResource.php',
'DrydockResourceCloseController' => 'applications/drydock/controller/DrydockResourceCloseController.php',
'DrydockResourceController' => 'applications/drydock/controller/DrydockResourceController.php',
+ 'DrydockResourceDatasource' => 'applications/drydock/typeahead/DrydockResourceDatasource.php',
'DrydockResourceListController' => 'applications/drydock/controller/DrydockResourceListController.php',
'DrydockResourceListView' => 'applications/drydock/view/DrydockResourceListView.php',
'DrydockResourcePHIDType' => 'applications/drydock/phid/DrydockResourcePHIDType.php',
@@ -4479,6 +4482,7 @@
),
'DrydockBlueprintCreateController' => 'DrydockBlueprintController',
'DrydockBlueprintCustomField' => 'PhabricatorCustomField',
+ 'DrydockBlueprintDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockBlueprintEditController' => 'DrydockBlueprintController',
'DrydockBlueprintEditor' => 'PhabricatorApplicationTransactionEditor',
'DrydockBlueprintImplementation' => 'Phobject',
@@ -4506,6 +4510,7 @@
'PhabricatorPolicyInterface',
),
'DrydockLeaseController' => 'DrydockController',
+ 'DrydockLeaseDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockLeaseListController' => 'DrydockLeaseController',
'DrydockLeaseListView' => 'AphrontView',
'DrydockLeasePHIDType' => 'PhabricatorPHIDType',
@@ -4537,6 +4542,7 @@
),
'DrydockResourceCloseController' => 'DrydockResourceController',
'DrydockResourceController' => 'DrydockController',
+ 'DrydockResourceDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockResourceListController' => 'DrydockResourceController',
'DrydockResourceListView' => 'AphrontView',
'DrydockResourcePHIDType' => 'PhabricatorPHIDType',
diff --git a/src/applications/drydock/phid/DrydockLeasePHIDType.php b/src/applications/drydock/phid/DrydockLeasePHIDType.php
--- a/src/applications/drydock/phid/DrydockLeasePHIDType.php
+++ b/src/applications/drydock/phid/DrydockLeasePHIDType.php
@@ -29,6 +29,9 @@
$lease = $objects[$phid];
$id = $lease->getID();
+ $handle->setName(pht(
+ 'Lease %d',
+ $id));
$handle->setURI("/drydock/lease/{$id}/");
}
}
diff --git a/src/applications/drydock/phid/DrydockResourcePHIDType.php b/src/applications/drydock/phid/DrydockResourcePHIDType.php
--- a/src/applications/drydock/phid/DrydockResourcePHIDType.php
+++ b/src/applications/drydock/phid/DrydockResourcePHIDType.php
@@ -29,6 +29,7 @@
$resource = $objects[$phid];
$id = $resource->getID();
+ $handle->setName($resource->getName());
$handle->setURI("/drydock/resource/{$id}/");
}
}
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
@@ -4,6 +4,7 @@
private $ids;
private $phids;
+ private $datasourceQuery;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -15,6 +16,11 @@
return $this;
}
+ public function withDatasourceQuery($query) {
+ $this->datasourceQuery = $query;
+ return $this;
+ }
+
protected function loadPage() {
$table = new DrydockBlueprint();
$conn_r = $table->establishConnection('r');
@@ -59,6 +65,13 @@
$this->phids);
}
+ if ($this->datasourceQuery) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'blueprintName LIKE %>',
+ $this->datasourceQuery);
+ }
+
return $this->formatWhereClause($where);
}
diff --git a/src/applications/drydock/query/DrydockLeaseQuery.php b/src/applications/drydock/query/DrydockLeaseQuery.php
--- a/src/applications/drydock/query/DrydockLeaseQuery.php
+++ b/src/applications/drydock/query/DrydockLeaseQuery.php
@@ -6,6 +6,7 @@
private $phids;
private $resourceIDs;
private $statuses;
+ private $datasourceQuery;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -31,6 +32,11 @@
return new DrydockLease();
}
+ public function withDatasourceQuery($query) {
+ $this->datasourceQuery = $query;
+ return $this;
+ }
+
protected function loadPage() {
return $this->loadStandardPage($this->newResultObject());
}
@@ -65,34 +71,41 @@
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
- if ($this->resourceIDs !== null) {
+ if ($this->resourceIDs) {
$where[] = qsprintf(
$conn,
'resourceID IN (%Ld)',
$this->resourceIDs);
}
- if ($this->ids !== null) {
+ if ($this->ids) {
$where[] = qsprintf(
$conn,
'id IN (%Ld)',
$this->ids);
}
- if ($this->phids !== null) {
+ if ($this->phids) {
$where[] = qsprintf(
$conn,
'phid IN (%Ls)',
$this->phids);
}
- if ($this->statuses !== null) {
+ if ($this->statuses) {
$where[] = qsprintf(
$conn,
'status IN (%Ld)',
$this->statuses);
}
+ if ($this->datasourceQuery) {
+ $where[] = qsprintf(
+ $conn,
+ 'id = %d',
+ (int)$this->datasourceQuery);
+ }
+
return $where;
}
diff --git a/src/applications/drydock/query/DrydockLogSearchEngine.php b/src/applications/drydock/query/DrydockLogSearchEngine.php
--- a/src/applications/drydock/query/DrydockLogSearchEngine.php
+++ b/src/applications/drydock/query/DrydockLogSearchEngine.php
@@ -11,16 +11,55 @@
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
- return new PhabricatorSavedQuery();
+ $query = new PhabricatorSavedQuery();
+
+ $query->setParameter(
+ 'resourcePHIDs',
+ $this->readListFromRequest($request, 'resources'));
+ $query->setParameter(
+ 'leasePHIDs',
+ $this->readListFromRequest($request, 'leases'));
+
+ return $query;
}
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
- return new DrydockLogQuery();
+
+ // TODO: Change logs to use PHIDs instead of IDs.
+ $resource_ids = id(new DrydockResourceQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withPHIDs($saved->getParameter('resourcePHIDs', array()))
+ ->execute();
+ $resource_ids = mpull($resource_ids, 'getID');
+ $lease_ids = id(new DrydockLeaseQuery())
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->withPHIDs($saved->getParameter('leasePHIDs', array()))
+ ->execute();
+ $lease_ids = mpull($lease_ids, 'getID');
+
+ return id(new DrydockLogQuery())
+ ->withResourceIDs($resource_ids)
+ ->withLeaseIDs($lease_ids);
}
public function buildSearchForm(
AphrontFormView $form,
- PhabricatorSavedQuery $saved) {}
+ PhabricatorSavedQuery $saved) {
+
+ $form
+ ->appendControl(
+ id(new AphrontFormTokenizerControl())
+ ->setDatasource(new DrydockResourceDatasource())
+ ->setName('resources')
+ ->setLabel(pht('Resources'))
+ ->setValue($saved->getParameter('resourcePHIDs', array())))
+ ->appendControl(
+ id(new AphrontFormTokenizerControl())
+ ->setDatasource(new DrydockLeaseDatasource())
+ ->setName('leases')
+ ->setLabel(pht('Leases'))
+ ->setValue($saved->getParameter('leasePHIDs', array())));
+ }
protected function getURI($path) {
return '/drydock/log/'.$path;
diff --git a/src/applications/drydock/query/DrydockResourceQuery.php b/src/applications/drydock/query/DrydockResourceQuery.php
--- a/src/applications/drydock/query/DrydockResourceQuery.php
+++ b/src/applications/drydock/query/DrydockResourceQuery.php
@@ -7,6 +7,7 @@
private $statuses;
private $types;
private $blueprintPHIDs;
+ private $datasourceQuery;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -33,6 +34,11 @@
return $this;
}
+ public function withDatasourceQuery($query) {
+ $this->datasourceQuery = $query;
+ return $this;
+ }
+
protected function loadPage() {
$table = new DrydockResource();
$conn_r = $table->establishConnection('r');
@@ -88,6 +94,13 @@
$this->blueprintPHIDs);
}
+ if ($this->datasourceQuery) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'name LIKE %>',
+ $this->datasourceQuery);
+ }
+
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
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
@@ -40,7 +40,7 @@
),
self::CONFIG_COLUMN_SCHEMA => array(
'className' => 'text255',
- 'blueprintName' => 'text255',
+ 'blueprintName' => 'sort255',
),
) + parent::getConfiguration();
}
diff --git a/src/applications/drydock/typeahead/DrydockBlueprintDatasource.php b/src/applications/drydock/typeahead/DrydockBlueprintDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/drydock/typeahead/DrydockBlueprintDatasource.php
@@ -0,0 +1,36 @@
+<?php
+
+final class DrydockBlueprintDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getPlaceholderText() {
+ return pht('Type a blueprint name...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorDrydockApplication';
+ }
+
+ public function loadResults() {
+ $viewer = $this->getViewer();
+ $raw_query = $this->getRawQuery();
+
+ $blueprints = id(new DrydockBlueprintQuery())
+ ->setViewer($viewer)
+ ->withDatasourceQuery($raw_query)
+ ->execute();
+
+ $handles = id(new PhabricatorHandleQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(mpull($blueprints, 'getPHID'))
+ ->execute();
+
+ $results = array();
+ foreach ($handles as $handle) {
+ $results[] = id(new PhabricatorTypeaheadResult())
+ ->setName($handle->getName())
+ ->setPHID($handle->getPHID());
+ }
+ return $results;
+ }
+}
diff --git a/src/applications/drydock/typeahead/DrydockLeaseDatasource.php b/src/applications/drydock/typeahead/DrydockLeaseDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/drydock/typeahead/DrydockLeaseDatasource.php
@@ -0,0 +1,36 @@
+<?php
+
+final class DrydockLeaseDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getPlaceholderText() {
+ return pht('Type a lease ID (exact match)...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorDrydockApplication';
+ }
+
+ public function loadResults() {
+ $viewer = $this->getViewer();
+ $raw_query = $this->getRawQuery();
+
+ $leases = id(new DrydockLeaseQuery())
+ ->setViewer($viewer)
+ ->withDatasourceQuery($raw_query)
+ ->execute();
+
+ $handles = id(new PhabricatorHandleQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(mpull($leases, 'getPHID'))
+ ->execute();
+
+ $results = array();
+ foreach ($handles as $handle) {
+ $results[] = id(new PhabricatorTypeaheadResult())
+ ->setName($handle->getName())
+ ->setPHID($handle->getPHID());
+ }
+ return $results;
+ }
+}
diff --git a/src/applications/drydock/typeahead/DrydockResourceDatasource.php b/src/applications/drydock/typeahead/DrydockResourceDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/drydock/typeahead/DrydockResourceDatasource.php
@@ -0,0 +1,36 @@
+<?php
+
+final class DrydockResourceDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getPlaceholderText() {
+ return pht('Type a resource name...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorDrydockApplication';
+ }
+
+ public function loadResults() {
+ $viewer = $this->getViewer();
+ $raw_query = $this->getRawQuery();
+
+ $resources = id(new DrydockResourceQuery())
+ ->setViewer($viewer)
+ ->withDatasourceQuery($raw_query)
+ ->execute();
+
+ $handles = id(new PhabricatorHandleQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(mpull($resources, 'getPHID'))
+ ->execute();
+
+ $results = array();
+ foreach ($handles as $handle) {
+ $results[] = id(new PhabricatorTypeaheadResult())
+ ->setName($handle->getName())
+ ->setPHID($handle->getPHID());
+ }
+ return $results;
+ }
+}
diff --git a/src/applications/drydock/view/DrydockLogListView.php b/src/applications/drydock/view/DrydockLogListView.php
--- a/src/applications/drydock/view/DrydockLogListView.php
+++ b/src/applications/drydock/view/DrydockLogListView.php
@@ -21,13 +21,18 @@
$resource_uri = '/drydock/resource/'.$log->getResourceID().'/';
$lease_uri = '/drydock/lease/'.$log->getLeaseID().'/';
+ $resource_name = $log->getResourceID();
+ if ($log->getResourceID() !== null) {
+ $resource_name = $log->getResource()->getName();
+ }
+
$rows[] = array(
phutil_tag(
'a',
array(
'href' => $resource_uri,
),
- $log->getResourceID()),
+ $resource_name),
phutil_tag(
'a',
array(

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 1, 8:50 PM (2 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6716413
Default Alt Text
D10874.id.diff (14 KB)

Event Timeline