Commit 63bfa5cc authored by epriestley's avatar epriestley
Browse files

Add "project.column.search" for querying workboard column information

Summary:
Ref T12074. Provide a basic but functional v3 API endpoint for reading workboard column information.

There is no equivalent to this in the UI yet, although there may be some day (perhaps adjacent to T5024).

Test Plan:
  - Queried for all columns.
  - Queried for columns on a particular board using `projectPHIDs`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12074

Differential Revision: https://secure.phabricator.com/D17157
parent ad3745c8
......@@ -3427,6 +3427,7 @@ phutil_register_library_map(array(
'PhabricatorProjectColumnPosition' => 'applications/project/storage/PhabricatorProjectColumnPosition.php',
'PhabricatorProjectColumnPositionQuery' => 'applications/project/query/PhabricatorProjectColumnPositionQuery.php',
'PhabricatorProjectColumnQuery' => 'applications/project/query/PhabricatorProjectColumnQuery.php',
'PhabricatorProjectColumnSearchEngine' => 'applications/project/query/PhabricatorProjectColumnSearchEngine.php',
'PhabricatorProjectColumnTransaction' => 'applications/project/storage/PhabricatorProjectColumnTransaction.php',
'PhabricatorProjectColumnTransactionEditor' => 'applications/project/editor/PhabricatorProjectColumnTransactionEditor.php',
'PhabricatorProjectColumnTransactionQuery' => 'applications/project/query/PhabricatorProjectColumnTransactionQuery.php',
......@@ -4454,6 +4455,7 @@ phutil_register_library_map(array(
'ProjectAddProjectsEmailCommand' => 'applications/project/command/ProjectAddProjectsEmailCommand.php',
'ProjectBoardTaskCard' => 'applications/project/view/ProjectBoardTaskCard.php',
'ProjectCanLockProjectsCapability' => 'applications/project/capability/ProjectCanLockProjectsCapability.php',
'ProjectColumnSearchConduitAPIMethod' => 'applications/project/conduit/ProjectColumnSearchConduitAPIMethod.php',
'ProjectConduitAPIMethod' => 'applications/project/conduit/ProjectConduitAPIMethod.php',
'ProjectCreateConduitAPIMethod' => 'applications/project/conduit/ProjectCreateConduitAPIMethod.php',
'ProjectCreateProjectsCapability' => 'applications/project/capability/ProjectCreateProjectsCapability.php',
......@@ -8565,6 +8567,7 @@ phutil_register_library_map(array(
'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface',
'PhabricatorExtendedPolicyInterface',
'PhabricatorConduitResultInterface',
),
'PhabricatorProjectColumnDetailController' => 'PhabricatorProjectBoardController',
'PhabricatorProjectColumnEditController' => 'PhabricatorProjectBoardController',
......@@ -8576,6 +8579,7 @@ phutil_register_library_map(array(
),
'PhabricatorProjectColumnPositionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorProjectColumnQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorProjectColumnSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorProjectColumnTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorProjectColumnTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorProjectColumnTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
......@@ -9849,6 +9853,7 @@ phutil_register_library_map(array(
'ProjectAddProjectsEmailCommand' => 'MetaMTAEmailTransactionCommand',
'ProjectBoardTaskCard' => 'Phobject',
'ProjectCanLockProjectsCapability' => 'PhabricatorPolicyCapability',
'ProjectColumnSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'ProjectConduitAPIMethod' => 'ConduitAPIMethod',
'ProjectCreateConduitAPIMethod' => 'ProjectConduitAPIMethod',
'ProjectCreateProjectsCapability' => 'PhabricatorPolicyCapability',
......
<?php
final class ProjectColumnSearchConduitAPIMethod
extends PhabricatorSearchEngineAPIMethod {
public function getAPIMethodName() {
return 'project.column.search';
}
public function newSearchEngine() {
return new PhabricatorProjectColumnSearchEngine();
}
public function getMethodSummary() {
return pht('Read information about workboard columns.');
}
}
<?php
final class PhabricatorProjectColumnSearchEngine
extends PhabricatorApplicationSearchEngine {
public function getResultTypeDescription() {
return pht('Workboard Columns');
}
public function getApplicationClassName() {
return 'PhabricatorProjectApplication';
}
public function newQuery() {
return new PhabricatorProjectColumnQuery();
}
protected function buildCustomSearchFields() {
return array(
id(new PhabricatorPHIDsSearchField())
->setLabel(pht('Projects'))
->setKey('projectPHIDs')
->setAliases(array('project', 'projects', 'projectPHID')),
);
}
protected function buildQueryFromParameters(array $map) {
$query = $this->newQuery();
if ($map['projectPHIDs']) {
$query->withProjectPHIDs($map['projectPHIDs']);
}
return $query;
}
protected function getURI($path) {
// NOTE: There's no way to query columns in the web UI, at least for
// the moment.
return null;
}
protected function getBuiltinQueryNames() {
$names = array();
$names['all'] = pht('All');
return $names;
}
public function buildSavedQueryFromBuiltin($query_key) {
$query = $this->newSavedQuery();
$query->setQueryKey($query_key);
switch ($query_key) {
case 'all':
return $query;
}
return parent::buildSavedQueryFromBuiltin($query_key);
}
protected function renderResultList(
array $projects,
PhabricatorSavedQuery $query,
array $handles) {
assert_instances_of($projects, 'PhabricatorProjectColumn');
$viewer = $this->requireViewer();
return null;
}
}
......@@ -6,7 +6,8 @@ final class PhabricatorProjectColumn
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface,
PhabricatorDestructibleInterface,
PhabricatorExtendedPolicyInterface {
PhabricatorExtendedPolicyInterface,
PhabricatorConduitResultInterface {
const STATUS_ACTIVE = 0;
const STATUS_HIDDEN = 1;
......@@ -183,6 +184,40 @@ final class PhabricatorProjectColumn
return sprintf('%s%012d', $group, $sequence);
}
/* -( PhabricatorConduitResultInterface )---------------------------------- */
public function getFieldSpecificationsForConduit() {
return array(
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('name')
->setType('string')
->setDescription(pht('The display name of the column.')),
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('project')
->setType('map<string, wild>')
->setDescription(pht('The project the column belongs to.')),
id(new PhabricatorConduitSearchFieldSpecification())
->setKey('proxyPHID')
->setType('phid?')
->setDescription(
pht(
'For columns that proxy another object (like a subproject or '.
'milestone), the PHID of the object they proxy.')),
);
}
public function getFieldValuesForConduit() {
return array(
'name' => $this->getDisplayName(),
'proxyPHID' => $this->getProxyPHID(),
'project' => $this->getProject()->getRefForConduit(),
);
}
public function getConduitSearchAttachments() {
return array();
}
public function getRefForConduit() {
return array(
'id' => (int)$this->getID(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment