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
|
|
|
|
2015-05-27 19:29:01 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
|
|
|
|
2015-05-27 19:29:01 +02:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2015-05-27 19:29:01 +02:00
|
|
|
$package = id(new PhabricatorOwnersPackageQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withIDs(array($request->getURIData('id')))
|
|
|
|
->executeOne();
|
2011-04-04 07:03:27 +02:00
|
|
|
if (!$package) {
|
|
|
|
return new Aphront404Response();
|
2011-04-04 04:20:47 +02:00
|
|
|
}
|
|
|
|
|
2011-04-04 07:03:27 +02:00
|
|
|
$paths = $package->loadPaths();
|
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())
|
2015-05-27 19:29:01 +02:00
|
|
|
->setViewer($viewer)
|
2013-09-26 01:54:48 +02:00
|
|
|
->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
|
|
|
|
2015-05-27 19:29:31 +02:00
|
|
|
$actions = $this->buildPackageActionView($package);
|
|
|
|
$properties = $this->buildPackagePropertyView($package);
|
|
|
|
$properties->setActionList($actions);
|
2011-04-04 04:20:47 +02:00
|
|
|
|
2015-05-27 19:29:31 +02:00
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setHeader($package->getName())
|
|
|
|
->setPolicyObject($package);
|
2015-03-03 22:51:28 +01:00
|
|
|
|
2015-05-27 19:29:31 +02:00
|
|
|
$panel = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
|
|
|
->addPropertyList($properties);
|
2011-04-04 07:03:27 +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())
|
2015-05-27 19:29:01 +02:00
|
|
|
->setUser($viewer)
|
2014-04-27 18:43:05 +02:00
|
|
|
->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'),
|
2015-03-18 15:08:50 +01:00
|
|
|
'button' => id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setHref($commit_uri->alter('status', 'open'))
|
|
|
|
->setText(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())
|
2015-05-27 19:29:01 +02:00
|
|
|
->setUser($viewer)
|
2014-04-27 18:43:05 +02:00
|
|
|
->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
|
|
|
return $this->buildApplicationPage(
|
2015-05-27 19:29:01 +02:00
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$panel,
|
2015-05-27 19:29:31 +02:00
|
|
|
$this->renderPathsTable($paths, $repositories),
|
2015-05-27 19:29:01 +02:00
|
|
|
$commit_panels,
|
|
|
|
),
|
2011-04-03 23:48:36 +02:00
|
|
|
array(
|
2015-05-27 19:29:31 +02:00
|
|
|
'title' => $package->getName(),
|
2011-04-03 23:48:36 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2015-05-27 19:29:31 +02:00
|
|
|
|
|
|
|
private function buildPackagePropertyView(PhabricatorOwnersPackage $package) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$primary_phid = $package->getPrimaryOwnerPHID();
|
|
|
|
if ($primary_phid) {
|
|
|
|
$primary_owner = $viewer->renderHandle($primary_phid);
|
|
|
|
} else {
|
|
|
|
$primary_owner = phutil_tag('em', array(), pht('None'));
|
|
|
|
}
|
|
|
|
$view->addProperty(pht('Primary Owner'), $primary_owner);
|
|
|
|
|
|
|
|
// TODO: needOwners() this on the Query.
|
|
|
|
$owners = $package->loadOwners();
|
|
|
|
if ($owners) {
|
|
|
|
$owner_list = $viewer->renderHandleList(mpull($owners, 'getUserPHID'));
|
|
|
|
} else {
|
|
|
|
$owner_list = phutil_tag('em', array(), pht('None'));
|
|
|
|
}
|
|
|
|
$view->addProperty(pht('Owners'), $owner_list);
|
|
|
|
|
|
|
|
if ($package->getAuditingEnabled()) {
|
|
|
|
$auditing = pht('Enabled');
|
|
|
|
} else {
|
|
|
|
$auditing = pht('Disabled');
|
|
|
|
}
|
|
|
|
$view->addProperty(pht('Auditing'), $auditing);
|
|
|
|
|
|
|
|
$description = $package->getDescription();
|
|
|
|
if (strlen($description)) {
|
|
|
|
$view->addSectionHeader(pht('Description'));
|
|
|
|
$view->addTextContent(
|
|
|
|
$output = PhabricatorMarkupEngine::renderOneObject(
|
|
|
|
id(new PhabricatorMarkupOneOff())->setContent($description),
|
|
|
|
'default',
|
|
|
|
$viewer));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPackageActionView(PhabricatorOwnersPackage $package) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
// TODO: Implement this capability.
|
|
|
|
$can_edit = true;
|
|
|
|
|
|
|
|
$id = $package->getID();
|
|
|
|
$edit_uri = $this->getApplicationURI("/edit/{$id}/");
|
|
|
|
$delete_uri = $this->getApplicationURI("/delete/{$id}/");
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setObject($package)
|
|
|
|
->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Edit Package'))
|
|
|
|
->setIcon('fa-pencil')
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(!$can_edit)
|
|
|
|
->setHref($edit_uri))
|
|
|
|
->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Delete Package'))
|
|
|
|
->setIcon('fa-times')
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
->setWorkflow(true)
|
|
|
|
->setHref($delete_uri));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderPathsTable(array $paths, array $repositories) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
foreach ($paths as $path) {
|
|
|
|
$repo = idx($repositories, $path->getRepositoryPHID());
|
|
|
|
if (!$repo) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$href = DiffusionRequest::generateDiffusionURI(
|
|
|
|
array(
|
|
|
|
'callsign' => $repo->getCallsign(),
|
|
|
|
'branch' => $repo->getDefaultBranch(),
|
|
|
|
'path' => $path->getPath(),
|
|
|
|
'action' => 'browse',
|
|
|
|
));
|
|
|
|
|
|
|
|
$path_link = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => (string)$href,
|
|
|
|
),
|
|
|
|
$path->getPath());
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
($path->getExcluded() ? '-' : '+'),
|
|
|
|
$repo->getName(),
|
|
|
|
$path_link,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setHeaders(
|
|
|
|
array(
|
|
|
|
null,
|
|
|
|
pht('Repository'),
|
|
|
|
pht('Path'),
|
|
|
|
))
|
|
|
|
->setColumnClasses(
|
|
|
|
array(
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
'wide',
|
|
|
|
));
|
|
|
|
|
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Paths'))
|
|
|
|
->appendChild($table);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-04-03 23:48:36 +02:00
|
|
|
}
|