From 7e0c5162763ceb1b5f9e89f5b71559a26708110e Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 3 Apr 2015 10:12:10 -0700 Subject: [PATCH] Conpherence - add edit control for rooms Summary: Fixes T7582. Basically if its a room we should be able to change title + policy and if its a thread just the title. T7582 had ideas to do a dropdown but "view in column" doesn't make sense from conpherence afaik - what would the page you'd end up with the column be? (maybe home?) Anyway, that is iteration we can add laters Test Plan: edited room metadata successfully from main and column view. edtied thread title from main and column view. Reviewers: epriestley, chad Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7582 Differential Revision: https://secure.phabricator.com/D12252 --- .../ConpherenceUpdateController.php | 63 +++++++++++++++---- .../view/ConpherenceDurableColumnView.php | 2 +- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index e2c82e9318..1b7baa2505 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -120,25 +120,28 @@ final class ConpherenceUpdateController ->setContent($result); break; case ConpherenceUpdateActions::METADATA: - $updated = false; // all metadata updates are continue requests if (!$request->isContinueRequest()) { break; } $title = $request->getStr('title'); - if ($title != $conpherence->getTitle()) { + $xactions[] = id(new ConpherenceTransaction()) + ->setTransactionType(ConpherenceTransactionType::TYPE_TITLE) + ->setNewValue($title); + if ($conpherence->getIsRoom()) { $xactions[] = id(new ConpherenceTransaction()) - ->setTransactionType(ConpherenceTransactionType::TYPE_TITLE) - ->setNewValue($title); - $updated = true; - if (!$request->getExists('force_ajax')) { - $response_mode = 'redirect'; - } + ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) + ->setNewValue($request->getStr('viewPolicy')); + $xactions[] = id(new ConpherenceTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_EDIT_POLICY) + ->setNewValue($request->getStr('editPolicy')); + $xactions[] = id(new ConpherenceTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_JOIN_POLICY) + ->setNewValue($request->getStr('joinPolicy')); } - if (!$updated) { - $errors[] = pht( - 'That was a non-update. Try cancel.'); + if (!$request->getExists('force_ajax')) { + $response_mode = 'redirect'; } break; case ConpherenceUpdateActions::LOAD: @@ -164,6 +167,11 @@ final class ConpherenceUpdateController ->setCancelURI($this->getApplicationURI($conpherence_id.'/')) ->setException($ex); } + // xactions had no effect...! + if (empty($xactions)) { + $errors[] = pht( + 'That was a non-update. Try cancel.'); + } } if ($xactions || ($action == ConpherenceUpdateActions::LOAD)) { @@ -293,6 +301,8 @@ final class ConpherenceUpdateController $error_view) { $request = $this->getRequest(); + $user = $request->getUser(); + $form = id(new PHUIFormLayoutView()) ->appendChild($error_view) ->appendChild( @@ -301,9 +311,38 @@ final class ConpherenceUpdateController ->setName('title') ->setValue($conpherence->getTitle())); + if ($conpherence->getIsRoom()) { + $title = pht('Update Room'); + $policies = id(new PhabricatorPolicyQuery()) + ->setViewer($user) + ->setObject($conpherence) + ->execute(); + + $form->appendChild( + id(new AphrontFormPolicyControl()) + ->setName('viewPolicy') + ->setPolicyObject($conpherence) + ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) + ->setPolicies($policies)) + ->appendChild( + id(new AphrontFormPolicyControl()) + ->setName('editPolicy') + ->setPolicyObject($conpherence) + ->setCapability(PhabricatorPolicyCapability::CAN_EDIT) + ->setPolicies($policies)) + ->appendChild( + id(new AphrontFormPolicyControl()) + ->setName('joinPolicy') + ->setPolicyObject($conpherence) + ->setCapability(PhabricatorPolicyCapability::CAN_JOIN) + ->setPolicies($policies)); + } else { + $title = pht('Update Thread'); + } + require_celerity_resource('conpherence-update-css'); $view = id(new AphrontDialogView()) - ->setTitle(pht('Update Conpherence')) + ->setTitle($title) ->addHiddenInput('action', 'metadata') ->addHiddenInput( 'latest_transaction_id', diff --git a/src/applications/conpherence/view/ConpherenceDurableColumnView.php b/src/applications/conpherence/view/ConpherenceDurableColumnView.php index 7fd765ad0b..fd0cba5c0d 100644 --- a/src/applications/conpherence/view/ConpherenceDurableColumnView.php +++ b/src/applications/conpherence/view/ConpherenceDurableColumnView.php @@ -381,7 +381,7 @@ final class ConpherenceDurableColumnView extends AphrontTagView { private function getHeaderActionsConfig(ConpherenceThread $conpherence) { if ($conpherence->getIsRoom()) { - $rename_label = pht('Rename Room'); + $rename_label = pht('Edit Room'); } else { $rename_label = pht('Rename Thread'); }