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:
@@ -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');
|
||||
Reference in New Issue
Block a user