Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15464962
D10874.id27535.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
17 KB
Referenced Files
None
Subscribers
None
D10874.id27535.diff
View Options
diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -7,7 +7,7 @@
*/
return array(
'names' => array(
- 'core.pkg.css' => '8d1c0f87',
+ 'core.pkg.css' => '083efd2e',
'core.pkg.js' => 'd60876a7',
'darkconsole.pkg.js' => '8ab24e01',
'differential.pkg.css' => '8af45893',
@@ -128,7 +128,7 @@
'rsrc/css/phui/phui-document.css' => 'bbeb1890',
'rsrc/css/phui/phui-feed-story.css' => '582f0ec9',
'rsrc/css/phui/phui-fontkit.css' => '9c3d2dce',
- 'rsrc/css/phui/phui-form-view.css' => 'aad06f2a',
+ 'rsrc/css/phui/phui-form-view.css' => '23088bec',
'rsrc/css/phui/phui-form.css' => '9aecbda1',
'rsrc/css/phui/phui-header-view.css' => '083669db',
'rsrc/css/phui/phui-icon.css' => 'a013a63d',
@@ -773,7 +773,7 @@
'phui-font-icon-base-css' => '3dad2ae3',
'phui-fontkit-css' => '9c3d2dce',
'phui-form-css' => '9aecbda1',
- 'phui-form-view-css' => 'aad06f2a',
+ 'phui-form-view-css' => '23088bec',
'phui-header-view-css' => '083669db',
'phui-icon-view-css' => 'a013a63d',
'phui-image-mask-css' => '5a8b09c8',
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
@@ -682,6 +682,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',
@@ -706,6 +707,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',
@@ -735,6 +737,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',
@@ -3788,6 +3791,7 @@
),
'DrydockBlueprintCreateController' => 'DrydockBlueprintController',
'DrydockBlueprintCustomField' => 'PhabricatorCustomField',
+ 'DrydockBlueprintDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockBlueprintEditController' => 'DrydockBlueprintController',
'DrydockBlueprintEditor' => 'PhabricatorApplicationTransactionEditor',
'DrydockBlueprintListController' => 'DrydockBlueprintController',
@@ -3811,6 +3815,7 @@
'PhabricatorPolicyInterface',
),
'DrydockLeaseController' => 'DrydockController',
+ 'DrydockLeaseDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockLeaseListController' => 'DrydockLeaseController',
'DrydockLeaseListView' => 'AphrontView',
'DrydockLeasePHIDType' => 'PhabricatorPHIDType',
@@ -3846,6 +3851,7 @@
),
'DrydockResourceCloseController' => 'DrydockResourceController',
'DrydockResourceController' => 'DrydockController',
+ 'DrydockResourceDatasource' => 'PhabricatorTypeaheadDatasource',
'DrydockResourceListController' => 'DrydockResourceController',
'DrydockResourceListView' => 'AphrontView',
'DrydockResourcePHIDType' => 'PhabricatorPHIDType',
diff --git a/src/applications/drydock/management/DrydockManagementSSHWorkflow.php b/src/applications/drydock/management/DrydockManagementSSHWorkflow.php
--- a/src/applications/drydock/management/DrydockManagementSSHWorkflow.php
+++ b/src/applications/drydock/management/DrydockManagementSSHWorkflow.php
@@ -3,7 +3,7 @@
final class DrydockManagementSSHWorkflow
extends DrydockManagementWorkflow {
- public function didConstruct() {
+ protected function didConstruct() {
$this
->setName('ssh')
->setSynopsis('Run a command on a remote host.')
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;
+ }
+
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;
@@ -27,6 +28,11 @@
return $this;
}
+ public function withDatasourceQuery($query) {
+ $this->datasourceQuery = $query;
+ return $this;
+ }
+
protected 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,78 @@
}
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.
+ $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;
+ }
+
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/storage/DrydockLease.php b/src/applications/drydock/storage/DrydockLease.php
--- a/src/applications/drydock/storage/DrydockLease.php
+++ b/src/applications/drydock/storage/DrydockLease.php
@@ -51,6 +51,7 @@
'taskID' => 'id?',
'ownerPHID' => 'phid?',
'resourceID' => 'id?',
+ 'brokenReason' => 'text?',
),
self::CONFIG_KEY_SCHEMA => array(
'key_phid' => null,
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
@@ -26,7 +26,7 @@
array(
'href' => $blueprint_uri,
),
- $blueprint_id);
+ $log->getBlueprint()->getBlueprintName());
} else {
$blueprint_tag = '';
}
@@ -38,7 +38,7 @@
array(
'href' => $resource_uri,
),
- $log->getResourceID());
+ $log->getResource()->getName());
} else {
$resource_tag = $log->getResourceID();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Apr 3, 1:12 PM (5 d, 17 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7492852
Default Alt Text
D10874.id27535.diff (17 KB)
Attached To
Mode
D10874: Improve Drydock log search engine
Attached
Detach File
Event Timeline
Log In to Comment