mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 04:02:43 +01:00
6010e80e5c
Summary: Fixes T8004. - For paths which are part of a package, show the package. - Highlight paths which are part of a package you (the viewer) have authority over. Test Plan: {F725418} - Viewed owned and unowned chagnes in Diffusion and Differential. Reviewers: chad Reviewed By: chad Maniphest Tasks: T8004 Differential Revision: https://secure.phabricator.com/D13923
95 lines
2.6 KiB
PHP
95 lines
2.6 KiB
PHP
<?php
|
|
|
|
abstract class DifferentialController extends PhabricatorController {
|
|
|
|
public function buildSideNavView($for_app = false) {
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
$nav = new AphrontSideNavFilterView();
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
|
|
|
|
id(new DifferentialRevisionSearchEngine())
|
|
->setViewer($viewer)
|
|
->addNavigationItems($nav->getMenu());
|
|
|
|
$nav->selectFilter(null);
|
|
|
|
return $nav;
|
|
}
|
|
|
|
public function buildApplicationMenu() {
|
|
return $this->buildSideNavView(true)->getMenu();
|
|
}
|
|
|
|
protected function buildTableOfContents(
|
|
array $changesets,
|
|
array $visible_changesets,
|
|
array $coverage) {
|
|
$viewer = $this->getViewer();
|
|
|
|
$toc_view = id(new PHUIDiffTableOfContentsListView())
|
|
->setUser($viewer);
|
|
|
|
$have_owners = PhabricatorApplication::isClassInstalledForViewer(
|
|
'PhabricatorOwnersApplication',
|
|
$viewer);
|
|
if ($have_owners) {
|
|
$repository_phid = null;
|
|
if ($changesets) {
|
|
$changeset = head($changesets);
|
|
$diff = $changeset->getDiff();
|
|
$repository_phid = $diff->getRepositoryPHID();
|
|
}
|
|
|
|
if (!$repository_phid) {
|
|
$have_owners = false;
|
|
} else {
|
|
if ($viewer->getPHID()) {
|
|
$packages = id(new PhabricatorOwnersPackageQuery())
|
|
->setViewer($viewer)
|
|
->withAuthorityPHIDs(array($viewer->getPHID()))
|
|
->execute();
|
|
$toc_view->setAuthorityPackages($packages);
|
|
}
|
|
|
|
// TODO: For Subversion, we should adjust these paths to be relative to
|
|
// the repository root where possible.
|
|
$paths = mpull($changesets, 'getFilename');
|
|
|
|
$control_query = id(new PhabricatorOwnersPackageQuery())
|
|
->setViewer($viewer)
|
|
->withControl($repository_phid, $paths);
|
|
$control_query->execute();
|
|
}
|
|
}
|
|
|
|
foreach ($changesets as $changeset_id => $changeset) {
|
|
$is_visible = isset($visible_changesets[$changeset_id]);
|
|
$anchor = $changeset->getAnchorName();
|
|
|
|
$filename = $changeset->getFilename();
|
|
$coverage_id = 'differential-mcoverage-'.md5($filename);
|
|
|
|
$item = id(new PHUIDiffTableOfContentsItemView())
|
|
->setChangeset($changeset)
|
|
->setIsVisible($is_visible)
|
|
->setAnchor($anchor)
|
|
->setCoverage(idx($coverage, $filename))
|
|
->setCoverageID($coverage_id);
|
|
|
|
if ($have_owners) {
|
|
$package = $control_query->getControllingPackageForPath(
|
|
$repository_phid,
|
|
$changeset->getFilename());
|
|
if ($package) {
|
|
$item->setPackage($package);
|
|
}
|
|
}
|
|
|
|
$toc_view->addItem($item);
|
|
}
|
|
|
|
return $toc_view;
|
|
}
|
|
|
|
}
|