1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 12:00:55 +01:00

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
This commit is contained in:
Bob Trahan 2015-04-03 10:12:10 -07:00
parent 2b3d3cf7e4
commit 7e0c516276
2 changed files with 52 additions and 13 deletions

View file

@ -120,26 +120,29 @@ 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);
$updated = true;
if ($conpherence->getIsRoom()) {
$xactions[] = id(new ConpherenceTransaction())
->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 (!$request->getExists('force_ajax')) {
$response_mode = 'redirect';
}
}
if (!$updated) {
$errors[] = pht(
'That was a non-update. Try cancel.');
}
break;
case ConpherenceUpdateActions::LOAD:
$updated = false;
@ -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',

View file

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