From 116f4625b6ca01772141e0ca45949f450e903a06 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 11 Mar 2015 11:55:18 -0700 Subject: [PATCH] Conpherence - add support for users with no conpherences in durable column view Summary: Ref T7014. This just makes it so there's almost no UI and a simple "You have no messages. " UI Test Plan: hacked the code such that should_404 and conpherence were false and null respectively. verified i got the right ui in the durable column. verified send a message button worked, ending up with me in main conpherence view on the right message Reviewers: chad, epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7014 Differential Revision: https://secure.phabricator.com/D12042 --- .../ConpherenceColumnViewController.php | 51 ++++++++++++------- .../view/ConpherenceDurableColumnView.php | 34 ++++++++++--- 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/src/applications/conpherence/controller/ConpherenceColumnViewController.php b/src/applications/conpherence/controller/ConpherenceColumnViewController.php index aaead4108c..93b17bf5d1 100644 --- a/src/applications/conpherence/controller/ConpherenceColumnViewController.php +++ b/src/applications/conpherence/controller/ConpherenceColumnViewController.php @@ -25,6 +25,7 @@ final class ConpherenceColumnViewController extends } $conpherence = null; + $should_404 = false; if ($request->getInt('id')) { $conpherence = id(new ConpherenceThreadQuery()) ->setViewer($user) @@ -32,6 +33,7 @@ final class ConpherenceColumnViewController extends ->needTransactions(true) ->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT) ->executeOne(); + $should_404 = true; } else if ($latest_participant) { $participant = head($latest_participant); $conpherence = id(new ConpherenceThreadQuery()) @@ -40,31 +42,44 @@ final class ConpherenceColumnViewController extends ->needTransactions(true) ->setTransactionLimit(ConpherenceThreadQuery::TRANSACTION_LIMIT) ->executeOne(); + $should_404 = true; } - if (!$conpherence) { - return new Aphront404Response(); - } - $this->setConpherence($conpherence); - - $participant = $conpherence->getParticipant($user->getPHID()); - $transactions = $conpherence->getTransactions(); - $latest_transaction = head($transactions); - $write_guard = AphrontWriteGuard::beginScopedUnguardedWrites(); - $participant->markUpToDate($conpherence, $latest_transaction); - unset($write_guard); - $durable_column = id(new ConpherenceDurableColumnView()) ->setUser($user) - ->setSelectedConpherence($conpherence) - ->setConpherences($latest_conpherences) - ->setStyle(null); + ->setVisible(true); + if (!$conpherence) { + if ($should_404) { + return new Aphront404Response(); + } + + $conpherence_id = null; + $conpherence_phid = null; + $latest_transaction_id = null; + + } else { + $this->setConpherence($conpherence); + + $participant = $conpherence->getParticipant($user->getPHID()); + $transactions = $conpherence->getTransactions(); + $latest_transaction = head($transactions); + $write_guard = AphrontWriteGuard::beginScopedUnguardedWrites(); + $participant->markUpToDate($conpherence, $latest_transaction); + unset($write_guard); + + $durable_column + ->setSelectedConpherence($conpherence) + ->setConpherences($latest_conpherences); + $conpherence_id = $conpherence->getID(); + $conpherence_phid = $conpherence->getPHID(); + $latest_transaction_id = $latest_transaction->getID(); + } $response = array( 'content' => hsprintf('%s', $durable_column), - 'threadID' => $conpherence->getID(), - 'threadPHID' => $conpherence->getPHID(), - 'latestTransactionID' => $latest_transaction->getID(),); + 'threadID' => $conpherence_id, + 'threadPHID' => $conpherence_phid, + 'latestTransactionID' => $latest_transaction_id,); return id(new AphrontAjaxResponse())->setContent($response); } diff --git a/src/applications/conpherence/view/ConpherenceDurableColumnView.php b/src/applications/conpherence/view/ConpherenceDurableColumnView.php index 9154853698..5e356ea177 100644 --- a/src/applications/conpherence/view/ConpherenceDurableColumnView.php +++ b/src/applications/conpherence/view/ConpherenceDurableColumnView.php @@ -193,7 +193,7 @@ final class ConpherenceDurableColumnView extends AphrontTagView { if (!$conpherence) { - $title = pht('Loading...'); + $title = null; $settings_button = null; $settings_menu = null; @@ -306,7 +306,24 @@ final class ConpherenceDurableColumnView extends AphrontTagView { private function buildTransactions() { $conpherence = $this->getSelectedConpherence(); if (!$conpherence) { - return pht('Loading...'); + if (!$this->getVisible()) { + return pht('Loading...'); + } + return array( + phutil_tag( + 'div', + array( + 'class' => 'mmb', + ), + pht('You do not have any messages yet.')), + javelin_tag( + 'a', + array( + 'href' => '/conpherence/new/', + 'class' => 'button grey', + 'sigil' => 'workflow', + ), + pht('Send a Message')),); } $data = ConpherenceTransactionView::renderTransactions( @@ -322,6 +339,10 @@ final class ConpherenceDurableColumnView extends AphrontTagView { private function buildTextInput() { $conpherence = $this->getSelectedConpherence(); + if (!$conpherence) { + return null; + } + $textarea = javelin_tag( 'textarea', array( @@ -330,10 +351,6 @@ final class ConpherenceDurableColumnView extends AphrontTagView { 'sigil' => 'conpherence-durable-column-textarea', 'placeholder' => pht('Send a message...'), )); - if (!$conpherence) { - return $textarea; - } - $id = $conpherence->getID(); return phabricator_form( $this->getUser(), @@ -358,6 +375,11 @@ final class ConpherenceDurableColumnView extends AphrontTagView { } private function buildSendButton() { + $conpherence = $this->getSelectedConpherence(); + if (!$conpherence) { + return null; + } + return javelin_tag( 'button', array(