Permalink
Browse files

Include more packages in Owned Packages view

Summary:
If a user is a member of a project, and that project is an owner of a package,
it would make sense to display those packages in the list of owned packages.

Test Plan:
create a project that I'm a member of, then create a package that that project
owns, and reload /owners/view/owned/ and see the package listed.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5355
  • Loading branch information...
Nick Harper
Nick Harper committed Mar 28, 2013
1 parent abdaf90 commit 3b7203dc9ffe441e3e0c1710630c22bf03ee4214
@@ -61,6 +61,7 @@ public function renderSideNav() {
$nav->addLabel('Packages');
$this->getExtraPackageViews($nav);
$nav->addFilter('view/owned', 'Owned');
+ $nav->addFilter('view/projects', 'Projects');
$nav->addFilter('view/all', 'All');
$nav->selectFilter($this->getSideNavFilter(), 'view/owned');
@@ -105,6 +105,25 @@ public function processRequest() {
$user->getPHID());
$packages = $package->loadAllFromArray($data);
+ $header = 'Owned Packages';
+ $nodata = 'No owned packages';
+ break;
+ case 'projects':
+ $projects = id(new PhabricatorProjectQuery())
+ ->setViewer($user)
+ ->withMemberPHIDs(array($user->getPHID()))
+ ->withStatus(PhabricatorProjectQuery::STATUS_ANY)
+ ->execute();
+ $owner_phids = mpull($projects, 'getPHID');
+ $data = queryfx_all(
+ $package->establishConnection('r'),
+ 'SELECT p.* FROM %T p JOIN %T o ON p.id = o.packageID
+ WHERE o.userPHID IN (%Ls) GROUP BY p.id',
+ $package->getTableName(),
+ $owner->getTableName(),
+ $owner_phids);
+ $packages = $package->loadAllFromArray($data);
+
$header = 'Owned Packages';
$nodata = 'No owned packages';
break;

0 comments on commit 3b7203d

Please sign in to comment.