From 75fcf56b678d1867f44a78845e723f1b91394197 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 22 Mar 2011 13:49:46 -0700 Subject: [PATCH] Rough cut of Herald home controller. --- resources/sql/patches/010.herald.sql | 44 +++++ src/__phutil_library_map__.php | 4 + ...AphrontDefaultApplicationConfiguration.php | 5 + .../contenttype/HeraldContentTypeConfig.php | 2 + .../controller/base/HeraldController.php | 34 ++++ .../herald/controller/base/__init__.php | 15 ++ .../controller/home/HeraldHomeController.php | 161 ++++++++++++++++++ .../herald/controller/home/__init__.php | 19 +++ 8 files changed, 284 insertions(+) create mode 100644 resources/sql/patches/010.herald.sql create mode 100644 src/applications/herald/controller/base/HeraldController.php create mode 100644 src/applications/herald/controller/base/__init__.php create mode 100644 src/applications/herald/controller/home/HeraldHomeController.php create mode 100644 src/applications/herald/controller/home/__init__.php diff --git a/resources/sql/patches/010.herald.sql b/resources/sql/patches/010.herald.sql new file mode 100644 index 0000000000..4ec76332b0 --- /dev/null +++ b/resources/sql/patches/010.herald.sql @@ -0,0 +1,44 @@ +CREATE DATABASE phabricator_herald; + +CREATE TABLE phabricator_herald.herald_action ( + id int unsigned not null auto_increment primary key, + ruleID int unsigned not null, + action varchar(255) not null, + target text not null +); + +CREATE TABLE phabricator_herald.herald_rule ( + id int unsigned not null auto_increment primary key, + name varchar(255) not null, + authorPHID varchar(64) binary not null, + contentType varchar(255) not null, + mustMatchAll bool not null, + configVersion int unsigned not null default '1', + dateCreated int unsigned not null, + dateModified int unsigned not null, + unique key (authorPHID, name) +); + +CREATE TABLE phabricator_herald.herald_condition ( + id int unsigned not null auto_increment primary key, + ruleID int unsigned not null, + fieldName varchar(255) not null, + fieldCondition varchar(255) not null, + value text not null +); + +CREATE TABLE phabricator_herald.herald_transcript ( + id int unsigned not null auto_increment primary key, + phid varchar(64) binary not null, + time int unsigned not null, + host varchar(255) not null, + psth varchar(255) not null, + duration float not null, + objectPHID varchar(64) binary not null, + dryRun bool not null, + objectTranscript longblob not null, + ruleTranscripts longblob not null, + conditionTranscripts longblob not null, + applyTranscripts longblob not null, + unique key (phid) +); \ No newline at end of file diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 70e3eddf13..d172af4702 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -185,10 +185,12 @@ phutil_register_library_map(array( 'HeraldConditionConfig' => 'applications/herald/config/condition', 'HeraldConditionTranscript' => 'applications/herald/storage/transcript/condition', 'HeraldContentTypeConfig' => 'applications/herald/config/contenttype', + 'HeraldController' => 'applications/herald/controller/base', 'HeraldDAO' => 'applications/herald/storage/base', 'HeraldEffect' => 'applications/herald/engine/effect', 'HeraldEngine' => 'applications/herald/engine/engine', 'HeraldFieldConfig' => 'applications/herald/config/field', + 'HeraldHomeController' => 'applications/herald/controller/home', 'HeraldInvalidConditionException' => 'applications/herald/engine/engine/exception', 'HeraldInvalidFieldException' => 'applications/herald/engine/engine/exception', 'HeraldObjectTranscript' => 'applications/herald/storage/transcript/object', @@ -528,7 +530,9 @@ phutil_register_library_map(array( 'HeraldAction' => 'HeraldDAO', 'HeraldApplyTranscript' => 'HeraldDAO', 'HeraldCondition' => 'HeraldDAO', + 'HeraldController' => 'PhabricatorController', 'HeraldDAO' => 'PhabricatorLiskDAO', + 'HeraldHomeController' => 'HeraldController', 'HeraldRule' => 'HeraldDAO', 'HeraldTranscript' => 'HeraldDAO', 'ManiphestController' => 'PhabricatorController', diff --git a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php index e420ada3e8..4fbcf78ead 100644 --- a/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php +++ b/src/aphront/default/configuration/AphrontDefaultApplicationConfiguration.php @@ -217,6 +217,11 @@ class AphrontDefaultApplicationConfiguration '$' => 'PhabricatorDaemonConsoleController', ), + '/herald/' => array( + '$' => 'HeraldHomeController', + 'view/(?P[^/]+)/$' => 'HeraldHomeController', + ), + ); } diff --git a/src/applications/herald/config/contenttype/HeraldContentTypeConfig.php b/src/applications/herald/config/contenttype/HeraldContentTypeConfig.php index e1cb96a2f8..938d5ffb3a 100644 --- a/src/applications/herald/config/contenttype/HeraldContentTypeConfig.php +++ b/src/applications/herald/config/contenttype/HeraldContentTypeConfig.php @@ -27,8 +27,10 @@ class HeraldContentTypeConfig { static $map = array( self::CONTENT_TYPE_DIFFERENTIAL => 'Differential Revisions', self::CONTENT_TYPE_COMMIT => 'Commits', +/* TODO: Deal with this self::CONTENT_TYPE_MERGE => 'Merge Requests', self::CONTENT_TYPE_OWNERS => 'Owners Changes', +*/ ); return $map; } diff --git a/src/applications/herald/controller/base/HeraldController.php b/src/applications/herald/controller/base/HeraldController.php new file mode 100644 index 0000000000..20b6d0a6fe --- /dev/null +++ b/src/applications/herald/controller/base/HeraldController.php @@ -0,0 +1,34 @@ +buildStandardPageView(); + + $page->setApplicationName('Herald'); + $page->setBaseURI('/herald/'); + $page->setTitle(idx($data, 'title')); + $page->setGlyph("\xE2\x98\xBF"); + $page->appendChild($view); + + $response = new AphrontWebpageResponse(); + return $response->setContent($page->render()); + + } +} diff --git a/src/applications/herald/controller/base/__init__.php b/src/applications/herald/controller/base/__init__.php new file mode 100644 index 0000000000..953582f57f --- /dev/null +++ b/src/applications/herald/controller/base/__init__.php @@ -0,0 +1,15 @@ +view = idx($data, 'view'); + } + + public function processRequest() { + + $request = $this->getRequest(); + $user = $request->getUser(); + + $map = HeraldContentTypeConfig::getContentTypeMap(); + if (empty($map[$this->view])) { + reset($map); + $this->view = key($map); + } + + $rules = id(new HeraldRule())->loadAllWhere( + 'contentType = %s AND authorPHID = %s', + $this->view, + $user->getPHID()); + + $handles = array(); + $need_phids = mpull($rules, 'getAuthorPHID'); + +/* + $data = new ToolsHandleData($need_fbids, $handles); + $data->needNames(); + $data->needAlternateNames(); + prep($data); +*/ + $type = 'differential'; + + $rows = array(); + foreach ($rules as $rule) { + + $owner = 'owner'; +/* getOwnerID()]->getURI()}> + {$handles[$rule->getOwnerID()]->getName()} + ; +*/ + $name = 'name'; +/* getID()."/"}> + {$rule->getName()} + ; +*/ + $delete = 'delete'; + +/* getID()."/"} workflow={true}> + Delete + ; +*/ + $rows[] = array( + $map[$rule->getContentType()], + $owner->toString(), + $name->toString(), + $delete->toString(), + ); + } + + $table = new AphrontTableView($rows); + $table->setNoDataString( + "No matching subscription rules for ". + phutil_escape_html($map[$this->view])."."); + + $table->setHeaders( + array( + 'Type', + 'Owner', + 'Rule Name', + 'Delete', + )); + $table->setColumnClasses( + array( + '', + '', + 'wide wrap', + 'action' + )); + + $items = array(); + foreach ($map as $key => $value) { + $uri = '/herald/view/'.$key.'/'; + $items[] = 'item'; +/* view}> + {$value} + ; +*/ + } + + +// require_static('herald-css'); + + // If you're viewing as an admin, this string renders in the table header. +// $map['admin'] = 'Omniscience'; + + $sidenav = new AphrontSideNavView(); + foreach ($map as $key => $value) { + $sidenav->addNavItem( + phutil_render_tag( + 'a', + array( + 'href' => '/herald/view/'.$key.'/', + 'class' => ($key == $this->view) + ? 'aphront-side-nav-selected' + : null, + ), + phutil_escape_html($value))); + } + + + $content = array(); + $content[] = 'oh hi'; + + return $this->buildStandardPageResponse( + $sidenav, + array( + 'title' => 'Herald', + )); + +/* + +
+ +
+ view} + class="button green" + style="float: right;">Create New Rule +

Herald Subscription Rules + for {txt2html($map[$this->view])}

+ {HTML($table->render())} +
+
+
+
; +*/ + + } + +} diff --git a/src/applications/herald/controller/home/__init__.php b/src/applications/herald/controller/home/__init__.php new file mode 100644 index 0000000000..8e8791e2ab --- /dev/null +++ b/src/applications/herald/controller/home/__init__.php @@ -0,0 +1,19 @@ +