Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13968137
D16353.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D16353.id.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
@@ -1106,6 +1106,7 @@
'HarbormasterBuildEngine' => 'applications/harbormaster/engine/HarbormasterBuildEngine.php',
'HarbormasterBuildFailureException' => 'applications/harbormaster/exception/HarbormasterBuildFailureException.php',
'HarbormasterBuildGraph' => 'applications/harbormaster/engine/HarbormasterBuildGraph.php',
+ 'HarbormasterBuildInitiatorDatasource' => 'applications/harbormaster/typeahead/HarbormasterBuildInitiatorDatasource.php',
'HarbormasterBuildLintMessage' => 'applications/harbormaster/storage/build/HarbormasterBuildLintMessage.php',
'HarbormasterBuildListController' => 'applications/harbormaster/controller/HarbormasterBuildListController.php',
'HarbormasterBuildLog' => 'applications/harbormaster/storage/build/HarbormasterBuildLog.php',
@@ -1281,6 +1282,7 @@
'HeraldRepetitionPolicyConfig' => 'applications/herald/config/HeraldRepetitionPolicyConfig.php',
'HeraldRule' => 'applications/herald/storage/HeraldRule.php',
'HeraldRuleController' => 'applications/herald/controller/HeraldRuleController.php',
+ 'HeraldRuleDatasource' => 'applications/herald/typeahead/HeraldRuleDatasource.php',
'HeraldRuleEditor' => 'applications/herald/editor/HeraldRuleEditor.php',
'HeraldRuleListController' => 'applications/herald/controller/HeraldRuleListController.php',
'HeraldRulePHIDType' => 'applications/herald/phid/HeraldRulePHIDType.php',
@@ -5651,6 +5653,7 @@
'HarbormasterBuildEngine' => 'Phobject',
'HarbormasterBuildFailureException' => 'Exception',
'HarbormasterBuildGraph' => 'AbstractDirectedGraph',
+ 'HarbormasterBuildInitiatorDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'HarbormasterBuildLintMessage' => 'HarbormasterDAO',
'HarbormasterBuildListController' => 'HarbormasterController',
'HarbormasterBuildLog' => array(
@@ -5865,6 +5868,7 @@
'PhabricatorSubscribableInterface',
),
'HeraldRuleController' => 'HeraldController',
+ 'HeraldRuleDatasource' => 'PhabricatorTypeaheadDatasource',
'HeraldRuleEditor' => 'PhabricatorApplicationTransactionEditor',
'HeraldRuleListController' => 'HeraldController',
'HeraldRulePHIDType' => 'PhabricatorPHIDType',
diff --git a/src/applications/harbormaster/query/HarbormasterBuildQuery.php b/src/applications/harbormaster/query/HarbormasterBuildQuery.php
--- a/src/applications/harbormaster/query/HarbormasterBuildQuery.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildQuery.php
@@ -8,6 +8,7 @@
private $buildStatuses;
private $buildablePHIDs;
private $buildPlanPHIDs;
+ private $initiatorPHIDs;
private $needBuildTargets;
public function withIDs(array $ids) {
@@ -35,6 +36,11 @@
return $this;
}
+ public function withInitiatorPHIDs(array $initiator_phids) {
+ $this->initiatorPHIDs = $initiator_phids;
+ return $this;
+ }
+
public function needBuildTargets($need_targets) {
$this->needBuildTargets = $need_targets;
return $this;
@@ -167,6 +173,13 @@
$this->buildPlanPHIDs);
}
+ if ($this->initiatorPHIDs !== null) {
+ $where[] = qsprintf(
+ $conn,
+ 'initiatorPHID IN (%Ls)',
+ $this->initiatorPHIDs);
+ }
+
return $where;
}
diff --git a/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php
--- a/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php
+++ b/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php
@@ -31,6 +31,14 @@
->setDescription(
pht('Search for builds with given statuses.'))
->setDatasource(new HarbormasterBuildStatusDatasource()),
+ id(new PhabricatorSearchDatasourceField())
+ ->setLabel(pht('Initiators'))
+ ->setKey('initiators')
+ ->setAliases(array('initiator'))
+ ->setDescription(
+ pht(
+ 'Search for builds started by someone or something in particular.'))
+ ->setDatasource(new HarbormasterBuildInitiatorDatasource()),
);
}
@@ -45,6 +53,10 @@
$query->withBuildStatuses($map['statuses']);
}
+ if ($map['initiators']) {
+ $query->withInitiatorPHIDs($map['initiators']);
+ }
+
return $query;
}
@@ -54,6 +66,7 @@
protected function getBuiltinQueryNames() {
return array(
+ 'initiated' => pht('My Builds'),
'all' => pht('All Builds'),
'waiting' => pht('Waiting'),
'active' => pht('Active'),
@@ -66,6 +79,9 @@
$query->setQueryKey($query_key);
switch ($query_key) {
+ case 'initiated':
+ $viewer = $this->requireViewer();
+ return $query->setParameter('initiators', array($viewer->getPHID()));
case 'all':
return $query;
case 'waiting':
diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php
@@ -59,6 +59,9 @@
'columns' => array('buildablePHID', 'planAutoKey'),
'unique' => true,
),
+ 'key_initiator' => array(
+ 'columns' => array('initiatorPHID'),
+ ),
),
) + parent::getConfiguration();
}
diff --git a/src/applications/harbormaster/typeahead/HarbormasterBuildInitiatorDatasource.php b/src/applications/harbormaster/typeahead/HarbormasterBuildInitiatorDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/harbormaster/typeahead/HarbormasterBuildInitiatorDatasource.php
@@ -0,0 +1,22 @@
+<?php
+
+final class HarbormasterBuildInitiatorDatasource
+ extends PhabricatorTypeaheadCompositeDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Build Initiators');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type the name of a user, application or Herald rule...');
+ }
+
+ public function getComponentDatasources() {
+ return array(
+ new PhabricatorApplicationDatasource(),
+ new PhabricatorPeopleUserFunctionDatasource(),
+ new HeraldRuleDatasource(),
+ );
+ }
+
+}
diff --git a/src/applications/herald/query/HeraldRuleQuery.php b/src/applications/herald/query/HeraldRuleQuery.php
--- a/src/applications/herald/query/HeraldRuleQuery.php
+++ b/src/applications/herald/query/HeraldRuleQuery.php
@@ -8,6 +8,7 @@
private $ruleTypes;
private $contentTypes;
private $disabled;
+ private $datasourceQuery;
private $triggerObjectPHIDs;
private $needConditionsAndActions;
@@ -49,6 +50,11 @@
return $this;
}
+ public function withDatasourceQuery($query) {
+ $this->datasourceQuery = $query;
+ return $this;
+ }
+
public function withTriggerObjectPHIDs(array $phids) {
$this->triggerObjectPHIDs = $phids;
return $this;
@@ -219,6 +225,13 @@
(int)$this->disabled);
}
+ if ($this->datasourceQuery) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'rule.name LIKE %>',
+ $this->datasourceQuery);
+ }
+
if ($this->triggerObjectPHIDs) {
$where[] = qsprintf(
$conn_r,
diff --git a/src/applications/herald/storage/HeraldRule.php b/src/applications/herald/storage/HeraldRule.php
--- a/src/applications/herald/storage/HeraldRule.php
+++ b/src/applications/herald/storage/HeraldRule.php
@@ -34,7 +34,7 @@
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_COLUMN_SCHEMA => array(
- 'name' => 'text255',
+ 'name' => 'sort255',
'contentType' => 'text255',
'mustMatchAll' => 'bool',
'configVersion' => 'uint32',
@@ -47,6 +47,9 @@
'repetitionPolicy' => 'uint32?',
),
self::CONFIG_KEY_SCHEMA => array(
+ 'key_name' => array(
+ 'columns' => array('name(128)'),
+ ),
'key_author' => array(
'columns' => array('authorPHID'),
),
diff --git a/src/applications/herald/typeahead/HeraldRuleDatasource.php b/src/applications/herald/typeahead/HeraldRuleDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/herald/typeahead/HeraldRuleDatasource.php
@@ -0,0 +1,49 @@
+<?php
+
+final class HeraldRuleDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ public function getPlaceholderText() {
+ return pht('Type a Herald rule name...');
+ }
+
+ public function getBrowseTitle() {
+ return pht('Browse Herald Rules');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorHeraldApplication';
+ }
+
+ public function loadResults() {
+ $viewer = $this->getViewer();
+ $raw_query = $this->getRawQuery();
+
+ $rules = id(new HeraldRuleQuery())
+ ->setViewer($viewer)
+ ->withDatasourceQuery($raw_query)
+ ->execute();
+
+ $handles = id(new PhabricatorHandleQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(mpull($rules, 'getPHID'))
+ ->execute();
+
+ $results = array();
+ foreach ($rules as $rule) {
+ $handle = $handles[$rule->getPHID()];
+
+ $result = id(new PhabricatorTypeaheadResult())
+ ->setName($handle->getFullName())
+ ->setPHID($handle->getPHID());
+
+ if ($rule->getIsDisabled()) {
+ $result->setClosed(pht('Archived'));
+ }
+
+ $results[] = $result;
+ }
+
+ return $results;
+ }
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 17 2024, 6:51 PM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6723042
Default Alt Text
D16353.id.diff (9 KB)
Attached To
Mode
D16353: Search builds based on who kicked them off
Attached
Detach File
Event Timeline
Log In to Comment