Use ApplicationSearch in Differential
Summary:
Ref T603. Ref T2625. Fixes T3241. Depends on D5451. Depends on D6346.
@wez, this changes the Differential revision list UI substantially and may generate a lot of bikeshedding / who-moved-my-cheese churn. See T3417 for context, for example. The motivations for this change are:
- The list now works on devices, like phones and tablets. This is a requirement to make the rest of Differential work on devices.
- Although ApplicationSearch intentionally presents a simpler interface initially and some options which were one click away before aren't now, it is much more powerful than the search it replaces and allows users to build, save, share, fork, edit, and customize a much wider range of queries. Users who used the old filters frequently can use Advanced Search -> Save Custom Query to create new versions of them, and of any other query. "Edit Queries.." allows users to remove and reorder queries, including builtin queries. Basically, there are like three things which have gone from "1-click" to "a few clicks", and ten trillion things which have gone from "hard/impossible" to "relatively easy".
The local screenshots look a bit iffy, but I think a lot of this is the fakenesss of my test data. If they still feel iffy in production we can tweak them until they feel good, like we did for Maniphest.
Test Plan:
{F48477}
{F48478}
Reviewers: btrahan, chad, wez
Reviewed By: btrahan
CC: aran, s
Maniphest Tasks: T603, T2625, T3241
Differential Revision: https://secure.phabricator.com/D6347
This commit is contained in:
@@ -6,22 +6,6 @@ abstract class DifferentialController extends PhabricatorController {
|
||||
return PhabricatorEnv::getEnvConfig('differential.anonymous-access');
|
||||
}
|
||||
|
||||
public function buildStandardPageResponse($view, array $data) {
|
||||
|
||||
require_celerity_resource('differential-core-view-css');
|
||||
|
||||
$page = $this->buildStandardPageView();
|
||||
$page->setApplicationName(pht('Differential'));
|
||||
$page->setBaseURI('/differential/');
|
||||
$page->setTitle(idx($data, 'title'));
|
||||
$page->setGlyph("\xE2\x9A\x99");
|
||||
$page->appendChild($view);
|
||||
$page->setSearchDefaultScope(PhabricatorSearchScope::SCOPE_OPEN_REVISIONS);
|
||||
|
||||
$response = new AphrontWebpageResponse();
|
||||
return $response->setContent($page->render());
|
||||
}
|
||||
|
||||
public function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
@@ -34,65 +18,23 @@ abstract class DifferentialController extends PhabricatorController {
|
||||
return $crumbs;
|
||||
}
|
||||
|
||||
public function buildSideNav($filter = null,
|
||||
$for_app = false, $username = null) {
|
||||
public function buildSideNavView($for_app = false) {
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$viewer_is_anonymous = !$this->getRequest()->getUser()->isLoggedIn();
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
||||
|
||||
$uri = id(new PhutilURI('/differential/filter/'))
|
||||
->setQueryParams($this->getRequest()->getRequestURI()->getQueryParams());
|
||||
$filters = $this->getFilters();
|
||||
$filter = $this->selectFilter($filters, $filter, $viewer_is_anonymous);
|
||||
id(new DifferentialRevisionSearchEngine())
|
||||
->setViewer($viewer)
|
||||
->addNavigationItems($nav->getMenu());
|
||||
|
||||
$side_nav = new AphrontSideNavFilterView();
|
||||
$side_nav->setBaseURI($uri);
|
||||
foreach ($filters as $filter) {
|
||||
list($filter_name, $display_name) = $filter;
|
||||
if ($filter_name) {
|
||||
$side_nav->addFilter($filter_name.'/'.$username, $display_name);
|
||||
} else {
|
||||
$side_nav->addLabel($display_name);
|
||||
}
|
||||
}
|
||||
$nav->selectFilter(null);
|
||||
|
||||
return $side_nav;
|
||||
}
|
||||
|
||||
protected function getFilters() {
|
||||
return array(
|
||||
array(null, pht('User Revisions')),
|
||||
array('active', pht('Active')),
|
||||
array('revisions', pht('Revisions')),
|
||||
array('reviews', pht('Reviews')),
|
||||
array('subscribed', pht('Subscribed')),
|
||||
array('drafts', pht('Draft Reviews')),
|
||||
array(null, pht('All Revisions')),
|
||||
array('all', pht('All')),
|
||||
);
|
||||
}
|
||||
|
||||
protected function selectFilter(
|
||||
array $filters,
|
||||
$requested_filter,
|
||||
$viewer_is_anonymous) {
|
||||
|
||||
$default_filter = ($viewer_is_anonymous ? 'all' : 'active');
|
||||
|
||||
// If the user requested a filter, make sure it actually exists.
|
||||
if ($requested_filter) {
|
||||
foreach ($filters as $filter) {
|
||||
if ($filter[0] === $requested_filter) {
|
||||
return $requested_filter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If not, return the default filter.
|
||||
return $default_filter;
|
||||
return $nav;
|
||||
}
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
return $this->buildSideNav(null, true)->getMenu();
|
||||
return $this->buildSideNavView(true)->getMenu();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user