From 65e13867535acf552b4f1f0c7b341d2b9d49b87c Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 3 Apr 2011 14:48:36 -0700 Subject: [PATCH] owners --- resources/sql/patches/018.owners.sql | 28 ++++ src/__phutil_library_map__.php | 14 ++ ...AphrontDefaultApplicationConfiguration.php | 6 + .../history/DiffusionHistoryController.php | 3 +- .../base/PhabricatorOwnersController.php | 34 +++++ .../owners/controller/base/__init__.php | 15 +++ .../PhabricatorOwnersDetailController.php | 29 +++++ .../owners/controller/detail/__init__.php | 12 ++ .../list/PhabricatorOwnersListController.php | 123 ++++++++++++++++++ .../owners/controller/list/__init__.php | 12 ++ .../storage/base/PhabricatorOwnersDAO.php | 25 ++++ .../owners/storage/base/__init__.php | 12 ++ .../storage/owner/PhabricatorOwnersOwner.php | 30 +++++ .../owners/storage/owner/__init__.php | 12 ++ .../package/PhabricatorOwnersPackage.php | 38 ++++++ .../owners/storage/package/__init__.php | 13 ++ .../storage/path/PhabricatorOwnersPath.php | 31 +++++ .../owners/storage/path/__init__.php | 12 ++ 18 files changed, 448 insertions(+), 1 deletion(-) create mode 100644 resources/sql/patches/018.owners.sql create mode 100644 src/applications/owners/controller/base/PhabricatorOwnersController.php create mode 100644 src/applications/owners/controller/base/__init__.php create mode 100644 src/applications/owners/controller/detail/PhabricatorOwnersDetailController.php create mode 100644 src/applications/owners/controller/detail/__init__.php create mode 100644 src/applications/owners/controller/list/PhabricatorOwnersListController.php create mode 100644 src/applications/owners/controller/list/__init__.php create mode 100644 src/applications/owners/storage/base/PhabricatorOwnersDAO.php create mode 100644 src/applications/owners/storage/base/__init__.php create mode 100644 src/applications/owners/storage/owner/PhabricatorOwnersOwner.php create mode 100644 src/applications/owners/storage/owner/__init__.php create mode 100644 src/applications/owners/storage/package/PhabricatorOwnersPackage.php create mode 100644 src/applications/owners/storage/package/__init__.php create mode 100644 src/applications/owners/storage/path/PhabricatorOwnersPath.php create mode 100644 src/applications/owners/storage/path/__init__.php diff --git a/resources/sql/patches/018.owners.sql b/resources/sql/patches/018.owners.sql new file mode 100644 index 0000000000..b2bc59ece8 --- /dev/null +++ b/resources/sql/patches/018.owners.sql @@ -0,0 +1,28 @@ +CREATE DATABASE phabricator_owners; + +CREATE TABLE phabricator_owners.onwners_package ( + id int unsigned not null auto_increment primary key, + phid varchar(64) binary not null, + unique key(phid), + name varchar(255) not null, + unique key(name), + description text not null, + primaryOwnerPHID varchar(64) binary +); + +CREATE TABLE phabricator_owners.owners_owner ( + id int unsigned not null auto_increment primary key, + packageID int unsigned not null, + userPHID varchar(64) binary not null, + UNIQUE KEY(packageID, userPHID), + KEY(userPHID) +); + +CREATE TABLE phabricator_owners.owners_path ( + id int unsigned not null auto_increment primary key, + packageID int unsigned not null, + key(packageID), + repositoryPHID varchar(64) binary not null, + path varchar(255) not null, + unique key (repositoryPHID, path) +); \ No newline at end of file diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index cb8292b905..790bce9fc7 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -315,6 +315,13 @@ phutil_register_library_map(array( 'PhabricatorObjectHandle' => 'applications/phid/handle', 'PhabricatorObjectHandleData' => 'applications/phid/handle/data', 'PhabricatorObjectSelectorDialog' => 'view/control/objectselector', + 'PhabricatorOwnersController' => 'applications/owners/controller/base', + 'PhabricatorOwnersDAO' => 'applications/owners/storage/base', + 'PhabricatorOwnersDetailController' => 'applications/owners/controller/detail', + 'PhabricatorOwnersListController' => 'applications/owners/controller/list', + 'PhabricatorOwnersOwner' => 'applications/owners/storage/owner', + 'PhabricatorOwnersPackage' => 'applications/owners/storage/package', + 'PhabricatorOwnersPath' => 'applications/owners/storage/path', 'PhabricatorPHID' => 'applications/phid/storage/phid', 'PhabricatorPHIDAllocateController' => 'applications/phid/controller/allocate', 'PhabricatorPHIDConstants' => 'applications/phid/constants', @@ -662,6 +669,13 @@ phutil_register_library_map(array( 'PhabricatorOAuthProviderGithub' => 'PhabricatorOAuthProvider', 'PhabricatorOAuthRegistrationController' => 'PhabricatorAuthController', 'PhabricatorOAuthUnlinkController' => 'PhabricatorAuthController', + 'PhabricatorOwnersController' => 'PhabricatorController', + 'PhabricatorOwnersDAO' => 'PhabricatorLiskDAO', + 'PhabricatorOwnersDetailController' => 'PhabricatorOwnersController', + 'PhabricatorOwnersListController' => 'PhabricatorOwnersController', + 'PhabricatorOwnersOwner' => 'PhabricatorOwnersDAO', + 'PhabricatorOwnersPackage' => 'PhabricatorOwnersDAO', + 'PhabricatorOwnersPath' => 'PhabricatorOwnersDAO', 'PhabricatorPHID' => 'PhabricatorPHIDDAO', 'PhabricatorPHIDAllocateController' => 'PhabricatorPHIDController', 'PhabricatorPHIDController' => 'PhabricatorController', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index 16665dd9cc..1aba28e37d 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -251,6 +251,12 @@ class AphrontDefaultApplicationConfiguration 'view/(?P[^/]+)/$' => 'PhabricatorUIExampleRenderController', ), + '/owners/' => array( + '$' => 'PhabricatorOwnersListController', + 'view/(?P[^/]+)/$' => 'PhabricatorOwnersListController', + 'package/(?P\d+)/$' => 'PhabricatorOwnersDetailController', + ), + ); } diff --git a/src/applications/diffusion/controller/history/DiffusionHistoryController.php b/src/applications/diffusion/controller/history/DiffusionHistoryController.php index fc21640db0..e2f269fd6c 100644 --- a/src/applications/diffusion/controller/history/DiffusionHistoryController.php +++ b/src/applications/diffusion/controller/history/DiffusionHistoryController.php @@ -36,10 +36,11 @@ class DiffusionHistoryController extends DiffusionController { $data = $item->getCommitData(); if ($data) { if ($data->getCommitDetail('authorPHID')) { - $phids[] = $data->getCommitDetail('authorPHID'); + $phids[$data->getCommitDetail('authorPHID')] = true; } } } + $phids = array_keys($phids); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $pager = new AphrontPagerView(); diff --git a/src/applications/owners/controller/base/PhabricatorOwnersController.php b/src/applications/owners/controller/base/PhabricatorOwnersController.php new file mode 100644 index 0000000000..f3429410c6 --- /dev/null +++ b/src/applications/owners/controller/base/PhabricatorOwnersController.php @@ -0,0 +1,34 @@ +buildStandardPageView(); + + $page->setApplicationName('Owners'); + $page->setBaseURI('/owners/'); + $page->setTitle(idx($data, 'title')); + $page->setGlyph("\xE2\x98\x81"); + $page->appendChild($view); + + $response = new AphrontWebpageResponse(); + return $response->setContent($page->render()); + } +} diff --git a/src/applications/owners/controller/base/__init__.php b/src/applications/owners/controller/base/__init__.php new file mode 100644 index 0000000000..951cd6ce8f --- /dev/null +++ b/src/applications/owners/controller/base/__init__.php @@ -0,0 +1,15 @@ +buildStandardPageResponse( + 'quack', + array( + 'title' => 'detail', + )); + } + +} diff --git a/src/applications/owners/controller/detail/__init__.php b/src/applications/owners/controller/detail/__init__.php new file mode 100644 index 0000000000..c06db617d0 --- /dev/null +++ b/src/applications/owners/controller/detail/__init__.php @@ -0,0 +1,12 @@ +view = idx($data, 'view'); + } + + public function processRequest() { + + $views = array( + 'owned' => 'Owned Packages', + 'all' => 'All Packages', + 'search' => 'Search Results', + ); + + if (empty($views[$this->view])) { + reset($views); + $this->view = key($views); + } + + if ($this->view != 'search') { + unset($views['search']); + } + + $nav = new AphrontSideNavView(); + foreach ($views as $key => $name) { + $nav->addNavItem( + phutil_render_tag( + 'a', + array( + 'href' => '/owners/view/'.$key.'/', + 'class' => ($this->view == $key) + ? 'aphront-side-nav-selected' + : null, + ), + phutil_escape_html($name))); + } + + switch ($this->view) { + case 'search': + $content = 'search goes here'; + break; + case 'owned': + $content = $this->renderOwnedView(); + break; + case 'all': + $content = $this->renderAllView(); + break; + } + + $nav->appendChild($content); + + return $this->buildStandardPageResponse( + $nav, + array( + 'title' => 'List', + )); + } + + private function renderOwnedView() { + $packages = array(); + + return $this->renderPackageTable($packages, 'Owned Packages'); + } + + private function renderAllView() { + $packages = array(); + + return $this->renderPackageTable($packages, 'All Packages'); + } + + private function renderPackageTable(array $packages, $header) { + + $rows = array(); + foreach ($packages as $package) { + $rows[] = array( + 'x', + 'y', + 'z', + ); + } + + $table = new AphrontTableView($rows); + $table->setHeaders( + array( + 'Name', + 'Owners', + 'Paths', + )); + $table->setColumnClasses( + array( + '', + '', + 'wide wrap', + )); + + $panel = new AphrontPanelView(); + $panel->setHeader($header); + $panel->appendChild($table); + + return $panel; + } + +} diff --git a/src/applications/owners/controller/list/__init__.php b/src/applications/owners/controller/list/__init__.php new file mode 100644 index 0000000000..91565a263b --- /dev/null +++ b/src/applications/owners/controller/list/__init__.php @@ -0,0 +1,12 @@ + false, + ); + } + +} diff --git a/src/applications/owners/storage/owner/__init__.php b/src/applications/owners/storage/owner/__init__.php new file mode 100644 index 0000000000..2c5c082935 --- /dev/null +++ b/src/applications/owners/storage/owner/__init__.php @@ -0,0 +1,12 @@ + false, + self::CONFIG_AUX_PHID => true, + ); + } + + public function generatePHID() { + return PhabricatorPHID::generateNew('OPKG'); + } + +} diff --git a/src/applications/owners/storage/package/__init__.php b/src/applications/owners/storage/package/__init__.php new file mode 100644 index 0000000000..8a401ec1b2 --- /dev/null +++ b/src/applications/owners/storage/package/__init__.php @@ -0,0 +1,13 @@ + false, + ); + } + +} diff --git a/src/applications/owners/storage/path/__init__.php b/src/applications/owners/storage/path/__init__.php new file mode 100644 index 0000000000..fa1f16af1e --- /dev/null +++ b/src/applications/owners/storage/path/__init__.php @@ -0,0 +1,12 @@ +