2011-04-03 23:48:36 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class PhabricatorOwnersDetailController
|
|
|
|
extends PhabricatorOwnersController {
|
2011-04-03 23:48:36 +02:00
|
|
|
|
2011-04-04 04:20:47 +02:00
|
|
|
private $id;
|
2012-01-10 20:21:49 +01:00
|
|
|
private $package;
|
2011-04-04 04:20:47 +02:00
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
2011-04-04 07:03:27 +02:00
|
|
|
$this->id = $data['id'];
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-04-03 23:48:36 +02:00
|
|
|
public function processRequest() {
|
2011-04-04 04:20:47 +02:00
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$package = id(new PhabricatorOwnersPackage())->load($this->id);
|
|
|
|
if (!$package) {
|
|
|
|
return new Aphront404Response();
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
2012-01-10 20:21:49 +01:00
|
|
|
$this->package = $package;
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$paths = $package->loadPaths();
|
|
|
|
$owners = $package->loadOwners();
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2012-05-20 20:30:01 +02:00
|
|
|
$repository_phids = array();
|
2011-04-04 07:03:27 +02:00
|
|
|
foreach ($paths as $path) {
|
2012-05-20 20:30:01 +02:00
|
|
|
$repository_phids[$path->getRepositoryPHID()] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($repository_phids) {
|
|
|
|
$repositories = id(new PhabricatorRepository())->loadAllWhere(
|
|
|
|
'phid in (%Ls)',
|
|
|
|
array_keys($repository_phids));
|
|
|
|
$repositories = mpull($repositories, null, 'getPHID');
|
|
|
|
} else {
|
|
|
|
$repositories = array();
|
2011-04-04 07:03:27 +02:00
|
|
|
}
|
2012-05-20 20:30:01 +02:00
|
|
|
|
|
|
|
$phids = array();
|
2011-04-04 07:03:27 +02:00
|
|
|
foreach ($owners as $owner) {
|
|
|
|
$phids[$owner->getUserPHID()] = true;
|
|
|
|
}
|
|
|
|
$phids = array_keys($phids);
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$rows = array();
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$rows[] = array(
|
|
|
|
'Name',
|
|
|
|
phutil_escape_html($package->getName()));
|
|
|
|
$rows[] = array(
|
|
|
|
'Description',
|
|
|
|
phutil_escape_html($package->getDescription()));
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$primary_owner = null;
|
|
|
|
$primary_phid = $package->getPrimaryOwnerPHID();
|
|
|
|
if ($primary_phid && isset($handles[$primary_phid])) {
|
|
|
|
$primary_owner =
|
|
|
|
'<strong>'.$handles[$primary_phid]->renderLink().'</strong>';
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
2011-04-04 07:03:27 +02:00
|
|
|
$rows[] = array(
|
|
|
|
'Primary Owner',
|
|
|
|
$primary_owner,
|
|
|
|
);
|
|
|
|
|
|
|
|
$owner_links = array();
|
|
|
|
foreach ($owners as $owner) {
|
|
|
|
$owner_links[] = $handles[$owner->getUserPHID()]->renderLink();
|
|
|
|
}
|
|
|
|
$owner_links = implode('<br />', $owner_links);
|
|
|
|
$rows[] = array(
|
|
|
|
'Owners',
|
|
|
|
$owner_links);
|
|
|
|
|
Add Basic Auditing Functionalities
Summary:
add basic auditing functionalities. For the related commits for a
package, we detect the following conditions which might be suspicious to the
owners of the package:
* no revision specified
* revision not found
* author not match
* reviewedby not match
* owners not involved
* commit author not recognized
The owners of the package can change the status of the audit entries by
accepting it or specify concern.
The owner can turn on/off the auditing for a package.
Test Plan:
* verified that non-owner cannot see the details of the audit and cannot modify
it
* verified that all the audit reasons can be detected
* tested dropdown filtering and package search
* verified really normal change not detected
* verified accept/concern a commit
* tested enable/disable a package for auditing
* verified one audit applies to all <commit, packages> to the packages the
auditor owns
* verified that re-parsing a commit won't have effect if there exists a
relationship for <commit, package> already
Reviewers: epriestley, nh
Reviewed By: epriestley
CC: aran, benmathews, btrahan, mpodobnik, prithvi, TomL, epriestley
Differential Revision: 1242
2011-12-18 00:52:54 +01:00
|
|
|
$rows[] = array(
|
|
|
|
'Auditing',
|
|
|
|
$package->getAuditingEnabled() ? 'Enabled' : 'Disabled',
|
|
|
|
);
|
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$path_links = array();
|
|
|
|
foreach ($paths as $path) {
|
2013-01-16 00:38:05 +01:00
|
|
|
$repo = idx($repositories, $path->getRepositoryPHID());
|
2012-12-07 22:32:14 +01:00
|
|
|
if (!$repo) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-09-07 05:38:19 +02:00
|
|
|
$href = DiffusionRequest::generateDiffusionURI(
|
2012-05-20 20:30:01 +02:00
|
|
|
array(
|
2012-09-07 05:38:19 +02:00
|
|
|
'callsign' => $repo->getCallsign(),
|
2012-09-18 01:49:55 +02:00
|
|
|
'branch' => $repo->getDefaultBranch(),
|
|
|
|
'path' => $path->getPath(),
|
|
|
|
'action' => 'browse'
|
2012-05-20 20:30:01 +02:00
|
|
|
));
|
|
|
|
$repo_name = '<strong>'.phutil_escape_html($repo->getName()).
|
|
|
|
'</strong>';
|
2013-01-18 03:43:35 +01:00
|
|
|
$path_link = phutil_tag(
|
2011-04-04 07:03:27 +02:00
|
|
|
'a',
|
|
|
|
array(
|
2012-05-20 20:30:01 +02:00
|
|
|
'href' => (string) $href,
|
2011-04-04 07:03:27 +02:00
|
|
|
),
|
2013-01-18 03:43:35 +01:00
|
|
|
$path->getPath());
|
2012-12-07 02:23:56 +01:00
|
|
|
$path_links[] =
|
|
|
|
($path->getExcluded() ? '–' : '+').' '.
|
|
|
|
$repo_name.' '.$path_link;
|
2011-04-04 07:03:27 +02:00
|
|
|
}
|
|
|
|
$path_links = implode('<br />', $path_links);
|
|
|
|
$rows[] = array(
|
|
|
|
'Paths',
|
|
|
|
$path_links);
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setColumnClasses(
|
2011-04-04 04:20:47 +02:00
|
|
|
array(
|
2011-04-04 07:03:27 +02:00
|
|
|
'header',
|
|
|
|
'wide',
|
2011-04-04 04:20:47 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
2011-04-04 07:03:27 +02:00
|
|
|
$panel->setHeader(
|
|
|
|
'Package Details for "'.phutil_escape_html($package->getName()).'"');
|
|
|
|
$panel->addButton(
|
|
|
|
javelin_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/owners/delete/'.$package->getID().'/',
|
|
|
|
'class' => 'button grey',
|
|
|
|
'sigil' => 'workflow',
|
|
|
|
),
|
|
|
|
'Delete Package'));
|
|
|
|
$panel->addButton(
|
2013-01-18 03:57:09 +01:00
|
|
|
phutil_tag(
|
2011-04-04 07:03:27 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/owners/edit/'.$package->getID().'/',
|
|
|
|
'class' => 'button',
|
|
|
|
),
|
|
|
|
'Edit Package'));
|
|
|
|
$panel->appendChild($table);
|
|
|
|
|
2012-01-10 20:21:49 +01:00
|
|
|
$key = 'package/'.$package->getID();
|
|
|
|
$this->setSideNavFilter($key);
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2012-03-05 18:57:46 +01:00
|
|
|
$commit_views = array();
|
|
|
|
|
|
|
|
$commit_uri = id(new PhutilURI('/audit/view/packagecommits/'))
|
|
|
|
->setQueryParams(
|
|
|
|
array(
|
|
|
|
'phid' => $package->getPHID(),
|
|
|
|
));
|
|
|
|
|
|
|
|
$attention_query = id(new PhabricatorAuditCommitQuery())
|
|
|
|
->withPackagePHIDs(array($package->getPHID()))
|
|
|
|
->withStatus(PhabricatorAuditCommitQuery::STATUS_OPEN)
|
|
|
|
->needCommitData(true)
|
2012-10-03 01:44:29 +02:00
|
|
|
->needAudits(true)
|
2012-03-05 18:57:46 +01:00
|
|
|
->setLimit(10);
|
|
|
|
$attention_commits = $attention_query->execute();
|
|
|
|
if ($attention_commits) {
|
|
|
|
$view = new PhabricatorAuditCommitListView();
|
|
|
|
$view->setUser($user);
|
|
|
|
$view->setCommits($attention_commits);
|
|
|
|
|
|
|
|
$commit_views[] = array(
|
|
|
|
'view' => $view,
|
|
|
|
'header' => 'Commits in this Package that Need Attention',
|
2013-01-18 03:57:09 +01:00
|
|
|
'button' => phutil_tag(
|
2012-03-05 18:57:46 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $commit_uri->alter('status', 'open'),
|
|
|
|
'class' => 'button grey',
|
|
|
|
),
|
|
|
|
'View All Problem Commits'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$all_query = id(new PhabricatorAuditCommitQuery())
|
|
|
|
->withPackagePHIDs(array($package->getPHID()))
|
|
|
|
->needCommitData(true)
|
2012-10-03 01:44:29 +02:00
|
|
|
->needAudits(true)
|
2012-03-05 18:57:46 +01:00
|
|
|
->setLimit(100);
|
|
|
|
$all_commits = $all_query->execute();
|
|
|
|
|
|
|
|
$view = new PhabricatorAuditCommitListView();
|
|
|
|
$view->setUser($user);
|
|
|
|
$view->setCommits($all_commits);
|
|
|
|
$view->setNoDataString('No commits in this package.');
|
|
|
|
|
|
|
|
$commit_views[] = array(
|
|
|
|
'view' => $view,
|
|
|
|
'header' => 'Recent Commits in Package',
|
2013-01-18 03:57:09 +01:00
|
|
|
'button' => phutil_tag(
|
2012-03-05 18:57:46 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $commit_uri,
|
|
|
|
'class' => 'button grey',
|
|
|
|
),
|
|
|
|
'View All Package Commits'),
|
|
|
|
);
|
|
|
|
|
|
|
|
$phids = array();
|
|
|
|
foreach ($commit_views as $commit_view) {
|
|
|
|
$phids[] = $commit_view['view']->getRequiredHandlePHIDs();
|
|
|
|
}
|
|
|
|
$phids = array_mergev($phids);
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2012-03-05 18:57:46 +01:00
|
|
|
|
|
|
|
$commit_panels = array();
|
|
|
|
foreach ($commit_views as $commit_view) {
|
|
|
|
$commit_panel = new AphrontPanelView();
|
|
|
|
$commit_panel->setHeader(phutil_escape_html($commit_view['header']));
|
|
|
|
if (isset($commit_view['button'])) {
|
|
|
|
$commit_panel->addButton($commit_view['button']);
|
|
|
|
}
|
|
|
|
$commit_view['view']->setHandles($handles);
|
|
|
|
$commit_panel->appendChild($commit_view['view']);
|
|
|
|
|
|
|
|
$commit_panels[] = $commit_panel;
|
|
|
|
}
|
|
|
|
|
2011-04-03 23:48:36 +02:00
|
|
|
return $this->buildStandardPageResponse(
|
2012-03-05 18:57:46 +01:00
|
|
|
array(
|
|
|
|
$panel,
|
|
|
|
$commit_panels,
|
|
|
|
),
|
2011-04-03 23:48:36 +02:00
|
|
|
array(
|
2011-04-04 07:03:27 +02:00
|
|
|
'title' => "Package '".$package->getName()."'",
|
2011-04-03 23:48:36 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-12-07 22:32:14 +01:00
|
|
|
protected function getExtraPackageViews(AphrontSideNavFilterView $view) {
|
2012-01-10 20:21:49 +01:00
|
|
|
$package = $this->package;
|
2012-12-07 22:32:14 +01:00
|
|
|
$view->addFilter('package/'.$package->getID(), 'Details');
|
2012-01-10 20:21:49 +01:00
|
|
|
}
|
|
|
|
|
2011-04-03 23:48:36 +02:00
|
|
|
}
|