2011-04-03 23:48:36 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
2012-01-10 20:21:49 +01:00
|
|
|
* Copyright 2012 Facebook, Inc.
|
2011-04-03 23:48:36 +02:00
|
|
|
*
|
|
|
|
* 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 PhabricatorOwnersDetailController extends PhabricatorOwnersController {
|
|
|
|
|
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
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$phids = array();
|
|
|
|
foreach ($paths as $path) {
|
|
|
|
$phids[$path->getRepositoryPHID()] = true;
|
|
|
|
}
|
|
|
|
foreach ($owners as $owner) {
|
|
|
|
$phids[$owner->getUserPHID()] = true;
|
|
|
|
}
|
|
|
|
$phids = array_keys($phids);
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
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',
|
|
|
|
);
|
|
|
|
|
Add Related Commits for Owners
Summary:
For each commit, find the affected packages, and provide a way to
search by package.
Test Plan:
create commits that touch and don't touch two packages, and verify
that they display correctly in all the UI pages.
Reviewers: epriestley, blair, nh, tuomaspelkonen
Reviewed By: epriestley
CC: benmathews, aran, epriestley, btrahan, jungejason, mpodobnik, prithvi
Maniphest Tasks: T83
Differential Revision: 1208
2011-12-14 09:53:25 +01:00
|
|
|
$rows[] = array(
|
|
|
|
'Related Commits',
|
|
|
|
phutil_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/owners/related/view/all/?phid='.$package->getPHID(),
|
|
|
|
),
|
|
|
|
phutil_escape_html('Related Commits'))
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$path_links = array();
|
|
|
|
foreach ($paths as $path) {
|
|
|
|
$callsign = $handles[$path->getRepositoryPHID()]->getName();
|
|
|
|
$repo = phutil_escape_html('r'.$callsign);
|
|
|
|
$path_link = phutil_render_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/diffusion/'.$callsign.'/browse/:'.$path->getPath(),
|
|
|
|
),
|
|
|
|
phutil_escape_html($path->getPath()));
|
|
|
|
$path_links[] = $repo.' '.$path_link;
|
|
|
|
}
|
|
|
|
$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(
|
|
|
|
phutil_render_tag(
|
|
|
|
'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
|
|
|
|
2011-04-03 23:48:36 +02:00
|
|
|
return $this->buildStandardPageResponse(
|
2012-01-10 20:21:49 +01:00
|
|
|
$panel,
|
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-01-10 20:21:49 +01:00
|
|
|
protected function getExtraPackageViews() {
|
|
|
|
$package = $this->package;
|
|
|
|
return array(
|
|
|
|
array('name' => 'Details',
|
|
|
|
'key' => 'package/'.$package->getID(),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-04-03 23:48:36 +02:00
|
|
|
}
|