1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-23 13:08:18 +01:00

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. <button>Send a message.</button>" 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
This commit is contained in:
Bob Trahan 2015-03-11 11:55:18 -07:00
parent 5ef99dba2a
commit 116f4625b6
2 changed files with 61 additions and 24 deletions

View file

@ -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);
}

View file

@ -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(