From 9b9a8001faae7768876b9620eeac94ce2c3ddb31 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Mon, 9 Mar 2015 12:09:43 -0700 Subject: [PATCH] Conpherence - add ability to change title in the durable column Summary: Ref T7014. Test Plan: changed the conpherence title from the column. since i can't get scrolling to work, i inspect the dom to verify the title change transaction showed up properly Reviewers: epriestley, chad Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7014 Differential Revision: https://secure.phabricator.com/D12002 --- resources/celerity/map.php | 24 ++++----- .../controller/ConpherenceController.php | 16 ++++-- .../ConpherenceUpdateController.php | 17 ++++++- .../controller/ConpherenceViewController.php | 5 +- .../view/ConpherenceDurableColumnView.php | 9 +++- .../conpherence/durable-column.css | 1 + .../conpherence/behavior-durable-column.js | 51 ++++++++++++++++--- 7 files changed, 93 insertions(+), 30 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 1e06d8276f..9681e5c69b 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -44,7 +44,7 @@ return array( 'rsrc/css/application/config/config-welcome.css' => '6abd79be', 'rsrc/css/application/config/setup-issue.css' => '22270af2', 'rsrc/css/application/config/unhandled-exception.css' => '37d4f9a2', - 'rsrc/css/application/conpherence/durable-column.css' => '1ef6ae75', + 'rsrc/css/application/conpherence/durable-column.css' => '9207426d', 'rsrc/css/application/conpherence/menu.css' => 'c6ac5299', 'rsrc/css/application/conpherence/message-pane.css' => '5930260a', 'rsrc/css/application/conpherence/notification.css' => '04a6e10a', @@ -351,7 +351,7 @@ return array( 'rsrc/js/application/aphlict/behavior-aphlict-status.js' => 'ea681761', 'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18', 'rsrc/js/application/config/behavior-reorder-fields.js' => '14a827de', - 'rsrc/js/application/conpherence/behavior-durable-column.js' => 'd32db212', + 'rsrc/js/application/conpherence/behavior-durable-column.js' => 'e4affa94', 'rsrc/js/application/conpherence/behavior-menu.js' => '869e3445', 'rsrc/js/application/conpherence/behavior-pontificate.js' => '86df5915', 'rsrc/js/application/conpherence/behavior-widget-pane.js' => '40b1ff90', @@ -512,7 +512,7 @@ return array( 'changeset-view-manager' => 'a9af1212', 'config-options-css' => '7fedf08b', 'config-welcome-css' => '6abd79be', - 'conpherence-durable-column-view' => '1ef6ae75', + 'conpherence-durable-column-view' => '9207426d', 'conpherence-menu-css' => 'c6ac5299', 'conpherence-message-pane-css' => '5930260a', 'conpherence-notification-css' => '04a6e10a', @@ -582,7 +582,7 @@ return array( 'javelin-behavior-diffusion-locate-file' => '6d3e1947', 'javelin-behavior-diffusion-pull-lastmodified' => '2b228192', 'javelin-behavior-doorkeeper-tag' => 'e5822781', - 'javelin-behavior-durable-column' => 'd32db212', + 'javelin-behavior-durable-column' => 'e4affa94', 'javelin-behavior-error-log' => '6882e80a', 'javelin-behavior-fancy-datepicker' => 'c51ae228', 'javelin-behavior-global-drag-and-drop' => '07f199d8', @@ -1756,14 +1756,6 @@ return array( 'd254d646' => array( 'javelin-util', ), - 'd32db212' => array( - 'javelin-behavior', - 'javelin-dom', - 'javelin-stratcom', - 'javelin-scrollbar', - 'javelin-quicksand', - 'phabricator-keyboard-shortcut', - ), 'd3aa4b40' => array( 'javelin-dom', 'javelin-util', @@ -1844,6 +1836,14 @@ return array( 'javelin-dom', 'javelin-uri', ), + 'e4affa94' => array( + 'javelin-behavior', + 'javelin-dom', + 'javelin-stratcom', + 'javelin-scrollbar', + 'javelin-quicksand', + 'phabricator-keyboard-shortcut', + ), 'e4cc26b3' => array( 'javelin-behavior', 'javelin-dom', diff --git a/src/applications/conpherence/controller/ConpherenceController.php b/src/applications/conpherence/controller/ConpherenceController.php index 85b0a8a71b..fdccc8d77d 100644 --- a/src/applications/conpherence/controller/ConpherenceController.php +++ b/src/applications/conpherence/controller/ConpherenceController.php @@ -62,11 +62,7 @@ abstract class ConpherenceController extends PhabricatorController { protected function buildHeaderPaneContent(ConpherenceThread $conpherence) { $crumbs = $this->buildApplicationCrumbs(); - if ($conpherence->getTitle()) { - $title = $conpherence->getTitle(); - } else { - $title = pht('[No Title]'); - } + $title = $this->getConpherenceTitle($conpherence); $crumbs->addCrumb( id(new PHUICrumbView()) ->setName($title) @@ -85,4 +81,14 @@ abstract class ConpherenceController extends PhabricatorController { $crumbs, )); } + + protected function getConpherenceTitle(ConpherenceThread $conpherence) { + if ($conpherence->getTitle()) { + $title = $conpherence->getTitle(); + } else { + $title = pht('[No Title]'); + } + return $title; + } + } diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index a5c4ddf598..8e54a518f6 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -108,7 +108,9 @@ final class ConpherenceUpdateController ->setTransactionType(ConpherenceTransactionType::TYPE_TITLE) ->setNewValue($title); $updated = true; - $response_mode = 'redirect'; + if (!$request->getExists('force_ajax')) { + $response_mode = 'redirect'; + } } if (!$updated) { $errors[] = pht( @@ -271,7 +273,7 @@ final class ConpherenceUpdateController ->setValue($conpherence->getTitle())); require_celerity_resource('conpherence-update-css'); - return id(new AphrontDialogView()) + $view = id(new AphrontDialogView()) ->setTitle(pht('Update Conpherence')) ->addHiddenInput('action', 'metadata') ->addHiddenInput( @@ -279,6 +281,15 @@ final class ConpherenceUpdateController $request->getInt('latest_transaction_id')) ->addHiddenInput('__continue__', true) ->appendChild($form); + + if ($request->getExists('minimal_display')) { + $view->addHiddenInput('minimal_display', true); + } + if ($request->getExists('force_ajax')) { + $view->addHiddenInput('force_ajax', true); + } + + return $view; } private function loadAndRenderUpdates( @@ -361,8 +372,10 @@ final class ConpherenceUpdateController if ($people_widget) { $people_html = hsprintf('%s', $people_widget->render()); } + $title = $this->getConpherenceTitle($conpherence); $content = array( 'transactions' => hsprintf('%s', $rendered_transactions), + 'conpherence_title' => (string) $title, 'latest_transaction_id' => $new_latest_transaction_id, 'nav_item' => hsprintf('%s', $nav_item), 'conpherence_phid' => $conpherence->getPHID(), diff --git a/src/applications/conpherence/controller/ConpherenceViewController.php b/src/applications/conpherence/controller/ConpherenceViewController.php index 8fb94a5157..160a1f0ab5 100644 --- a/src/applications/conpherence/controller/ConpherenceViewController.php +++ b/src/applications/conpherence/controller/ConpherenceViewController.php @@ -54,10 +54,7 @@ final class ConpherenceViewController extends ); } - $title = $conpherence->getTitle(); - if (!$title) { - $title = pht('[No Title]'); - } + $title = $this->getConpherenceTitle($conpherence); $content['title'] = $title; if ($request->isAjax()) { diff --git a/src/applications/conpherence/view/ConpherenceDurableColumnView.php b/src/applications/conpherence/view/ConpherenceDurableColumnView.php index 2ff864e496..9478c5a564 100644 --- a/src/applications/conpherence/view/ConpherenceDurableColumnView.php +++ b/src/applications/conpherence/view/ConpherenceDurableColumnView.php @@ -205,9 +205,10 @@ final class ConpherenceDurableColumnView extends AphrontTagView { 'class' => 'conpherence-durable-column-header', ), array( - phutil_tag( + javelin_tag( 'div', array( + 'sigil' => 'conpherence-durable-column-header-text', 'class' => 'conpherence-durable-column-header-text', ), $title), @@ -224,6 +225,12 @@ final class ConpherenceDurableColumnView extends AphrontTagView { 'icon' => 'fa-plus', 'key' => ConpherenceUpdateActions::ADD_PERSON, ), + array( + 'name' => pht('Rename Thread'), + 'href' => '/conpherence/update/'.$conpherence->getID().'/', + 'icon' => 'fa-pencil', + 'key' => ConpherenceUpdateActions::METADATA, + ), array( 'name' => pht('View in Conpherence'), 'href' => '/conpherence/'.$conpherence->getID().'/', diff --git a/webroot/rsrc/css/application/conpherence/durable-column.css b/webroot/rsrc/css/application/conpherence/durable-column.css index ec21650eef..6fb72d2f37 100644 --- a/webroot/rsrc/css/application/conpherence/durable-column.css +++ b/webroot/rsrc/css/application/conpherence/durable-column.css @@ -50,6 +50,7 @@ .conpherence-durable-column-header-text:hover { color: #fff; + text-decoration: none; } .conpherence-durable-column-icon-bar { diff --git a/webroot/rsrc/js/application/conpherence/behavior-durable-column.js b/webroot/rsrc/js/application/conpherence/behavior-durable-column.js index 8ea94f14a4..fd4c8368bf 100644 --- a/webroot/rsrc/js/application/conpherence/behavior-durable-column.js +++ b/webroot/rsrc/js/application/conpherence/behavior-durable-column.js @@ -90,7 +90,7 @@ JX.behavior('durable-column', function() { knownID: latestTransactionID }; workflow.listen('finally', function() { - var need_sync = (updating.knownID > latestTransactionID); + var need_sync = (updating && updating.knownID > latestTransactionID); updating = null; if (need_sync) { update_thread(); @@ -134,11 +134,43 @@ JX.behavior('durable-column', function() { var data = e.getNodeData('conpherence-durable-column-header-action'); var action = data.action; var link = e.getNode('tag:a'); + var params = null; switch (action) { + case 'metadata': + JX.Stratcom.invoke('notification-panel-close'); + params = { + action: action, + latest_transaction_id: latestTransactionID, + minimal_display: true, + force_ajax: true + }; + var workflow = new JX.Workflow.newFromLink(link) + .setData(params) + .setHandler(function(r) { + var messages = _getColumnMessagesNode(); + JX.DOM.appendContent(messages, JX.$H(r.transactions)); + messages.scrollTop = messages.scrollHeight; + + var title = _getColumnTitleNode(); + JX.DOM.setContent(title, r.conpherence_title); + + latestTransactionID = r.latest_transaction_id; + // since this is a two step workflow, and the "finally" method + // gets called on the first form load, restore "updating" if + // necessary + if (updating === null) { + updating = { + threadPHID: loadedThreadPHID, + knownID: latestTransactionID + }; + } + }); + sync_workflow(workflow); + break; case 'add_person': JX.Stratcom.invoke('notification-panel-close'); - var params = { + params = { action: action, latest_transaction_id: latestTransactionID, minimal_display: true @@ -193,6 +225,14 @@ JX.behavior('durable-column', function() { 'conpherence-durable-column-transactions'); } + function _getColumnTitleNode() { + var column = JX.$('conpherence-durable-column'); + return JX.DOM.find( + column, + 'div', + 'conpherence-durable-column-header-text'); + } + function _getColumnFormNode() { var column = JX.$('conpherence-durable-column'); return JX.DOM.find( @@ -231,7 +271,6 @@ JX.behavior('durable-column', function() { // We can pick a thread from the server the first time if (shouldInit) { shouldInit = false; - params = { shouldInit : true }; } else { params = { id : thread_id }; } @@ -282,9 +321,9 @@ JX.behavior('durable-column', function() { } JX.Stratcom.listen( - 'click', - 'conpherence-send-message', - _sendMessage); + 'click', + 'conpherence-send-message', + _sendMessage); JX.Stratcom.listen( ['submit', 'didSyntheticSubmit'],