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) {
|
2013-09-26 01:54:48 +02:00
|
|
|
$repositories = id(new PhabricatorRepositoryQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withPHIDs(array_keys($repository_phids))
|
|
|
|
->execute();
|
2012-05-20 20:30:01 +02:00
|
|
|
$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
|
|
|
|
2013-05-22 00:31:24 +02:00
|
|
|
$rows[] = array(pht('Name'), $package->getName());
|
|
|
|
$rows[] = array(pht('Description'), $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])) {
|
2013-02-13 23:50:15 +01:00
|
|
|
$primary_owner = phutil_tag(
|
|
|
|
'strong',
|
|
|
|
array(),
|
|
|
|
$handles[$primary_phid]->renderLink());
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
2013-05-22 00:31:24 +02:00
|
|
|
$rows[] = array(pht('Primary Owner'), $primary_owner);
|
2011-04-04 07:03:27 +02:00
|
|
|
|
|
|
|
$owner_links = array();
|
|
|
|
foreach ($owners as $owner) {
|
|
|
|
$owner_links[] = $handles[$owner->getUserPHID()]->renderLink();
|
|
|
|
}
|
2013-02-13 23:50:15 +01:00
|
|
|
$owner_links = phutil_implode_html(phutil_tag('br'), $owner_links);
|
2013-05-22 00:31:24 +02:00
|
|
|
$rows[] = array(pht('Owners'), $owner_links);
|
2011-04-04 07:03:27 +02:00
|
|
|
|
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(
|
2013-05-22 00:31:24 +02:00
|
|
|
pht('Auditing'),
|
|
|
|
$package->getAuditingEnabled() ?
|
|
|
|
pht('Enabled') :
|
|
|
|
pht('Disabled'),
|
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
|
|
|
);
|
|
|
|
|
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(),
|
2014-10-07 15:01:04 +02:00
|
|
|
'action' => 'browse',
|
2012-05-20 20:30:01 +02:00
|
|
|
));
|
2013-02-08 21:07:44 +01:00
|
|
|
$repo_name = phutil_tag('strong', array(), $repo->getName());
|
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());
|
2013-02-13 23:50:15 +01:00
|
|
|
$path_links[] = hsprintf(
|
|
|
|
'%s %s %s',
|
|
|
|
($path->getExcluded() ? "\xE2\x80\x93" : '+'),
|
|
|
|
$repo_name,
|
|
|
|
$path_link);
|
2011-04-04 07:03:27 +02:00
|
|
|
}
|
2013-02-13 23:50:15 +01:00
|
|
|
$path_links = phutil_implode_html(phutil_tag('br'), $path_links);
|
2013-05-22 00:31:24 +02:00
|
|
|
$rows[] = array(pht('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
|
|
|
));
|
|
|
|
|
2015-03-03 22:51:28 +01:00
|
|
|
$panel = new PHUIObjectBoxView();
|
|
|
|
$header = new PHUIHeaderView();
|
|
|
|
$header->setHeader(
|
2013-05-22 00:31:24 +02:00
|
|
|
pht('Package Details for "%s"', $package->getName()));
|
2015-03-03 22:51:28 +01:00
|
|
|
$header->addActionLink(
|
|
|
|
id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setHref('/owners/delete/'.$package->getID().'/')
|
|
|
|
->addSigil('workflow')
|
|
|
|
->setText(pht('Delete Package')));
|
|
|
|
|
|
|
|
$header->addActionLink(
|
|
|
|
id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setHref('/owners/edit/'.$package->getID().'/')
|
|
|
|
->setText(pht('Edit Package')));
|
|
|
|
|
|
|
|
$panel->setHeader($header);
|
2011-04-04 07:03:27 +02:00
|
|
|
$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();
|
|
|
|
|
2014-11-08 01:45:59 +01:00
|
|
|
$commit_uri = id(new PhutilURI('/audit/'))
|
2012-03-05 18:57:46 +01:00
|
|
|
->setQueryParams(
|
|
|
|
array(
|
2014-11-08 01:45:59 +01:00
|
|
|
'auditorPHIDs' => $package->getPHID(),
|
2012-03-05 18:57:46 +01:00
|
|
|
));
|
|
|
|
|
2014-04-27 18:43:05 +02:00
|
|
|
$attention_commits = id(new DiffusionCommitQuery())
|
|
|
|
->setViewer($request->getUser())
|
|
|
|
->withAuditorPHIDs(array($package->getPHID()))
|
|
|
|
->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)
|
2012-03-05 18:57:46 +01:00
|
|
|
->needCommitData(true)
|
2014-04-27 18:43:05 +02:00
|
|
|
->setLimit(10)
|
|
|
|
->execute();
|
2012-03-05 18:57:46 +01:00
|
|
|
if ($attention_commits) {
|
2014-04-27 18:43:05 +02:00
|
|
|
$view = id(new PhabricatorAuditListView())
|
|
|
|
->setUser($user)
|
|
|
|
->setCommits($attention_commits);
|
2012-03-05 18:57:46 +01:00
|
|
|
|
|
|
|
$commit_views[] = array(
|
|
|
|
'view' => $view,
|
2013-05-22 00:31:24 +02:00
|
|
|
'header' => pht('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',
|
|
|
|
),
|
2013-05-22 00:31:24 +02:00
|
|
|
pht('View All Problem Commits')),
|
2012-03-05 18:57:46 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-04-27 18:43:05 +02:00
|
|
|
$all_commits = id(new DiffusionCommitQuery())
|
|
|
|
->setViewer($request->getUser())
|
|
|
|
->withAuditorPHIDs(array($package->getPHID()))
|
2012-03-05 18:57:46 +01:00
|
|
|
->needCommitData(true)
|
2014-04-27 18:43:05 +02:00
|
|
|
->setLimit(100)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorAuditListView())
|
|
|
|
->setUser($user)
|
|
|
|
->setCommits($all_commits)
|
|
|
|
->setNoDataString(pht('No commits in this package.'));
|
2012-03-05 18:57:46 +01:00
|
|
|
|
|
|
|
$commit_views[] = array(
|
|
|
|
'view' => $view,
|
2013-05-22 00:31:24 +02:00
|
|
|
'header' => pht('Recent Commits in Package'),
|
2015-03-03 22:51:28 +01:00
|
|
|
'button' => id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setHref($commit_uri)
|
|
|
|
->setText(pht('View All Package Commits')),
|
2012-03-05 18:57:46 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
$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) {
|
2015-03-03 22:51:28 +01:00
|
|
|
$commit_panel = new PHUIObjectBoxView();
|
|
|
|
$header = new PHUIHeaderView();
|
|
|
|
$header->setHeader($commit_view['header']);
|
2012-03-05 18:57:46 +01:00
|
|
|
if (isset($commit_view['button'])) {
|
2015-03-03 22:51:28 +01:00
|
|
|
$header->addActionLink($commit_view['button']);
|
2012-03-05 18:57:46 +01:00
|
|
|
}
|
|
|
|
$commit_view['view']->setHandles($handles);
|
2015-03-03 22:51:28 +01:00
|
|
|
$commit_panel->setHeader($header);
|
2012-03-05 18:57:46 +01:00
|
|
|
$commit_panel->appendChild($commit_view['view']);
|
|
|
|
|
|
|
|
$commit_panels[] = $commit_panel;
|
|
|
|
}
|
|
|
|
|
2015-03-03 22:51:28 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addTextCrumb($package->getName());
|
|
|
|
|
2013-05-22 00:31:24 +02:00
|
|
|
$nav = $this->buildSideNavView();
|
2015-03-03 22:51:28 +01:00
|
|
|
$nav->appendChild($crumbs);
|
2013-05-22 00:31:24 +02:00
|
|
|
$nav->appendChild($panel);
|
|
|
|
$nav->appendChild($commit_panels);
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
2015-03-03 22:51:28 +01:00
|
|
|
$nav,
|
2011-04-03 23:48:36 +02:00
|
|
|
array(
|
2014-06-09 20:36:49 +02:00
|
|
|
'title' => pht('Package %s', $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;
|
2013-05-22 00:31:24 +02:00
|
|
|
$view->addFilter('package/'.$package->getID(), pht('Details'));
|
2012-01-10 20:21:49 +01:00
|
|
|
}
|
|
|
|
|
2011-04-03 23:48:36 +02:00
|
|
|
}
|