1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-04 20:52:43 +01:00
phorge-phorge/src/applications/owners/controller/PhabricatorOwnersDetailController.php

220 lines
6.2 KiB
PHP
Raw Normal View History

2011-04-03 23:48:36 +02:00
<?php
final class PhabricatorOwnersDetailController
extends PhabricatorOwnersController {
2011-04-03 23:48:36 +02:00
public function shouldAllowPublic() {
return true;
2011-04-04 04:20:47 +02:00
}
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
2011-04-04 04:20:47 +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();
$owners = $package->loadOwners();
2011-04-04 04:20:47 +02:00
$repository_phids = array();
2011-04-04 07:03:27 +02:00
foreach ($paths as $path) {
$repository_phids[$path->getRepositoryPHID()] = true;
}
if ($repository_phids) {
$repositories = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withPHIDs(array_keys($repository_phids))
->execute();
$repositories = mpull($repositories, null, 'getPHID');
} else {
$repositories = array();
2011-04-04 07:03:27 +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
$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
$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
}
$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);
$rows[] = array(pht('Owners'), $owner_links);
2011-04-04 07:03:27 +02:00
$rows[] = array(
pht('Auditing'),
$package->getAuditingEnabled() ?
pht('Enabled') :
pht('Disabled'),
);
2011-04-04 07:03:27 +02:00
$path_links = 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',
));
$repo_name = phutil_tag('strong', array(), $repo->getName());
$path_link = phutil_tag(
2011-04-04 07:03:27 +02:00
'a',
array(
'href' => (string)$href,
2011-04-04 07:03:27 +02: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);
$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
));
$panel = new PHUIObjectBoxView();
$header = new PHUIHeaderView();
$header->setHeader(
pht('Package Details for "%s"', $package->getName()));
$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);
$commit_views = array();
$commit_uri = id(new PhutilURI('/audit/'))
->setQueryParams(
array(
'auditorPHIDs' => $package->getPHID(),
));
$attention_commits = id(new DiffusionCommitQuery())
->setViewer($request->getUser())
->withAuditorPHIDs(array($package->getPHID()))
->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)
->needCommitData(true)
->setLimit(10)
->execute();
if ($attention_commits) {
$view = id(new PhabricatorAuditListView())
->setUser($viewer)
->setCommits($attention_commits);
$commit_views[] = array(
'view' => $view,
'header' => pht('Commits in this Package that Need Attention'),
'button' => id(new PHUIButtonView())
->setTag('a')
->setHref($commit_uri->alter('status', 'open'))
->setText(pht('View All Problem Commits')),
);
}
$all_commits = id(new DiffusionCommitQuery())
->setViewer($request->getUser())
->withAuditorPHIDs(array($package->getPHID()))
->needCommitData(true)
->setLimit(100)
->execute();
$view = id(new PhabricatorAuditListView())
->setUser($viewer)
->setCommits($all_commits)
->setNoDataString(pht('No commits in this package.'));
$commit_views[] = array(
'view' => $view,
'header' => pht('Recent Commits in Package'),
'button' => id(new PHUIButtonView())
->setTag('a')
->setHref($commit_uri)
->setText(pht('View All Package Commits')),
);
$phids = array();
foreach ($commit_views as $commit_view) {
$phids[] = $commit_view['view']->getRequiredHandlePHIDs();
}
$phids = array_mergev($phids);
$handles = $this->loadViewerHandles($phids);
$commit_panels = array();
foreach ($commit_views as $commit_view) {
$commit_panel = new PHUIObjectBoxView();
$header = new PHUIHeaderView();
$header->setHeader($commit_view['header']);
if (isset($commit_view['button'])) {
$header->addActionLink($commit_view['button']);
}
$commit_view['view']->setHandles($handles);
$commit_panel->setHeader($header);
$commit_panel->appendChild($commit_view['view']);
$commit_panels[] = $commit_panel;
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($package->getName());
return $this->buildApplicationPage(
array(
$crumbs,
$panel,
$commit_panels,
),
2011-04-03 23:48:36 +02:00
array(
'title' => pht('Package %s', $package->getName()),
2011-04-03 23:48:36 +02:00
));
}
}