Make pressing "R" on your keyboard reload the card state on workboards

Summary:
Depends on D20638. Ref T4900. This is an incremental step toward proper workboard updates.

Currently, the client can mostly update its view because we do updates when you edit or move a card, and the client and server know how to send lists of card updates, so a lot of the work is already done.

However, the code assumes we're only updating/redrawing one card at a time. Make the client accept and process multiple card updates.

In future changes, I'll add versioning (so we only update cards that have actually changed), fix the "TODO" around ordering, and move toward actual Aphlict-based real-time updates.

Test Plan:
  - Opened the same workboard in two windows.
  - Edited cards in one window, pressed "R" (capital letter, with no modifier keys) to reload the second window.
  - Saw edits and moves reflected accurately after sync, except for some special cases of header/order interaction (see "TODO").

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T4900

Differential Revision: https://secure.phabricator.com/D20639
This commit is contained in:
epriestley
2019-07-02 10:33:13 -07:00
parent 97c1699756
commit db69686927
9 changed files with 283 additions and 129 deletions

View File

@@ -0,0 +1,38 @@
<?php
final class PhabricatorProjectBoardReloadController
extends PhabricatorProjectBoardController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$response = $this->loadProject();
if ($response) {
return $response;
}
$project = $this->getProject();
$state = $this->getViewState();
$board_uri = $state->newWorkboardURI();
$layout_engine = $state->getLayoutEngine();
$board_phid = $project->getPHID();
$objects = $state->getObjects();
$object_phids = mpull($objects, 'getPHID');
$engine = id(new PhabricatorBoardResponseEngine())
->setViewer($viewer)
->setBoardPHID($board_phid)
->setUpdatePHIDs($object_phids);
// TODO: We don't currently process "order" properly. If a user is viewing
// a board grouped by "Owner", and another user changes a task to be owned
// by a user who currently owns nothing on the board, the new header won't
// generate correctly if the first user presses "R".
return $engine->buildResponse();
}
}