1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-08 04:48:28 +01:00

Update Conpherence to use EditEngine

Summary: Moves Conpherence to use EditEngine. This removes the "First Message" field, but I think that's ok until we have direct messaging of some sort, then maybe have built-ins cover that case.

Test Plan:
 - Visit /new/ and /edit/ for creating new rooms.
 - Edit a room in full conpherence
 - Edit a room in durable column
 - grep for METADATA calls

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T11729

Differential Revision: https://secure.phabricator.com/D16677
This commit is contained in:
Chad Little 2017-04-26 10:48:50 -07:00
parent d2baa88171
commit d6bce34a5d
12 changed files with 157 additions and 241 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => 'ff161f2d',
'conpherence.pkg.js' => 'b5b51108',
'core.pkg.css' => '84ce260a',
'core.pkg.js' => 'fffe0122',
'core.pkg.js' => '2ff7879f',
'darkconsole.pkg.js' => '1f9a31bc',
'differential.pkg.css' => '90b30783',
'differential.pkg.js' => 'ddfeb49b',
@ -378,7 +378,7 @@ return array(
'rsrc/js/application/config/behavior-reorder-fields.js' => 'b6993408',
'rsrc/js/application/conpherence/ConpherenceThreadManager.js' => '4d863052',
'rsrc/js/application/conpherence/behavior-conpherence-search.js' => '9bbf3762',
'rsrc/js/application/conpherence/behavior-durable-column.js' => 'aa3bd034',
'rsrc/js/application/conpherence/behavior-durable-column.js' => '2ae077e1',
'rsrc/js/application/conpherence/behavior-menu.js' => 'c9b99b77',
'rsrc/js/application/conpherence/behavior-participant-pane.js' => '8604caa8',
'rsrc/js/application/conpherence/behavior-pontificate.js' => '55616e04',
@ -639,7 +639,7 @@ return array(
'javelin-behavior-diffusion-pull-lastmodified' => 'f01586dc',
'javelin-behavior-doorkeeper-tag' => 'e5822781',
'javelin-behavior-drydock-live-operation-status' => '901935ef',
'javelin-behavior-durable-column' => 'aa3bd034',
'javelin-behavior-durable-column' => '2ae077e1',
'javelin-behavior-editengine-reorder-configs' => 'd7a74243',
'javelin-behavior-editengine-reorder-fields' => 'b59e1e96',
'javelin-behavior-error-log' => '6882e80a',
@ -1095,6 +1095,16 @@ return array(
'javelin-install',
'javelin-util',
),
'2ae077e1' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
'javelin-behavior-device',
'javelin-scrollbar',
'javelin-quicksand',
'phabricator-keyboard-shortcut',
'conpherence-thread-manager',
),
'2b8de964' => array(
'javelin-install',
'javelin-util',
@ -1793,16 +1803,6 @@ return array(
'javelin-util',
'phabricator-prefab',
),
'aa3bd034' => array(
'javelin-behavior',
'javelin-dom',
'javelin-stratcom',
'javelin-behavior-device',
'javelin-scrollbar',
'javelin-quicksand',
'phabricator-keyboard-shortcut',
'conpherence-thread-manager',
),
'ab2f381b' => array(
'javelin-request',
'javelin-behavior',

View file

@ -292,13 +292,13 @@ phutil_register_library_map(array(
'ConpherenceCreateThreadConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceCreateThreadConduitAPIMethod.php',
'ConpherenceDAO' => 'applications/conpherence/storage/ConpherenceDAO.php',
'ConpherenceDurableColumnView' => 'applications/conpherence/view/ConpherenceDurableColumnView.php',
'ConpherenceEditEngine' => 'applications/conpherence/editor/ConpherenceEditEngine.php',
'ConpherenceEditor' => 'applications/conpherence/editor/ConpherenceEditor.php',
'ConpherenceFulltextQuery' => 'applications/conpherence/query/ConpherenceFulltextQuery.php',
'ConpherenceIndex' => 'applications/conpherence/storage/ConpherenceIndex.php',
'ConpherenceLayoutView' => 'applications/conpherence/view/ConpherenceLayoutView.php',
'ConpherenceListController' => 'applications/conpherence/controller/ConpherenceListController.php',
'ConpherenceMenuItemView' => 'applications/conpherence/view/ConpherenceMenuItemView.php',
'ConpherenceNewRoomController' => 'applications/conpherence/controller/ConpherenceNewRoomController.php',
'ConpherenceNotificationPanelController' => 'applications/conpherence/controller/ConpherenceNotificationPanelController.php',
'ConpherenceParticipant' => 'applications/conpherence/storage/ConpherenceParticipant.php',
'ConpherenceParticipantController' => 'applications/conpherence/controller/ConpherenceParticipantController.php',
@ -308,6 +308,7 @@ phutil_register_library_map(array(
'ConpherenceQueryThreadConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceQueryThreadConduitAPIMethod.php',
'ConpherenceQueryTransactionConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceQueryTransactionConduitAPIMethod.php',
'ConpherenceReplyHandler' => 'applications/conpherence/mail/ConpherenceReplyHandler.php',
'ConpherenceRoomEditController' => 'applications/conpherence/controller/ConpherenceRoomEditController.php',
'ConpherenceRoomListController' => 'applications/conpherence/controller/ConpherenceRoomListController.php',
'ConpherenceRoomPictureController' => 'applications/conpherence/controller/ConpherenceRoomPictureController.php',
'ConpherenceRoomPreferencesController' => 'applications/conpherence/controller/ConpherenceRoomPreferencesController.php',
@ -5074,13 +5075,13 @@ phutil_register_library_map(array(
'ConpherenceCreateThreadConduitAPIMethod' => 'ConpherenceConduitAPIMethod',
'ConpherenceDAO' => 'PhabricatorLiskDAO',
'ConpherenceDurableColumnView' => 'AphrontTagView',
'ConpherenceEditEngine' => 'PhabricatorEditEngine',
'ConpherenceEditor' => 'PhabricatorApplicationTransactionEditor',
'ConpherenceFulltextQuery' => 'PhabricatorOffsetPagedQuery',
'ConpherenceIndex' => 'ConpherenceDAO',
'ConpherenceLayoutView' => 'AphrontTagView',
'ConpherenceListController' => 'ConpherenceController',
'ConpherenceMenuItemView' => 'AphrontTagView',
'ConpherenceNewRoomController' => 'ConpherenceController',
'ConpherenceNotificationPanelController' => 'ConpherenceController',
'ConpherenceParticipant' => 'ConpherenceDAO',
'ConpherenceParticipantController' => 'ConpherenceController',
@ -5090,6 +5091,7 @@ phutil_register_library_map(array(
'ConpherenceQueryThreadConduitAPIMethod' => 'ConpherenceConduitAPIMethod',
'ConpherenceQueryTransactionConduitAPIMethod' => 'ConpherenceConduitAPIMethod',
'ConpherenceReplyHandler' => 'PhabricatorMailReplyHandler',
'ConpherenceRoomEditController' => 'ConpherenceController',
'ConpherenceRoomListController' => 'ConpherenceController',
'ConpherenceRoomPictureController' => 'ConpherenceController',
'ConpherenceRoomPreferencesController' => 'ConpherenceController',

View file

@ -45,8 +45,10 @@ final class PhabricatorConpherenceApplication extends PhabricatorApplication {
=> 'ConpherenceViewController',
'columnview/'
=> 'ConpherenceColumnViewController',
'new/'
=> 'ConpherenceNewRoomController',
$this->getEditRoutePattern('new/')
=> 'ConpherenceRoomEditController',
$this->getEditRoutePattern('edit/')
=> 'ConpherenceRoomEditController',
'picture/(?P<id>[1-9]\d*)/'
=> 'ConpherenceRoomPictureController',
'search/(?:query/(?P<queryKey>[^/]+)/)?'

View file

@ -2,7 +2,6 @@
final class ConpherenceUpdateActions extends ConpherenceConstants {
const METADATA = 'metadata';
const MESSAGE = 'message';
const DRAFT = 'draft';
const JOIN_ROOM = 'join_room';

View file

@ -91,7 +91,8 @@ abstract class ConpherenceController extends PhabricatorController {
$header->addActionItem(
id(new PHUIIconCircleView())
->setHref($this->getApplicationURI("update/{$id}/"))
->setHref(
$this->getApplicationURI('edit/'.$conpherence->getID()).'/')
->setIcon('fa-pencil')
->addClass('hide-on-device')
->setColor('violet')

View file

@ -1,117 +0,0 @@
<?php
final class ConpherenceNewRoomController extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
$user = $request->getUser();
$title = pht('New Room');
$e_title = true;
$validation_exception = null;
$conpherence = ConpherenceThread::initializeNewRoom($user);
$participants = array();
if ($request->isFormPost()) {
$editor = new ConpherenceEditor();
$xactions = array();
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
->setNewValue($request->getStr('title'));
$participants = $request->getArr('participants');
$participants[] = $user->getPHID();
$participants = array_unique($participants);
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setNewValue(array('+' => $participants));
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
->setNewValue($request->getStr('topic'));
$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'));
try {
$editor
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->setActor($user)
->applyTransactions($conpherence, $xactions);
return id(new AphrontRedirectResponse())
->setURI('/'.$conpherence->getMonogram());
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
$e_title = $ex->getShortMessage(
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE);
$conpherence->setViewPolicy($request->getStr('viewPolicy'));
$conpherence->setEditPolicy($request->getStr('editPolicy'));
}
} else {
if ($request->getStr('participant')) {
$participants[] = $request->getStr('participant');
}
}
$policies = id(new PhabricatorPolicyQuery())
->setViewer($user)
->setObject($conpherence)
->execute();
$submit_uri = $this->getApplicationURI('new/');
$cancel_uri = $this->getApplicationURI('search/');
$dialog = $this->newDialog()
->setWidth(AphrontDialogView::WIDTH_FORM)
->setValidationException($validation_exception)
->setUser($user)
->setTitle($title)
->addCancelButton($cancel_uri)
->addSubmitButton(pht('Create Room'));
$form = id(new PHUIFormLayoutView())
->setUser($user)
->appendChild(
id(new AphrontFormTextControl())
->setError($e_title)
->setLabel(pht('Name'))
->setName('title')
->setValue($request->getStr('title')))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Topic'))
->setName('topic')
->setValue($request->getStr('topic')))
->appendChild(
id(new AphrontFormTokenizerControl())
->setName('participants')
->setUser($user)
->setDatasource(new PhabricatorPeopleDatasource())
->setValue($participants)
->setLabel(pht('Other Participants')))
->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));
$dialog->appendChild($form);
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}

View file

@ -0,0 +1,11 @@
<?php
final class ConpherenceRoomEditController
extends ConpherenceController {
public function handleRequest(AphrontRequest $request) {
return id(new ConpherenceEditEngine())
->setController($this)
->buildResponse();
}
}

View file

@ -12,7 +12,7 @@ final class ConpherenceUpdateController
$need_participants = false;
$needed_capabilities = array(PhabricatorPolicyCapability::CAN_VIEW);
$action = $request->getStr('action', ConpherenceUpdateActions::METADATA);
$action = $request->getStr('action');
switch ($action) {
case ConpherenceUpdateActions::REMOVE_PERSON:
$person_phid = $request->getStr('remove_person');
@ -21,7 +21,6 @@ final class ConpherenceUpdateController
}
break;
case ConpherenceUpdateActions::ADD_PERSON:
case ConpherenceUpdateActions::METADATA:
$needed_capabilities[] = PhabricatorPolicyCapability::CAN_EDIT;
break;
case ConpherenceUpdateActions::LOAD:
@ -110,35 +109,6 @@ final class ConpherenceUpdateController
$response_mode = 'go-home';
}
break;
case ConpherenceUpdateActions::METADATA:
$title = $request->getStr('title');
$topic = $request->getStr('topic');
// all other metadata updates are continue requests
if (!$request->isContinueRequest()) {
break;
}
$title = $request->getStr('title');
$topic = $request->getStr('topic');
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
->setNewValue($title);
$xactions[] = id(new ConpherenceTransaction())
->setTransactionType(
ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
->setNewValue($topic);
$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'));
if (!$request->getExists('force_ajax')) {
$response_mode = 'redirect';
}
break;
case ConpherenceUpdateActions::LOAD:
$updated = false;
$response_mode = 'ajax';
@ -208,10 +178,6 @@ final class ConpherenceUpdateController
case ConpherenceUpdateActions::REMOVE_PERSON:
$dialog = $this->renderRemovePersonDialog($conpherence);
break;
case ConpherenceUpdateActions::METADATA:
default:
$dialog = $this->renderMetadataDialog($conpherence, $error_view);
break;
}
return
@ -332,62 +298,6 @@ final class ConpherenceUpdateController
return $dialog;
}
private function renderMetadataDialog(
ConpherenceThread $conpherence,
$error_view) {
$request = $this->getRequest();
$user = $request->getUser();
$title = pht('Update Room');
$form = id(new PHUIFormLayoutView())
->appendChild($error_view)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Title'))
->setName('title')
->setValue($conpherence->getTitle()))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Topic'))
->setName('topic')
->setValue($conpherence->getTopic()));
$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));
$view = id(new AphrontDialogView())
->setTitle($title)
->addHiddenInput('action', 'metadata')
->addHiddenInput(
'latest_transaction_id',
$request->getInt('latest_transaction_id'))
->addHiddenInput('__continue__', true)
->appendChild($form);
if ($request->getExists('force_ajax')) {
$view->addHiddenInput('force_ajax', true);
}
return $view;
}
private function loadAndRenderUpdates(
$action,
$conpherence_id,
@ -395,7 +305,6 @@ final class ConpherenceUpdateController
$need_transactions = false;
switch ($action) {
case ConpherenceUpdateActions::METADATA:
case ConpherenceUpdateActions::LOAD:
$need_transactions = true;
break;
@ -444,15 +353,6 @@ final class ConpherenceUpdateController
$header = null;
$people_widget = null;
switch ($action) {
case ConpherenceUpdateActions::METADATA:
$header = $this->buildHeaderPaneContent($conpherence);
$header = hsprintf('%s', $header);
$nav_item = id(new ConpherenceThreadListView())
->setUser($user)
->setBaseURI($this->getApplicationURI())
->renderThreadItem($conpherence);
$nav_item = hsprintf('%s', $nav_item);
break;
case ConpherenceUpdateActions::ADD_PERSON:
$people_widget = id(new ConpherenceParticipantView())
->setUser($user)

View file

@ -0,0 +1,118 @@
<?php
final class ConpherenceEditEngine
extends PhabricatorEditEngine {
const ENGINECONST = 'conpherence.thread';
public function getEngineName() {
return pht('Conpherence');
}
public function getEngineApplicationClass() {
return 'PhabricatorConpherenceApplication';
}
public function getSummaryHeader() {
return pht('Configure Conpherence Forms');
}
public function getSummaryText() {
return pht('Configure creation and editing forms in Conpherence.');
}
protected function newEditableObject() {
return ConpherenceThread::initializeNewRoom($this->getViewer());
}
protected function newObjectQuery() {
return new ConpherenceThreadQuery();
}
protected function getObjectCreateTitleText($object) {
return pht('Create New Room');
}
protected function getObjectEditTitleText($object) {
return pht('Edit Room: %s', $object->getTitle());
}
protected function getObjectEditShortText($object) {
return $object->getTitle();
}
protected function getObjectCreateShortText() {
return pht('Create Room');
}
protected function getObjectName() {
return pht('Room');
}
protected function getObjectCreateCancelURI($object) {
return $this->getApplication()->getApplicationURI('/');
}
protected function getEditorURI() {
return $this->getApplication()->getApplicationURI('edit/');
}
protected function getObjectViewURI($object) {
return $object->getURI();
}
public function isEngineConfigurable() {
return false;
}
protected function buildCustomEditFields($object) {
$viewer = $this->getViewer();
if ($this->getIsCreate()) {
$participant_phids = array($viewer->getPHID());
$initial_phids = array();
} else {
$participant_phids = $object->getParticipantPHIDs();
$initial_phids = $participant_phids;
}
// Only show participants on create or conduit, not edit
$conduit_only = !$this->getIsCreate();
return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setDescription(pht('Room name.'))
->setConduitTypeDescription(pht('New Room name.'))
->setIsRequired(true)
->setTransactionType(
ConpherenceThreadTitleTransaction::TRANSACTIONTYPE)
->setValue($object->getTitle()),
id(new PhabricatorTextEditField())
->setKey('topic')
->setLabel(pht('Topic'))
->setDescription(pht('Room topic.'))
->setConduitTypeDescription(pht('New Room topic.'))
->setTransactionType(
ConpherenceThreadTopicTransaction::TRANSACTIONTYPE)
->setValue($object->getTopic()),
id(new PhabricatorUsersEditField())
->setKey('participants')
->setValue($participant_phids)
->setInitialValue($initial_phids)
->setIsConduitOnly($conduit_only)
->setAliases(array('users', 'members', 'participants', 'userPHID'))
->setDescription(pht('Room participants.'))
->setUseEdgeTransactions(true)
->setConduitTypeDescription(pht('New Room participants.'))
->setTransactionType(
ConpherenceThreadParticipantsTransaction::TRANSACTIONTYPE)
->setLabel(pht('Initial Participants')),
);
}
}

View file

@ -363,9 +363,9 @@ final class ConpherenceDurableColumnView extends AphrontTagView {
$actions[] = array(
'name' => pht('Edit Room'),
'disabled' => !$can_edit,
'href' => '/conpherence/update/'.$conpherence->getID().'/?nopic',
'href' => '/conpherence/edit/'.$conpherence->getID().'/',
'icon' => 'fa-pencil',
'key' => ConpherenceUpdateActions::METADATA,
'key' => 'go_edit',
);
$actions[] = array(
'name' => pht('View in Conpherence'),

View file

@ -117,7 +117,7 @@ final class ConpherenceThreadListView extends AphrontView {
$new_icon = id(new PHUIIconView())
->setIcon('fa-plus-square')
->addSigil('has-tooltip')
->setHref('/conpherence/new/')
->setHref('/conpherence/edit/')
->setWorkflow(true)
->setMetaData(array(
'tip' => pht('New Room'),

View file

@ -177,7 +177,7 @@ JX.behavior('durable-column', function(config, statics) {
var params = null;
switch (action) {
case 'metadata':
case 'go_edit':
threadManager.runUpdateWorkflowFromLink(
link,
{