2012-11-09 01:13:21 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DiffusionLintDetailsController extends DiffusionController {
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$limit = 500;
|
|
|
|
$offset = $this->getRequest()->getInt('offset', 0);
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
2012-11-10 02:45:19 +01:00
|
|
|
$branch = $drequest->loadBranch();
|
|
|
|
$messages = $this->loadLintMessages($branch, $limit, $offset);
|
2012-11-09 01:13:21 +01:00
|
|
|
$is_dir = (substr('/'.$drequest->getPath(), -1) == '/');
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($messages as $message) {
|
|
|
|
$path = hsprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$drequest->generateURI(array(
|
|
|
|
'action' => 'lint',
|
|
|
|
'path' => $message['path'],
|
|
|
|
)),
|
|
|
|
substr($message['path'], strlen($drequest->getPath()) + 1));
|
|
|
|
|
|
|
|
$line = hsprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$drequest->generateURI(array(
|
|
|
|
'action' => 'browse',
|
|
|
|
'path' => $message['path'],
|
|
|
|
'line' => $message['line'],
|
2012-11-10 02:45:19 +01:00
|
|
|
'commit' => $branch->getLintCommit(),
|
2012-11-09 01:13:21 +01:00
|
|
|
)),
|
|
|
|
$message['line']);
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
$path,
|
|
|
|
$line,
|
|
|
|
phutil_escape_html(ArcanistLintSeverity::getStringForSeverity(
|
|
|
|
$message['severity'])),
|
|
|
|
phutil_escape_html($message['name']),
|
|
|
|
phutil_escape_html($message['description']),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setHeaders(array(
|
|
|
|
'Path',
|
|
|
|
'Line',
|
|
|
|
'Severity',
|
|
|
|
'Name',
|
2012-11-10 02:45:19 +01:00
|
|
|
'Description',
|
2012-11-09 01:13:21 +01:00
|
|
|
))
|
2012-11-10 02:45:19 +01:00
|
|
|
->setColumnClasses(array('', 'n', '', '', ''))
|
|
|
|
->setColumnVisibility(array($is_dir));
|
2012-11-09 01:13:21 +01:00
|
|
|
|
|
|
|
$content = array();
|
|
|
|
|
|
|
|
$pager = id(new AphrontPagerView())
|
|
|
|
->setPageSize($limit)
|
|
|
|
->setOffset($offset)
|
|
|
|
->setHasMorePages(count($messages) >= $limit)
|
|
|
|
->setURI($this->getRequest()->getRequestURI(), 'offset');
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
$lint = $drequest->getLint();
|
|
|
|
$link = hsprintf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
$drequest->generateURI(array(
|
|
|
|
'action' => 'lint',
|
|
|
|
'lint' => null,
|
|
|
|
)),
|
|
|
|
pht('Switch to Grouped View'));
|
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
$content[] = id(new AphrontPanelView())
|
2012-11-10 02:45:19 +01:00
|
|
|
->setHeader(
|
|
|
|
($lint != '' ? phutil_escape_html($lint)." \xC2\xB7 " : '').
|
|
|
|
pht('%d Lint Message(s)', count($messages)))
|
|
|
|
->setCaption($link)
|
2012-11-09 01:13:21 +01:00
|
|
|
->appendChild($table)
|
|
|
|
->appendChild($pager);
|
|
|
|
|
|
|
|
$nav = $this->buildSideNav('lint', false);
|
|
|
|
$nav->appendChild($content);
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
$crumbs = $this->buildCrumbs(
|
|
|
|
array(
|
|
|
|
'branch' => true,
|
|
|
|
'path' => true,
|
|
|
|
'view' => 'lint',
|
|
|
|
));
|
|
|
|
$nav->setCrumbs($crumbs);
|
2012-11-09 01:13:21 +01:00
|
|
|
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
return $this->buildApplicationPage(
|
2012-11-09 01:13:21 +01:00
|
|
|
$nav,
|
|
|
|
array('title' => array(
|
|
|
|
'Lint',
|
|
|
|
$drequest->getRepository()->getCallsign(),
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
private function loadLintMessages(
|
|
|
|
PhabricatorRepositoryBranch $branch,
|
|
|
|
$limit,
|
|
|
|
$offset) {
|
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
if (!$branch) {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$conn = $branch->establishConnection('r');
|
|
|
|
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
$where = array(
|
|
|
|
qsprintf(
|
|
|
|
$conn,
|
|
|
|
'branchID = %d',
|
|
|
|
$branch->getID())
|
|
|
|
);
|
2012-11-09 01:13:21 +01:00
|
|
|
if ($drequest->getPath() != '') {
|
|
|
|
$is_dir = (substr($drequest->getPath(), -1) == '/');
|
2012-11-10 02:45:19 +01:00
|
|
|
$where[] = qsprintf(
|
2012-11-09 01:13:21 +01:00
|
|
|
$conn,
|
2012-11-10 02:45:19 +01:00
|
|
|
'path '.($is_dir ? 'LIKE %>' : '= %s'),
|
2012-11-09 01:13:21 +01:00
|
|
|
'/'.$drequest->getPath());
|
|
|
|
}
|
|
|
|
|
2012-11-10 02:45:19 +01:00
|
|
|
if ($drequest->getLint() != '') {
|
|
|
|
$where[] = qsprintf(
|
|
|
|
$conn,
|
|
|
|
'code = %s',
|
|
|
|
$drequest->getLint());
|
|
|
|
}
|
|
|
|
|
2012-11-09 01:13:21 +01:00
|
|
|
return queryfx_all(
|
|
|
|
$conn,
|
|
|
|
'SELECT *
|
|
|
|
FROM %T
|
upgrade diffusion to use modern header UI and fix a few quirks
Summary:
upgrades are CrumbsView, HeaderView, PropertyListView, and ActionListView. I had to modify CrumbsView stuff a bit to handle the "advanced" diffusion crumbs.
Quirks fixed include making file tree view show up in diffusion, the page not have extra space when the file tree is hidden, links no longer breaking once you visit files (since without the change the files always got "/" appended and thus 404'd), and a differential quirk where it read "next step:" and that colon is a no no,
Test Plan: played around in diffusion and differential
Reviewers: epriestley
Reviewed By: epriestley
CC: aran, Korvin, chad
Maniphest Tasks: T2048, T2178
Differential Revision: https://secure.phabricator.com/D4169
2012-12-13 02:50:42 +01:00
|
|
|
WHERE %Q
|
|
|
|
ORDER BY path, code, line LIMIT %d OFFSET %d',
|
2012-11-09 01:13:21 +01:00
|
|
|
PhabricatorRepository::TABLE_LINTMESSAGE,
|
2012-11-10 02:45:19 +01:00
|
|
|
implode(' AND ', $where),
|
2012-11-09 01:13:21 +01:00
|
|
|
$limit,
|
|
|
|
$offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|