Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15196692
D10874.id26113.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
16 KB
Referenced Files
None
Subscribers
None
D10874.id26113.diff
View Options
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
@@ -653,6 +653,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',
@@ -677,6 +678,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',
@@ -706,6 +708,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',
@@ -3664,6 +3667,7 @@
),
'DrydockBlueprintCreateController' => 'DrydockBlueprintController',
'DrydockBlueprintCustomField' => 'PhabricatorCustomField',
+ 'DrydockBlueprintDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockBlueprintEditController' => 'DrydockBlueprintController',
'DrydockBlueprintEditor' => 'PhabricatorApplicationTransactionEditor',
'DrydockBlueprintListController' => 'DrydockBlueprintController',
@@ -3687,6 +3691,7 @@
'PhabricatorPolicyInterface',
),
'DrydockLeaseController' => 'DrydockController',
+ 'DrydockLeaseDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockLeaseListController' => 'DrydockLeaseController',
'DrydockLeaseListView' => 'AphrontView',
'DrydockLeasePHIDType' => 'PhabricatorPHIDType',
@@ -3722,6 +3727,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/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;
+ }
+
public 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;
@@ -27,6 +28,11 @@
return $this;
}
+ public function withDatasourceQuery($query) {
+ $this->datasourceQuery = $query;
+ return $this;
+ }
+
public function loadPage() {
$table = new DrydockLease();
$conn_r = $table->establishConnection('r');
@@ -100,6 +106,13 @@
$this->statuses);
}
+ if ($this->datasourceQuery) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'id = %d',
+ (int)$this->datasourceQuery);
+ }
+
$where[] = $this->buildPagingClause($conn_r);
return $this->formatWhereClause($where);
diff --git a/src/applications/drydock/query/DrydockLogQuery.php b/src/applications/drydock/query/DrydockLogQuery.php
--- a/src/applications/drydock/query/DrydockLogQuery.php
+++ b/src/applications/drydock/query/DrydockLogQuery.php
@@ -2,9 +2,15 @@
final class DrydockLogQuery extends DrydockQuery {
+ private $blueprintPHIDs;
private $resourceIDs;
private $leaseIDs;
+ public function withBlueprintPHIDs(array $phids) {
+ $this->blueprintPHIDs = $phids;
+ return $this;
+ }
+
public function withResourceIDs(array $ids) {
$this->resourceIDs = $ids;
return $this;
@@ -107,6 +113,13 @@
private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
$where = array();
+ if ($this->blueprintPHIDs) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'blueprintPHID IN (%Ls)',
+ $this->blueprintPHIDs);
+ }
+
if ($this->resourceIDs) {
$where[] = qsprintf(
$conn_r,
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,80 @@
}
public function buildSavedQueryFromRequest(AphrontRequest $request) {
- return new PhabricatorSavedQuery();
+ $query = new PhabricatorSavedQuery();
+
+ $query->setParameter(
+ 'blueprintPHIDs',
+ $this->readListFromRequest($request, 'blueprints'));
+ $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. I don't believe
+ // this violates any policies since the query already has the IDs
+ // and logs won't be returned if you can't see the resource / lease.
+ $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())
+ ->withBlueprintPHIDs($saved->getParameter('blueprintPHIDs', array()))
+ ->withResourceIDs($resource_ids)
+ ->withLeaseIDs($lease_ids);
}
public function buildSearchForm(
AphrontFormView $form,
- PhabricatorSavedQuery $saved) {}
+ PhabricatorSavedQuery $saved) {
+
+ $blueprint_handles = id(new PhabricatorHandleQuery())
+ ->setViewer($this->requireViewer())
+ ->withPHIDs($saved->getParameter('blueprintPHIDs', array()))
+ ->execute();
+ $resource_handles = id(new PhabricatorHandleQuery())
+ ->setViewer($this->requireViewer())
+ ->withPHIDs($saved->getParameter('resourcePHIDs', array()))
+ ->execute();
+ $lease_handles = id(new PhabricatorHandleQuery())
+ ->setViewer($this->requireViewer())
+ ->withPHIDs($saved->getParameter('leasePHIDs', array()))
+ ->execute();
+
+ $form
+ ->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setDatasource(new DrydockBlueprintDatasource())
+ ->setName('blueprints')
+ ->setLabel(pht('Blueprints'))
+ ->setValue($blueprint_handles))
+ ->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setDatasource(new DrydockResourceDatasource())
+ ->setName('resources')
+ ->setLabel(pht('Resources'))
+ ->setValue($resource_handles))
+ ->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setDatasource(new DrydockLeaseDatasource())
+ ->setName('leases')
+ ->setLabel(pht('Leases'))
+ ->setValue($lease_handles));
+ }
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;
+ }
+
public 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
@@ -39,7 +39,7 @@
),
self::CONFIG_COLUMN_SCHEMA => array(
'className' => 'text255',
- 'blueprintName' => 'text255',
+ 'blueprintName' => 'sort',
),
) + 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
@@ -18,13 +18,14 @@
$rows = array();
foreach ($logs as $log) {
- $blueprint_id = null;
+ $blueprint_uri = null;
+ $blueprint_name = null;
if ($log->getBlueprintPHID() !== null) {
- $blueprint_id = $log->getBlueprint()->getID();
+ $blueprint_uri =
+ '/drydock/blueprint/'.$log->getBlueprint()->getID().'/';
+ $blueprint_name = $log->getBlueprint()->getBlueprintName();
}
- $blueprint_uri = '/drydock/blueprint/'.$blueprint_id.'/';
-
if ($log->getResource()) {
$resource_uri = '/drydock/resource/'.$log->getResourceID().'/';
$resource_tag = phutil_tag(
@@ -32,7 +33,7 @@
array(
'href' => $resource_uri,
),
- $log->getResourceID());
+ $log->getResource()->getName());
} else {
$resource_tag = $log->getResourceID();
}
@@ -55,7 +56,7 @@
array(
'href' => $blueprint_uri,
),
- $blueprint_id),
+ $blueprint_name),
$resource_tag,
$lease_tag,
$log->getMessage(),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 23, 6:43 PM (2 h, 54 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7187435
Default Alt Text
D10874.id26113.diff (16 KB)
Attached To
Mode
D10874: Improve Drydock log search engine
Attached
Detach File
Event Timeline
Log In to Comment