1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

In Packages, give publishers a list of packages and packages a list of versions

Summary: Ref T8116. Puts a list of packages on the publisher page, and a list of versions on the package page.

Test Plan: Viewed a publisher, saw packages. Viewed a package, saw versions. Looked at list views.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8116

Differential Revision: https://secure.phabricator.com/D16321
This commit is contained in:
epriestley 2016-07-22 06:53:49 -07:00
parent 08a19f35f0
commit 7517d40519
11 changed files with 233 additions and 33 deletions

View file

@ -2990,6 +2990,7 @@ phutil_register_library_map(array(
'PhabricatorPackagesPackageEditor' => 'applications/packages/editor/PhabricatorPackagesPackageEditor.php',
'PhabricatorPackagesPackageKeyTransaction' => 'applications/packages/xaction/package/PhabricatorPackagesPackageKeyTransaction.php',
'PhabricatorPackagesPackageListController' => 'applications/packages/controller/PhabricatorPackagesPackageListController.php',
'PhabricatorPackagesPackageListView' => 'applications/packages/view/PhabricatorPackagesPackageListView.php',
'PhabricatorPackagesPackageNameNgrams' => 'applications/packages/storage/PhabricatorPackagesPackageNameNgrams.php',
'PhabricatorPackagesPackageNameTransaction' => 'applications/packages/xaction/package/PhabricatorPackagesPackageNameTransaction.php',
'PhabricatorPackagesPackagePHIDType' => 'applications/packages/phid/PhabricatorPackagesPackagePHIDType.php',
@ -3011,6 +3012,7 @@ phutil_register_library_map(array(
'PhabricatorPackagesPublisherEditor' => 'applications/packages/editor/PhabricatorPackagesPublisherEditor.php',
'PhabricatorPackagesPublisherKeyTransaction' => 'applications/packages/xaction/publisher/PhabricatorPackagesPublisherKeyTransaction.php',
'PhabricatorPackagesPublisherListController' => 'applications/packages/controller/PhabricatorPackagesPublisherListController.php',
'PhabricatorPackagesPublisherListView' => 'applications/packages/view/PhabricatorPackagesPublisherListView.php',
'PhabricatorPackagesPublisherNameNgrams' => 'applications/packages/storage/PhabricatorPackagesPublisherNameNgrams.php',
'PhabricatorPackagesPublisherNameTransaction' => 'applications/packages/xaction/publisher/PhabricatorPackagesPublisherNameTransaction.php',
'PhabricatorPackagesPublisherPHIDType' => 'applications/packages/phid/PhabricatorPackagesPublisherPHIDType.php',
@ -3031,6 +3033,7 @@ phutil_register_library_map(array(
'PhabricatorPackagesVersionEditEngine' => 'applications/packages/editor/PhabricatorPackagesVersionEditEngine.php',
'PhabricatorPackagesVersionEditor' => 'applications/packages/editor/PhabricatorPackagesVersionEditor.php',
'PhabricatorPackagesVersionListController' => 'applications/packages/controller/PhabricatorPackagesVersionListController.php',
'PhabricatorPackagesVersionListView' => 'applications/packages/view/PhabricatorPackagesVersionListView.php',
'PhabricatorPackagesVersionNameNgrams' => 'applications/packages/storage/PhabricatorPackagesVersionNameNgrams.php',
'PhabricatorPackagesVersionNameTransaction' => 'applications/packages/xaction/version/PhabricatorPackagesVersionNameTransaction.php',
'PhabricatorPackagesVersionPHIDType' => 'applications/packages/phid/PhabricatorPackagesVersionPHIDType.php',
@ -3042,6 +3045,7 @@ phutil_register_library_map(array(
'PhabricatorPackagesVersionTransactionQuery' => 'applications/packages/query/PhabricatorPackagesVersionTransactionQuery.php',
'PhabricatorPackagesVersionTransactionType' => 'applications/packages/xaction/version/PhabricatorPackagesVersionTransactionType.php',
'PhabricatorPackagesVersionViewController' => 'applications/packages/controller/PhabricatorPackagesVersionViewController.php',
'PhabricatorPackagesView' => 'applications/packages/view/PhabricatorPackagesView.php',
'PhabricatorPagerUIExample' => 'applications/uiexample/examples/PhabricatorPagerUIExample.php',
'PhabricatorPassphraseApplication' => 'applications/passphrase/application/PhabricatorPassphraseApplication.php',
'PhabricatorPasswordAuthProvider' => 'applications/auth/provider/PhabricatorPasswordAuthProvider.php',
@ -7822,6 +7826,7 @@ phutil_register_library_map(array(
'PhabricatorPackagesPackageEditor' => 'PhabricatorPackagesEditor',
'PhabricatorPackagesPackageKeyTransaction' => 'PhabricatorPackagesPackageTransactionType',
'PhabricatorPackagesPackageListController' => 'PhabricatorPackagesPackageController',
'PhabricatorPackagesPackageListView' => 'PhabricatorPackagesView',
'PhabricatorPackagesPackageNameNgrams' => 'PhabricatorPackagesNgrams',
'PhabricatorPackagesPackageNameTransaction' => 'PhabricatorPackagesPackageTransactionType',
'PhabricatorPackagesPackagePHIDType' => 'PhabricatorPHIDType',
@ -7852,6 +7857,7 @@ phutil_register_library_map(array(
'PhabricatorPackagesPublisherEditor' => 'PhabricatorPackagesEditor',
'PhabricatorPackagesPublisherKeyTransaction' => 'PhabricatorPackagesPublisherTransactionType',
'PhabricatorPackagesPublisherListController' => 'PhabricatorPackagesPublisherController',
'PhabricatorPackagesPublisherListView' => 'PhabricatorPackagesView',
'PhabricatorPackagesPublisherNameNgrams' => 'PhabricatorPackagesNgrams',
'PhabricatorPackagesPublisherNameTransaction' => 'PhabricatorPackagesPublisherTransactionType',
'PhabricatorPackagesPublisherPHIDType' => 'PhabricatorPHIDType',
@ -7882,6 +7888,7 @@ phutil_register_library_map(array(
'PhabricatorPackagesVersionEditEngine' => 'PhabricatorPackagesEditEngine',
'PhabricatorPackagesVersionEditor' => 'PhabricatorPackagesEditor',
'PhabricatorPackagesVersionListController' => 'PhabricatorPackagesVersionController',
'PhabricatorPackagesVersionListView' => 'PhabricatorPackagesView',
'PhabricatorPackagesVersionNameNgrams' => 'PhabricatorPackagesNgrams',
'PhabricatorPackagesVersionNameTransaction' => 'PhabricatorPackagesVersionTransactionType',
'PhabricatorPackagesVersionPHIDType' => 'PhabricatorPHIDType',
@ -7893,6 +7900,7 @@ phutil_register_library_map(array(
'PhabricatorPackagesVersionTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorPackagesVersionTransactionType' => 'PhabricatorPackagesTransactionType',
'PhabricatorPackagesVersionViewController' => 'PhabricatorPackagesVersionController',
'PhabricatorPackagesView' => 'AphrontView',
'PhabricatorPagerUIExample' => 'PhabricatorUIExample',
'PhabricatorPassphraseApplication' => 'PhabricatorApplication',
'PhabricatorPasswordAuthProvider' => 'PhabricatorAuthProvider',

View file

@ -32,14 +32,21 @@ final class PhabricatorPackagesPackageViewController
$header = $this->buildHeaderView($package);
$curtain = $this->buildCurtain($package);
$versions_view = $this->buildVersionsView($package);
$timeline = $this->buildTransactionTimeline(
$package,
new PhabricatorPackagesPackageTransactionQuery());
$timeline->setShouldTerminate(true);
$package_view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn($timeline);
->setMainColumn(
array(
$versions_view,
$timeline,
));
return $this->newPage()
->setCrumbs($crumbs)
@ -84,4 +91,39 @@ final class PhabricatorPackagesPackageViewController
return $curtain;
}
private function buildVersionsView(PhabricatorPackagesPackage $package) {
$viewer = $this->getViewer();
$versions = id(new PhabricatorPackagesVersionQuery())
->setViewer($viewer)
->withPackagePHIDs(array($package->getPHID()))
->setLimit(25)
->execute();
$versions_list = id(new PhabricatorPackagesVersionListView())
->setViewer($viewer)
->setVersions($versions);
$all_href = urisprintf(
'version/?package=%s#R',
$package->getPHID());
$all_href = $this->getApplicationURI($all_href);
$view_all = id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-search')
->setText(pht('View All'))
->setHref($all_href);
$header = id(new PHUIHeaderView())
->setHeader(pht('Versions'))
->addActionLink($view_all);
$versions_view = id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setObjectList($versions_list);
return $versions_view;
}
}

View file

@ -29,14 +29,21 @@ final class PhabricatorPackagesPublisherViewController
$header = $this->buildHeaderView($publisher);
$curtain = $this->buildCurtain($publisher);
$packages_view = $this->buildPackagesView($publisher);
$timeline = $this->buildTransactionTimeline(
$publisher,
new PhabricatorPackagesPublisherTransactionQuery());
$timeline->setShouldTerminate(true);
$publisher_view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn($timeline);
->setMainColumn(
array(
$packages_view,
$timeline,
));
return $this->newPage()
->setCrumbs($crumbs)
@ -81,4 +88,40 @@ final class PhabricatorPackagesPublisherViewController
return $curtain;
}
private function buildPackagesView(PhabricatorPackagesPublisher $publisher) {
$viewer = $this->getViewer();
$packages = id(new PhabricatorPackagesPackageQuery())
->setViewer($viewer)
->withPublisherPHIDs(array($publisher->getPHID()))
->setLimit(25)
->execute();
$packages_list = id(new PhabricatorPackagesPackageListView())
->setViewer($viewer)
->setPackages($packages);
$all_href = urisprintf(
'package/?publisher=%s#R',
$publisher->getPHID());
$all_href = $this->getApplicationURI($all_href);
$view_all = id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-search')
->setText(pht('View All'))
->setHref($all_href);
$header = id(new PHUIHeaderView())
->setHeader(pht('Packages'))
->addActionLink($view_all);
$packages_view = id(new PHUIObjectBoxView())
->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setObjectList($packages_list);
return $packages_view;
}
}

View file

@ -39,6 +39,7 @@ final class PhabricatorPackagesVersionViewController
$timeline = $this->buildTransactionTimeline(
$version,
new PhabricatorPackagesVersionTransactionQuery());
$timeline->setShouldTerminate(true);
$version_view = id(new PHUITwoColumnView())
->setHeader($header)

View file

@ -74,19 +74,12 @@ final class PhabricatorPackagesPackageSearchEngine
array $handles) {
assert_instances_of($packages, 'PhabricatorPackagesPackage');
$viewer = $this->requireViewer();
$list = id(new PHUIObjectItemListView())
->setViewer($viewer);
foreach ($packages as $package) {
$item = id(new PHUIObjectItemView())
->setObjectName($package->getFullKey())
->setHeader($package->getName())
->setHref($package->getURI());
$list->addItem($item);
}
$list = id(new PhabricatorPackagesPackageListView())
->setViewer($viewer)
->setPackages($packages)
->newListView();
return id(new PhabricatorApplicationSearchResultView())
->setObjectList($list)

View file

@ -67,16 +67,10 @@ final class PhabricatorPackagesPublisherSearchEngine
$viewer = $this->requireViewer();
$list = id(new PHUIObjectItemListView())
->setViewer($viewer);
foreach ($publishers as $publisher) {
$item = id(new PHUIObjectItemView())
->setObjectName($publisher->getPublisherKey())
->setHeader($publisher->getName())
->setHref($publisher->getURI());
$list->addItem($item);
}
$list = id(new PhabricatorPackagesPublisherListView())
->setViewer($viewer)
->setPublishers($publishers)
->newListView();
return id(new PhabricatorApplicationSearchResultView())
->setObjectList($list)

View file

@ -73,18 +73,12 @@ final class PhabricatorPackagesVersionSearchEngine
array $handles) {
assert_instances_of($versions, 'PhabricatorPackagesVersion');
$viewer = $this->requireViewer();
$list = id(new PHUIObjectItemListView())
->setViewer($viewer);
foreach ($versions as $version) {
$item = id(new PHUIObjectItemView())
->setHeader($version->getName())
->setHref($version->getURI());
$list->addItem($item);
}
$list = id(new PhabricatorPackagesVersionListView())
->setViewer($viewer)
->setVersions($versions)
->newListView();
return id(new PhabricatorApplicationSearchResultView())
->setObjectList($list)

View file

@ -0,0 +1,41 @@
<?php
final class PhabricatorPackagesPackageListView
extends PhabricatorPackagesView {
private $packages;
public function setPackages(array $packages) {
assert_instances_of($packages, 'PhabricatorPackagesPackage');
$this->packages = $packages;
return $this;
}
public function getPackages() {
return $this->packages;
}
public function render() {
return $this->newListView();
}
public function newListView() {
$viewer = $this->getViewer();
$packages = $this->getPackages();
$list = id(new PHUIObjectItemListView())
->setViewer($viewer);
foreach ($packages as $package) {
$item = id(new PHUIObjectItemView())
->setObjectName($package->getFullKey())
->setHeader($package->getName())
->setHref($package->getURI());
$list->addItem($item);
}
return $list;
}
}

View file

@ -0,0 +1,41 @@
<?php
final class PhabricatorPackagesPublisherListView
extends PhabricatorPackagesView {
private $publishers;
public function setPublishers(array $publishers) {
assert_instances_of($publishers, 'PhabricatorPackagesPublisher');
$this->publishers = $publishers;
return $this;
}
public function getPublishers() {
return $this->publishers;
}
public function render() {
return $this->newListView();
}
public function newListView() {
$viewer = $this->getViewer();
$publishers = $this->getPublishers();
$list = id(new PHUIObjectItemListView())
->setViewer($viewer);
foreach ($publishers as $publisher) {
$item = id(new PHUIObjectItemView())
->setObjectName($publisher->getPublisherKey())
->setHeader($publisher->getName())
->setHref($publisher->getURI());
$list->addItem($item);
}
return $list;
}
}

View file

@ -0,0 +1,40 @@
<?php
final class PhabricatorPackagesVersionListView
extends PhabricatorPackagesView {
private $versions;
public function setVersions(array $versions) {
assert_instances_of($versions, 'PhabricatorPackagesVersion');
$this->versions = $versions;
return $this;
}
public function getVersions() {
return $this->versions;
}
public function render() {
return $this->newListView();
}
public function newListView() {
$viewer = $this->getViewer();
$versions = $this->getVersions();
$list = id(new PHUIObjectItemListView())
->setViewer($viewer);
foreach ($versions as $version) {
$item = id(new PHUIObjectItemView())
->setHeader($version->getName())
->setHref($version->getURI());
$list->addItem($item);
}
return $list;
}
}

View file

@ -0,0 +1,3 @@
<?php
abstract class PhabricatorPackagesView extends AphrontView {}