2013-07-22 17:34:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorProjectSearchEngine
|
|
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
|
2014-06-12 22:22:20 +02:00
|
|
|
public function getResultTypeDescription() {
|
|
|
|
return pht('Projects');
|
|
|
|
}
|
|
|
|
|
2015-02-05 00:47:48 +01:00
|
|
|
public function getApplicationClassName() {
|
2014-07-23 02:03:09 +02:00
|
|
|
return 'PhabricatorProjectApplication';
|
2014-05-09 21:25:52 +02:00
|
|
|
}
|
|
|
|
|
2015-06-08 21:21:48 +02:00
|
|
|
public function newQuery() {
|
|
|
|
return id(new PhabricatorProjectQuery())
|
Lock milestone projects to an automatic color/icon
Summary:
Ref T10010.
Currently, milestone subproject have editable icons/colors, but I don't think this is likely to be used much (the expectation is that milestones will be common and homogenous, and it doesn't make much sense to pick different icons for "Sprint 32" vs "Sprint 33", I think).
Locking the icon and color lets us simplify the form, make milestones more distinct, and potentially reuse the color later for other things (e.g., active/future/past or on time / overdue or whatever else) or just give them a special color to make them more visible.
The best argument for retaining this that I can come up with is that certain milestones may be special (e.g., Sprint 19 is a major release?), but you can just name it "Sprint 19 (v3.0!)" or something, which seems pretty good for now.
Also don't show milestones on task browse/list view.
Test Plan: {F1048532}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T10010
Differential Revision: https://secure.phabricator.com/D14912
2015-12-30 12:35:51 +01:00
|
|
|
->needImages(true)
|
|
|
|
->withIsMilestone(false);
|
2014-02-10 23:31:34 +01:00
|
|
|
}
|
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
protected function buildCustomSearchFields() {
|
|
|
|
return array(
|
|
|
|
id(new PhabricatorSearchTextField())
|
|
|
|
->setLabel(pht('Name'))
|
|
|
|
->setKey('name'),
|
2015-07-06 14:52:04 +02:00
|
|
|
id(new PhabricatorUsersSearchField())
|
2015-06-08 21:20:16 +02:00
|
|
|
->setLabel(pht('Members'))
|
|
|
|
->setKey('memberPHIDs')
|
|
|
|
->setAliases(array('member', 'members')),
|
|
|
|
id(new PhabricatorSearchSelectField())
|
|
|
|
->setLabel(pht('Status'))
|
|
|
|
->setKey('status')
|
|
|
|
->setOptions($this->getStatusOptions()),
|
|
|
|
id(new PhabricatorSearchCheckboxesField())
|
|
|
|
->setLabel(pht('Icons'))
|
|
|
|
->setKey('icons')
|
|
|
|
->setOptions($this->getIconOptions()),
|
|
|
|
id(new PhabricatorSearchCheckboxesField())
|
|
|
|
->setLabel(pht('Colors'))
|
|
|
|
->setKey('colors')
|
|
|
|
->setOptions($this->getColorOptions()),
|
|
|
|
);
|
2013-07-22 17:34:35 +02:00
|
|
|
}
|
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
|
2015-06-08 23:09:58 +02:00
|
|
|
protected function buildQueryFromParameters(array $map) {
|
2015-06-08 21:21:48 +02:00
|
|
|
$query = $this->newQuery();
|
2013-07-22 17:34:35 +02:00
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
if (strlen($map['name'])) {
|
|
|
|
$tokens = PhabricatorTypeaheadDatasource::tokenizeString($map['name']);
|
2015-04-15 20:49:07 +02:00
|
|
|
$query->withNameTokens($tokens);
|
2014-07-18 01:35:54 +02:00
|
|
|
}
|
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
if ($map['memberPHIDs']) {
|
|
|
|
$query->withMemberPHIDs($map['memberPHIDs']);
|
2014-08-12 17:04:38 +02:00
|
|
|
}
|
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
if ($map['status']) {
|
|
|
|
$status = idx($this->getStatusValues(), $map['status']);
|
|
|
|
if ($status) {
|
|
|
|
$query->withStatus($status);
|
|
|
|
}
|
2014-08-12 17:04:38 +02:00
|
|
|
}
|
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
if ($map['icons']) {
|
|
|
|
$query->withIcons($map['icons']);
|
2014-08-12 17:04:38 +02:00
|
|
|
}
|
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
if ($map['colors']) {
|
|
|
|
$query->withColors($map['colors']);
|
2014-08-12 17:04:38 +02:00
|
|
|
}
|
2013-07-22 17:34:35 +02:00
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
return $query;
|
2013-07-22 17:34:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function getURI($path) {
|
|
|
|
return '/project/'.$path;
|
|
|
|
}
|
|
|
|
|
2015-01-06 21:34:51 +01:00
|
|
|
protected function getBuiltinQueryNames() {
|
2013-07-22 17:34:35 +02:00
|
|
|
$names = array();
|
|
|
|
|
|
|
|
if ($this->requireViewer()->isLoggedIn()) {
|
|
|
|
$names['joined'] = pht('Joined');
|
|
|
|
}
|
|
|
|
|
|
|
|
$names['active'] = pht('Active');
|
|
|
|
$names['all'] = pht('All');
|
|
|
|
|
|
|
|
return $names;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
$query = $this->newSavedQuery();
|
|
|
|
$query->setQueryKey($query_key);
|
|
|
|
|
|
|
|
$viewer_phid = $this->requireViewer()->getPHID();
|
|
|
|
|
|
|
|
switch ($query_key) {
|
|
|
|
case 'all':
|
|
|
|
return $query;
|
|
|
|
case 'active':
|
|
|
|
return $query
|
|
|
|
->setParameter('status', 'active');
|
|
|
|
case 'joined':
|
|
|
|
return $query
|
|
|
|
->setParameter('memberPHIDs', array($viewer_phid))
|
|
|
|
->setParameter('status', 'active');
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getStatusOptions() {
|
|
|
|
return array(
|
2015-05-01 01:06:59 +02:00
|
|
|
'active' => pht('Show Only Active Projects'),
|
|
|
|
'archived' => pht('Show Only Archived Projects'),
|
|
|
|
'all' => pht('Show All Projects'),
|
2013-07-22 17:34:35 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getStatusValues() {
|
|
|
|
return array(
|
2015-05-01 01:06:59 +02:00
|
|
|
'active' => PhabricatorProjectQuery::STATUS_ACTIVE,
|
|
|
|
'archived' => PhabricatorProjectQuery::STATUS_ARCHIVED,
|
|
|
|
'all' => PhabricatorProjectQuery::STATUS_ANY,
|
2013-07-22 17:34:35 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
private function getIconOptions() {
|
|
|
|
$options = array();
|
2014-08-12 17:04:38 +02:00
|
|
|
|
2015-12-16 16:53:13 +01:00
|
|
|
$set = new PhabricatorProjectIconSet();
|
|
|
|
foreach ($set->getIcons() as $icon) {
|
|
|
|
$options[$icon->getKey()] = array(
|
2015-06-08 21:20:16 +02:00
|
|
|
id(new PHUIIconView())
|
2015-12-16 16:53:13 +01:00
|
|
|
->setIconFont($icon->getIcon()),
|
2015-06-08 21:20:16 +02:00
|
|
|
' ',
|
2015-12-16 16:53:13 +01:00
|
|
|
$icon->getLabel(),
|
2015-06-08 21:20:16 +02:00
|
|
|
);
|
|
|
|
}
|
2014-08-12 17:04:38 +02:00
|
|
|
|
2015-06-08 21:20:16 +02:00
|
|
|
return $options;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getColorOptions() {
|
|
|
|
$options = array();
|
|
|
|
|
2015-12-16 16:53:13 +01:00
|
|
|
foreach (PhabricatorProjectIconSet::getColorMap() as $color => $name) {
|
2015-06-08 21:20:16 +02:00
|
|
|
$options[$color] = array(
|
|
|
|
id(new PHUITagView())
|
|
|
|
->setType(PHUITagView::TYPE_SHADE)
|
|
|
|
->setShade($color)
|
|
|
|
->setName($name),
|
|
|
|
' ',
|
|
|
|
$name,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $options;
|
2014-08-12 17:04:38 +02:00
|
|
|
}
|
|
|
|
|
2014-05-09 21:25:52 +02:00
|
|
|
protected function renderResultList(
|
|
|
|
array $projects,
|
|
|
|
PhabricatorSavedQuery $query,
|
|
|
|
array $handles) {
|
|
|
|
assert_instances_of($projects, 'PhabricatorProject');
|
|
|
|
$viewer = $this->requireViewer();
|
2015-06-19 12:46:20 +02:00
|
|
|
|
2015-12-27 14:16:36 +01:00
|
|
|
$list = id(new PhabricatorProjectListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setProjects($projects)
|
|
|
|
->renderList();
|
2015-06-19 12:46:20 +02:00
|
|
|
|
2015-12-27 14:16:36 +01:00
|
|
|
return id(new PhabricatorApplicationSearchResultView())
|
|
|
|
->setObjectList($list)
|
|
|
|
->setNoDataString(pht('No projects found.'));
|
2014-05-09 21:25:52 +02:00
|
|
|
}
|
|
|
|
|
2015-12-21 20:15:44 +01:00
|
|
|
protected function getNewUserBody() {
|
|
|
|
$create_button = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setText(pht('Create a Project'))
|
2015-12-31 14:57:12 +01:00
|
|
|
->setHref('/project/edit/')
|
2015-12-21 20:15:44 +01:00
|
|
|
->setColor(PHUIButtonView::GREEN);
|
|
|
|
|
|
|
|
$icon = $this->getApplication()->getFontIcon();
|
|
|
|
$app_name = $this->getApplication()->getName();
|
|
|
|
$view = id(new PHUIBigInfoView())
|
|
|
|
->setIcon($icon)
|
|
|
|
->setTitle(pht('Welcome to %s', $app_name))
|
|
|
|
->setDescription(
|
|
|
|
pht('Projects are flexible storage containers used as '.
|
|
|
|
'tags, teams, projects, or anything you need to group.'))
|
|
|
|
->addAction($create_button);
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-07-22 17:34:35 +02:00
|
|
|
}
|