mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Remove commit list from Diffusion in favor of Audit commit list
Summary: We can drive this query better from the Audit tool now; get rid of the Diffusion version. Preserve usernames in URIs as per T900. Test Plan: Clicked "Commits" from profile. Browsed audit commit filters. Reviewers: btrahan, jungejason Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T904 Differential Revision: https://secure.phabricator.com/D1713
This commit is contained in:
parent
f3549bb2d3
commit
1eeaeb62e4
5 changed files with 27 additions and 195 deletions
|
@ -286,10 +286,6 @@ class AphrontDefaultApplicationConfiguration
|
|||
'validate/$' => 'DiffusionPathValidateController',
|
||||
),
|
||||
),
|
||||
'author/' => array(
|
||||
'$' => 'DiffusionCommitListController',
|
||||
'(?P<username>\w+)/$' => 'DiffusionCommitListController',
|
||||
),
|
||||
'symbol/(?P<name>[^/]+)/$' => 'DiffusionSymbolController',
|
||||
),
|
||||
|
||||
|
@ -348,7 +344,8 @@ class AphrontDefaultApplicationConfiguration
|
|||
|
||||
'/audit/' => array(
|
||||
'$' => 'PhabricatorAuditListController',
|
||||
'view/(?P<filter>[^/]+)/$' => 'PhabricatorAuditListController',
|
||||
'view/(?P<filter>[^/]+)/(?:(?P<name>[^/]+)/)?$'
|
||||
=> 'PhabricatorAuditListController',
|
||||
'edit/$' => 'PhabricatorAuditEditController',
|
||||
'addcomment/$' => 'PhabricatorAuditAddCommentController',
|
||||
'preview/(?P<id>\d+)/$' => 'PhabricatorAuditPreviewController',
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||
|
||||
private $filter;
|
||||
private $name;
|
||||
private $filterStatus;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->filter = idx($data, 'filter');
|
||||
$this->name = idx($data, 'name');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
@ -33,10 +35,20 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
|||
// bookmarked.
|
||||
$uri = $request->getRequestURI();
|
||||
$phid = head($request->getArr('phid'));
|
||||
if ($phid) {
|
||||
$user = id(new PhabricatorUser())->loadOneWhere(
|
||||
'phid = %s',
|
||||
$phid);
|
||||
|
||||
$uri = $request->getRequestURI();
|
||||
if ($user) {
|
||||
$username = phutil_escape_uri($user->getUsername());
|
||||
$uri = '/audit/view/'.$this->filter.'/'.$username.'/';
|
||||
} else if ($phid) {
|
||||
$uri = $request->getRequestURI();
|
||||
$uri = $uri->alter('phid', $phid);
|
||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||
}
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($uri);
|
||||
}
|
||||
|
||||
$nav = $this->buildNavAndSelectFilter();
|
||||
|
@ -94,7 +106,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
|||
|
||||
$nav->addLabel('Commits');
|
||||
$nav->addFilter('commits', 'All');
|
||||
$nav->addFilter('author', 'By User');
|
||||
$nav->addFilter('author', 'By Author');
|
||||
$nav->addFilter('packagecommits', 'By Package');
|
||||
|
||||
$this->filter = $nav->selectFilter($this->filter, 'active');
|
||||
|
@ -140,7 +152,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
|||
|
||||
if ($show_user || $show_project || $show_package) {
|
||||
if ($show_user) {
|
||||
$uri = '/typeahead/common/user/';
|
||||
$uri = '/typeahead/common/users/';
|
||||
$label = 'User';
|
||||
} else if ($show_project) {
|
||||
$uri = '/typeahead/common/projects/';
|
||||
|
@ -198,6 +210,14 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
|||
case 'active':
|
||||
case 'author':
|
||||
$default = $request->getUser()->getPHID();
|
||||
if ($this->name) {
|
||||
$user = id(new PhabricatorUser())->loadOneWhere(
|
||||
'username = %s',
|
||||
$this->name);
|
||||
if ($user) {
|
||||
$default = $user->getPHID();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,152 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
class DiffusionCommitListController extends DiffusionController {
|
||||
|
||||
private $username;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
if (isset($data['username'])) {
|
||||
$this->username = $data['username'];
|
||||
}
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
if ($this->username) {
|
||||
$user = id(new PhabricatorUser())->loadOneWhere(
|
||||
'username = %s',
|
||||
$this->username);
|
||||
} else {
|
||||
$user = $request->getUser();
|
||||
}
|
||||
|
||||
$content = array();
|
||||
if (!$user) {
|
||||
$error_view = new AphrontErrorView();
|
||||
$error_view->setSeverity(AphrontErrorView::SEVERITY_ERROR);
|
||||
$error_body = 'User name '.
|
||||
'<b>'.phutil_escape_html($this->username).'</b>'.
|
||||
' doesn\'t exist.';
|
||||
|
||||
$error_view->setTitle("Error");
|
||||
$error_view->appendChild('<p>'.$error_body.'</p>');
|
||||
|
||||
$content[] = $error_view;
|
||||
} else {
|
||||
|
||||
$pager = new AphrontPagerView();
|
||||
$pager->setOffset($request->getInt('offset'));
|
||||
$pager->setURI($request->getRequestURI(), 'offset');
|
||||
|
||||
$query = new PhabricatorSearchQuery();
|
||||
$query->setParameter('type', PhabricatorPHIDConstants::PHID_TYPE_CMIT);
|
||||
$query->setParameter('author', array($user->getPHID()));
|
||||
$query->setParameter('limit', $pager->getPageSize() + 1);
|
||||
$query->setParameter('offset', $pager->getOffset());
|
||||
|
||||
$user_link = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/p/'.$user->getUsername().'/',
|
||||
),
|
||||
phutil_escape_html($user->getUsername()));
|
||||
|
||||
$engine = PhabricatorSearchEngineSelector::newSelector()->newEngine();
|
||||
$results = $engine->executeSearch($query);
|
||||
$results = $pager->sliceResults($results);
|
||||
$result_phids = ipull($results, 'phid');
|
||||
$commit_table = self::createCommitTable($result_phids, $user);
|
||||
|
||||
$list_panel = new AphrontPanelView();
|
||||
$list_panel->setHeader('Commits by '.$user_link);
|
||||
$list_panel->appendChild($commit_table);
|
||||
$list_panel->appendChild($pager);
|
||||
|
||||
$content[] = $list_panel;
|
||||
}
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$content,
|
||||
array(
|
||||
'title' => 'Commit List',
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param array $commit_phids phids of the commits to render
|
||||
* @param PhabricatorUser $user phabricator user
|
||||
* @return AphrontTableView
|
||||
*/
|
||||
private static function createCommitTable(
|
||||
array $commit_phids, PhabricatorUser $user) {
|
||||
|
||||
$loader = new PhabricatorObjectHandleData($commit_phids);
|
||||
$handles = $loader->loadHandles();
|
||||
$objects = $loader->loadObjects();
|
||||
|
||||
$rows = array();
|
||||
foreach ($commit_phids as $phid) {
|
||||
$handle = $handles[$phid];
|
||||
$object = $objects[$phid];
|
||||
|
||||
$summary = null;
|
||||
if ($object) {
|
||||
$commit_data = $object->getCommitData();
|
||||
if ($commit_data) {
|
||||
$summary = $commit_data->getSummary();
|
||||
}
|
||||
}
|
||||
|
||||
$epoch = $handle->getTimeStamp();
|
||||
$date = phabricator_date($epoch, $user);
|
||||
$time = phabricator_time($epoch, $user);
|
||||
$link = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $handle->getURI(),
|
||||
),
|
||||
phutil_escape_html($handle->getName()));
|
||||
$rows[] = array(
|
||||
$link,
|
||||
$date,
|
||||
$time,
|
||||
phutil_escape_html($summary),
|
||||
);
|
||||
}
|
||||
$commit_table = new AphrontTableView($rows);
|
||||
$commit_table->setHeaders(
|
||||
array(
|
||||
'Commit',
|
||||
'Date',
|
||||
'Time',
|
||||
'Summary',
|
||||
));
|
||||
$commit_table->setColumnClasses(
|
||||
array(
|
||||
'',
|
||||
'',
|
||||
'right',
|
||||
'wide',
|
||||
));
|
||||
|
||||
return $commit_table;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||
phutil_require_module('phabricator', 'applications/phid/constants');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
phutil_require_module('phabricator', 'applications/search/selector/base');
|
||||
phutil_require_module('phabricator', 'applications/search/storage/query');
|
||||
phutil_require_module('phabricator', 'view/control/pager');
|
||||
phutil_require_module('phabricator', 'view/control/table');
|
||||
phutil_require_module('phabricator', 'view/form/error');
|
||||
phutil_require_module('phabricator', 'view/layout/panel');
|
||||
phutil_require_module('phabricator', 'view/utils');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionCommitListController.php');
|
|
@ -68,7 +68,7 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
|
|||
$nav->addFilter(
|
||||
null,
|
||||
"Commits {$external_arrow}",
|
||||
'/diffusion/author/'.$user->getUserName().'/');
|
||||
'/audit/view/author/'.phutil_escape_uri($user->getUserName()).'/');
|
||||
|
||||
$oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere(
|
||||
'userID = %d',
|
||||
|
@ -160,14 +160,6 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
|
|||
|
||||
$engine = PhabricatorMarkupEngine::newProfileMarkupEngine();
|
||||
$blurb = $engine->markupText($blurb);
|
||||
$commit_list =
|
||||
phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/diffusion/author/'.
|
||||
phutil_escape_uri($user->getUsername()),
|
||||
),
|
||||
'Recent Commits');
|
||||
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
|
|
Loading…
Reference in a new issue