From aa86cf0ed84593dc83ccd5f46b5ab9f534ac8390 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 13 Jun 2011 17:35:13 -0700 Subject: [PATCH] Countdown tweaks Summary: A few tweaks to hsb's Countdown implementation: - Allow the page to be rendered "chromeless", suitable for display on one of the dozens of monitors everyone has laying around. - Show title of countdown in deletion dialog. - When creating a new countdown default to time(), not Dec 31, 1969. - Add extra "/" after editing to avoid needless redirect. - Tweak some page titles. - Show countdown author in list view. - Highlight tab in list view. - Tweak menu copy. - Link countdown title in list view, separate buttons into different columns so they pick up padding. Test Plan: Created, edited and deleted a timer. Viewed a timer and toggled chrome mode. Viewed timer list. Reviewed By: hsb Reviewers: hsb, aran, jungejason, tuomaspelkonen CC: aran, hsb, epriestley Differential Revision: 454 --- resources/sql/patches/044.countdown.sql | 2 +- .../base/PhabricatorCountdownController.php | 5 ++- .../PhabricatorCountdownDeleteController.php | 4 +- .../countdown/controller/delete/__init__.php | 1 + .../PhabricatorCountdownEditController.php | 11 ++--- .../PhabricatorCountdownListController.php | 43 ++++++++++--------- .../countdown/controller/list/__init__.php | 1 + .../PhabricatorCountdownViewController.php | 20 +++++++-- src/view/page/base/AphrontPageView.php | 8 +++- .../standard/PhabricatorStandardPageView.php | 43 ++++++++++++++++--- .../application/base/standard-page-view.css | 9 ++++ .../rsrc/css/application/countdown/timer.css | 5 +++ webroot/rsrc/css/core/core.css | 4 ++ 13 files changed, 115 insertions(+), 41 deletions(-) diff --git a/resources/sql/patches/044.countdown.sql b/resources/sql/patches/044.countdown.sql index d57c089da8..77836429a7 100644 --- a/resources/sql/patches/044.countdown.sql +++ b/resources/sql/patches/044.countdown.sql @@ -12,5 +12,5 @@ CREATE TABLE phabricator_countdown.countdown_timer ( INSERT INTO phabricator_directory.directory_item (name, description, href, categoryID, sequence, dateCreated, dateModified) VALUES - ("Counterdown", "T-minus X to Y", "/countdown/", 5, 350, + ("Countdown", "Utilize the full capabilities of your ALU.", "/countdown/", 5, 350, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()); diff --git a/src/applications/countdown/controller/base/PhabricatorCountdownController.php b/src/applications/countdown/controller/base/PhabricatorCountdownController.php index 801dd2a60b..89175a6d0a 100644 --- a/src/applications/countdown/controller/base/PhabricatorCountdownController.php +++ b/src/applications/countdown/controller/base/PhabricatorCountdownController.php @@ -28,12 +28,13 @@ abstract class PhabricatorCountdownController extends PhabricatorController { $page->setGlyph("\xE2\x9A\xB2"); $page->setTabs( array( - 'create' => array( + 'list' => array( 'href' => '/countdown/', - 'name' => 'List', + 'name' => 'Countdown List', ), ), idx($data, 'tab')); + $page->setShowChrome(idx($data, 'chrome', true)); $page->appendChild($view); diff --git a/src/applications/countdown/controller/delete/PhabricatorCountdownDeleteController.php b/src/applications/countdown/controller/delete/PhabricatorCountdownDeleteController.php index 777c7a6fa1..d2c46721a6 100644 --- a/src/applications/countdown/controller/delete/PhabricatorCountdownDeleteController.php +++ b/src/applications/countdown/controller/delete/PhabricatorCountdownDeleteController.php @@ -47,7 +47,9 @@ class PhabricatorCountdownDeleteController $dialog = new AphrontDialogView(); $dialog->setUser($request->getUser()); $dialog->setTitle('Really delete this countdown?'); - $dialog->appendChild("Are you sure you want to delete this countdown?"); + $dialog->appendChild( + '

Are you sure you want to delete the countdown "'. + phutil_escape_html($timer->getTitle()).'"?

'); $dialog->addSubmitButton('Delete'); $dialog->addCancelButton('/countdown/'); $dialog->setSubmitURI($request->getPath()); diff --git a/src/applications/countdown/controller/delete/__init__.php b/src/applications/countdown/controller/delete/__init__.php index 2f550ae3dd..55062778dc 100644 --- a/src/applications/countdown/controller/delete/__init__.php +++ b/src/applications/countdown/controller/delete/__init__.php @@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'applications/countdown/controller/base'); phutil_require_module('phabricator', 'applications/countdown/storage/timer'); phutil_require_module('phabricator', 'view/dialog'); +phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'utils'); diff --git a/src/applications/countdown/controller/edit/PhabricatorCountdownEditController.php b/src/applications/countdown/controller/edit/PhabricatorCountdownEditController.php index 71e43e409c..21b9fcc505 100644 --- a/src/applications/countdown/controller/edit/PhabricatorCountdownEditController.php +++ b/src/applications/countdown/controller/edit/PhabricatorCountdownEditController.php @@ -45,6 +45,7 @@ class PhabricatorCountdownEditController $action_label = 'Update Timer'; } else { $timer = new PhabricatorTimer(); + $timer->setDatePoint(time()); } $error_view = null; @@ -75,7 +76,7 @@ class PhabricatorCountdownEditController $timer->setAuthorPHID($user->getPHID()); $timer->save(); return id(new AphrontRedirectResponse()) - ->setURI('/countdown/'.$timer->getID()); + ->setURI('/countdown/'.$timer->getID().'/'); } else { $error_view = id(new AphrontErrorView()) @@ -109,13 +110,13 @@ class PhabricatorCountdownEditController ->setHeader($action_label) ->appendChild($form); - return $this->buildStandardPageResponse(array( + return $this->buildStandardPageResponse( + array( $error_view, - $panel + $panel, ), array( - 'title' => 'Countdown management', - 'tab' => 'management', + 'title' => 'Edit Countdown', )); } } diff --git a/src/applications/countdown/controller/list/PhabricatorCountdownListController.php b/src/applications/countdown/controller/list/PhabricatorCountdownListController.php index 79b2238d10..ca52cf14c6 100644 --- a/src/applications/countdown/controller/list/PhabricatorCountdownListController.php +++ b/src/applications/countdown/controller/list/PhabricatorCountdownListController.php @@ -35,22 +35,16 @@ class PhabricatorCountdownListController $timers = $pager->sliceResults($timers); + $phids = mpull($timers, 'getAuthorPHID'); + $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); + $rows = array(); foreach ($timers as $timer) { - - $control_buttons = array(); - $control_buttons[] = phutil_render_tag( - 'a', - array( - 'class' => 'small button grey', - 'href' => '/countdown/'.$timer->getID().'/', - ), - 'View'); - + $edit_button = null; + $delete_button = null; if ($user->getIsAdmin() || ($user->getPHID() == $timer->getAuthorPHID())) { - - $control_buttons[] = phutil_render_tag( + $edit_button = phutil_render_tag( 'a', array( 'class' => 'small button grey', @@ -58,7 +52,7 @@ class PhabricatorCountdownListController ), 'Edit'); - $control_buttons[] = javelin_render_tag( + $delete_button = javelin_render_tag( 'a', array( 'class' => 'small button grey', @@ -66,14 +60,19 @@ class PhabricatorCountdownListController 'sigil' => 'workflow' ), 'Delete'); - } - $rows[] = array( phutil_escape_html($timer->getID()), - phutil_escape_html($timer->getTitle()), + $handles[$timer->getAuthorPHID()]->renderLink(), + phutil_render_tag( + 'a', + array( + 'href' => '/countdown/'.$timer->getID().'/', + ), + phutil_escape_html($timer->getTitle())), phabricator_format_timestamp($timer->getDatepoint()), - implode('', $control_buttons) + $edit_button, + $delete_button, ); } @@ -81,17 +80,21 @@ class PhabricatorCountdownListController $table->setHeaders( array( 'ID', + 'Author', 'Title', 'End Date', - 'Action' + '', + '' )); $table->setColumnClasses( array( null, null, + 'wide pri', null, - 'action' + 'action', + 'action', )); $panel = id(new AphrontPanelView()) @@ -103,7 +106,7 @@ class PhabricatorCountdownListController return $this->buildStandardPageResponse($panel, array( 'title' => 'Countdown', - 'tab' => 'countdown', + 'tab' => 'list', )); } } diff --git a/src/applications/countdown/controller/list/__init__.php b/src/applications/countdown/controller/list/__init__.php index 14fadffd7f..ff0c92c32c 100644 --- a/src/applications/countdown/controller/list/__init__.php +++ b/src/applications/countdown/controller/list/__init__.php @@ -8,6 +8,7 @@ phutil_require_module('phabricator', 'applications/countdown/controller/base'); phutil_require_module('phabricator', 'applications/countdown/storage/timer'); +phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'view/control/pager'); phutil_require_module('phabricator', 'view/control/table'); diff --git a/src/applications/countdown/controller/view/PhabricatorCountdownViewController.php b/src/applications/countdown/controller/view/PhabricatorCountdownViewController.php index a6843215ae..7ee31bb5c2 100644 --- a/src/applications/countdown/controller/view/PhabricatorCountdownViewController.php +++ b/src/applications/countdown/controller/view/PhabricatorCountdownViewController.php @@ -37,6 +37,15 @@ class PhabricatorCountdownViewController require_celerity_resource('phabricator-countdown-css'); + $chrome_visible = $request->getBool('chrome', true); + $chrome_link = phutil_render_tag( + 'a', + array( + 'href' => $request->getRequestURI()->alter('chrome', !$chrome_visible), + 'class' => 'phabricator-timer-chrome-link', + ), + $chrome_visible ? 'Disable Chrome' : 'Enable Chrome'); + $content = '

'. @@ -56,8 +65,9 @@ class PhabricatorCountdownViewController -

- '; + '. + $chrome_link. + ''; Javelin::initBehavior('countdown-timer', array( 'timestamp' => $timer->getDatepoint() @@ -65,10 +75,12 @@ class PhabricatorCountdownViewController $panel = $content; - return $this->buildStandardPageResponse($panel, + return $this->buildStandardPageResponse( + $panel, array( - 'title' => 'T-minus..', + 'title' => 'Countdown: '.$timer->getTitle(), 'tab' => 'view', + 'chrome' => $chrome_visible )); } diff --git a/src/view/page/base/AphrontPageView.php b/src/view/page/base/AphrontPageView.php index e853a3f790..408a104868 100644 --- a/src/view/page/base/AphrontPageView.php +++ b/src/view/page/base/AphrontPageView.php @@ -49,6 +49,10 @@ class AphrontPageView extends AphrontView { return $response; } + protected function getBodyClasses() { + return null; + } + public function render() { $this->willRenderPage(); @@ -58,6 +62,8 @@ class AphrontPageView extends AphrontView { $body = $this->getBody(); $tail = $this->getTail(); + $body_classes = $this->getBodyClasses(); + $response = << @@ -65,7 +71,7 @@ class AphrontPageView extends AphrontView { {$title} {$head} - + {$body} {$tail} diff --git a/src/view/page/standard/PhabricatorStandardPageView.php b/src/view/page/standard/PhabricatorStandardPageView.php index 542ca810ab..e5dec0e373 100644 --- a/src/view/page/standard/PhabricatorStandardPageView.php +++ b/src/view/page/standard/PhabricatorStandardPageView.php @@ -26,6 +26,7 @@ class PhabricatorStandardPageView extends AphrontPageView { private $bodyContent; private $request; private $isAdminInterface; + private $showChrome = true; public function setIsAdminInterface($is_admin_interface) { $this->isAdminInterface = $is_admin_interface; @@ -69,6 +70,15 @@ class PhabricatorStandardPageView extends AphrontPageView { return $this; } + public function setShowChrome($show_chrome) { + $this->showChrome = $show_chrome; + return $this; + } + + public function getShowChrome() { + return $this->showChrome; + } + public function getTitle() { $use_glyph = true; $request = $this->getRequest(); @@ -274,9 +284,10 @@ class PhabricatorStandardPageView extends AphrontPageView { $admin_class = 'phabricator-admin-page-view'; } - return - ($console ? '' : null). - '
'. + $header_chrome = null; + $footer_chrome = null; + if ($this->getShowChrome()) { + $header_chrome = ''. ''. ''. @@ -300,13 +311,21 @@ class PhabricatorStandardPageView extends AphrontPageView { $login_stuff. ''. ''. - '
'. + ''; + $footer_chrome = + '
'. + $foot_links. + '
'; + } + + return + ($console ? '' : null). + '
'. + $header_chrome. $this->bodyContent. '
'. '
'. - '
'. - $foot_links. - '
'; + $footer_chrome; } protected function getTail() { @@ -316,4 +335,14 @@ class PhabricatorStandardPageView extends AphrontPageView { $response->renderHTMLFooter(); } + protected function getBodyClasses() { + $classes = array(); + + if (!$this->getShowChrome()) { + $classes[] = 'phabricator-chromeless-page'; + } + + return implode(' ', $classes); + } + } diff --git a/webroot/rsrc/css/application/base/standard-page-view.css b/webroot/rsrc/css/application/base/standard-page-view.css index c19d94e907..819e29d595 100644 --- a/webroot/rsrc/css/application/base/standard-page-view.css +++ b/webroot/rsrc/css/application/base/standard-page-view.css @@ -12,6 +12,15 @@ box-shadow: 0 0 6px #000; } +.phabricator-chromeless-page .phabricator-standard-page { + background: transparent; + border-width: 0px; + + -webkit-box-shadow: none; + -mox-box-shadow: none; + box-shadow: none; +} + .phabricator-standard-header { background: #005588; color: white; diff --git a/webroot/rsrc/css/application/countdown/timer.css b/webroot/rsrc/css/application/countdown/timer.css index dae77a6c20..22905f10e9 100644 --- a/webroot/rsrc/css/application/countdown/timer.css +++ b/webroot/rsrc/css/application/countdown/timer.css @@ -38,3 +38,8 @@ font-size: 4em; } +.phabricator-timer-chrome-link { + float: right; + padding: 3px 6px; + font-size: 11px; +} diff --git a/webroot/rsrc/css/core/core.css b/webroot/rsrc/css/core/core.css index 09d0b9a7ca..d31a481442 100644 --- a/webroot/rsrc/css/core/core.css +++ b/webroot/rsrc/css/core/core.css @@ -60,6 +60,10 @@ body { *font-size: small; } +body.phabricator-chromeless-page { + background: #ffffff; +} + select, input, button, textarea, button { font: 99% 'lucida grande', tahoma, verdana, arial, clean, sans-serif; }