Skip to content

Commit b6a38b4

Browse files
author
epriestley
committed
Add storage and read logic for workboard card cover photos
Summary: No way to set photos yet, but if you magic them in they work. Primarily, this consolidates rendering logic so the move + edit + view controllers all run the same code to do tags / cover photos. Test Plan: {F1095870} Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D15201
1 parent f097c9c commit b6a38b4

File tree

9 files changed

+237
-87
lines changed

9 files changed

+237
-87
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ALTER TABLE {$NAMESPACE}_maniphest.maniphest_task
2+
ADD properties LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT};
3+
4+
UPDATE {$NAMESPACE}_maniphest.maniphest_task
5+
SET properties = '{}' WHERE properties = '';

src/__phutil_library_map__.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1815,6 +1815,7 @@
18151815
'PhabricatorBinariesSetupCheck' => 'applications/config/check/PhabricatorBinariesSetupCheck.php',
18161816
'PhabricatorBitbucketAuthProvider' => 'applications/auth/provider/PhabricatorBitbucketAuthProvider.php',
18171817
'PhabricatorBoardLayoutEngine' => 'applications/project/engine/PhabricatorBoardLayoutEngine.php',
1818+
'PhabricatorBoardRenderingEngine' => 'applications/project/engine/PhabricatorBoardRenderingEngine.php',
18181819
'PhabricatorBot' => 'infrastructure/daemon/bot/PhabricatorBot.php',
18191820
'PhabricatorBotChannel' => 'infrastructure/daemon/bot/target/PhabricatorBotChannel.php',
18201821
'PhabricatorBotDebugLogHandler' => 'infrastructure/daemon/bot/handler/PhabricatorBotDebugLogHandler.php',
@@ -6043,6 +6044,7 @@
60436044
'PhabricatorBinariesSetupCheck' => 'PhabricatorSetupCheck',
60446045
'PhabricatorBitbucketAuthProvider' => 'PhabricatorOAuth1AuthProvider',
60456046
'PhabricatorBoardLayoutEngine' => 'Phobject',
6047+
'PhabricatorBoardRenderingEngine' => 'Phobject',
60466048
'PhabricatorBot' => 'PhabricatorDaemon',
60476049
'PhabricatorBotChannel' => 'PhabricatorBotTarget',
60486050
'PhabricatorBotDebugLogHandler' => 'PhabricatorBotHandler',

src/applications/files/transform/PhabricatorFileThumbnailTransform.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ final class PhabricatorFileThumbnailTransform
77
const TRANSFORM_PINBOARD = 'pinboard';
88
const TRANSFORM_THUMBGRID = 'thumbgrid';
99
const TRANSFORM_PREVIEW = 'preview';
10+
const TRANSFORM_WORKCARD = 'workcard';
1011

1112
private $name;
1213
private $key;
@@ -73,6 +74,10 @@ public function generateTransforms() {
7374
->setName(pht('Preview (220px)'))
7475
->setKey(self::TRANSFORM_PREVIEW)
7576
->setDimensions(220, null),
77+
id(new self())
78+
->setName(pht('Workcard (526px)'))
79+
->setKey(self::TRANSFORM_WORKCARD)
80+
->setDimensions(526, null),
7681
);
7782
}
7883

src/applications/maniphest/editor/ManiphestEditEngine.php

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -334,39 +334,27 @@ private function buildCardResponse(ManiphestTask $task) {
334334
'sortMap' => $sort_map,
335335
);
336336

337-
// TODO: This should just use HandlePool once we get through the EditEngine
338-
// transition.
339-
$owner = null;
340-
if ($task->getOwnerPHID()) {
341-
$owner = id(new PhabricatorHandleQuery())
342-
->setViewer($viewer)
343-
->withPHIDs(array($task->getOwnerPHID()))
344-
->executeOne();
345-
}
346-
347-
$handle_phids = $task->getProjectPHIDs();
348-
$handle_phids = array_fuse($handle_phids);
349-
$handle_phids = array_diff_key($handle_phids, $board_phids);
350-
351-
$project_handles = $viewer->loadHandles($handle_phids);
352-
$project_handles = iterator_to_array($project_handles);
353-
354-
$tasks = id(new ProjectBoardTaskCard())
337+
$rendering_engine = id(new PhabricatorBoardRenderingEngine())
355338
->setViewer($viewer)
356-
->setTask($task)
357-
->setOwner($owner)
358-
->setProjectHandles($project_handles)
359-
->setCanEdit(true)
360-
->getItem();
339+
->setObjects(array($task))
340+
->setExcludedProjectPHIDs($board_phids);
361341

362-
$tasks->addClass('phui-workcard');
342+
$card = $rendering_engine->renderCard($task->getPHID());
343+
344+
$item = $card->getItem();
345+
$item->addClass('phui-workcard');
363346

364347
$payload = array(
365-
'tasks' => $tasks,
348+
'tasks' => $item,
366349
'data' => $data,
367350
);
368351

369-
return id(new AphrontAjaxResponse())->setContent($payload);
352+
return id(new AphrontAjaxResponse())
353+
->setContent(
354+
array(
355+
'tasks' => $item,
356+
'data' => $data,
357+
));
370358
}
371359

372360

src/applications/maniphest/storage/ManiphestTask.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ final class ManiphestTask extends ManiphestDAO
3838

3939
protected $ownerOrdering;
4040
protected $spacePHID;
41+
protected $properties = array();
4142

4243
private $subscriberPHIDs = self::ATTACHABLE;
4344
private $groupByProjectPHID = self::ATTACHABLE;
@@ -74,6 +75,7 @@ protected function getConfiguration() {
7475
'ccPHIDs' => self::SERIALIZATION_JSON,
7576
'attached' => self::SERIALIZATION_JSON,
7677
'projectPHIDs' => self::SERIALIZATION_JSON,
78+
'properties' => self::SERIALIZATION_JSON,
7779
),
7880
self::CONFIG_COLUMN_SCHEMA => array(
7981
'ownerPHID' => 'phid?',
@@ -215,6 +217,19 @@ public function getPrioritySortVector() {
215217
);
216218
}
217219

220+
public function setProperty($key, $value) {
221+
$this->properties[$key] = $value;
222+
return $this;
223+
}
224+
225+
public function getProperty($key, $default = null) {
226+
return idx($this->properties, $key, $default);
227+
}
228+
229+
public function getCoverImageThumbnailPHID() {
230+
return idx($this->properties, 'cover.thumbnailPHID');
231+
}
232+
218233

219234
/* -( PhabricatorSubscribableInterface )----------------------------------- */
220235

src/applications/project/controller/PhabricatorProjectBoardViewController.php

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ final class PhabricatorProjectBoardViewController
77

88
private $id;
99
private $slug;
10-
private $handles;
1110
private $queryKey;
1211
private $filter;
1312
private $sortKey;
@@ -226,22 +225,9 @@ public function handleRequest(AphrontRequest $request) {
226225
'project-boards',
227226
$behavior_config);
228227

229-
$this->handles = ManiphestTaskListView::loadTaskHandles($viewer, $tasks);
230-
231-
$all_project_phids = array();
232-
foreach ($tasks as $task) {
233-
foreach ($task->getProjectPHIDs() as $project_phid) {
234-
$all_project_phids[$project_phid] = $project_phid;
235-
}
236-
}
237-
238-
foreach ($select_phids as $phid) {
239-
unset($all_project_phids[$phid]);
240-
}
241-
242-
$all_handles = $viewer->loadHandles($all_project_phids);
243-
$all_handles = iterator_to_array($all_handles);
244-
228+
$visible_columns = array();
229+
$column_phids = array();
230+
$visible_phids = array();
245231
foreach ($columns as $column) {
246232
if (!$this->showHidden) {
247233
if ($column->isHidden()) {
@@ -268,6 +254,25 @@ public function handleRequest(AphrontRequest $request) {
268254
$column_tasks = array_select_keys($column_tasks, array_keys($tasks));
269255
}
270256

257+
$column_phid = $column->getPHID();
258+
259+
$visible_columns[$column_phid] = $column;
260+
$column_phids[$column_phid] = $column_tasks;
261+
262+
foreach ($column_tasks as $phid => $task) {
263+
$visible_phids[$phid] = $phid;
264+
}
265+
}
266+
267+
$rendering_engine = id(new PhabricatorBoardRenderingEngine())
268+
->setViewer($viewer)
269+
->setObjects(array_select_keys($tasks, $visible_phids))
270+
->setEditMap($task_can_edit_map)
271+
->setExcludedProjectPHIDs($select_phids);
272+
273+
foreach ($visible_columns as $column_phid => $column) {
274+
$column_tasks = $column_phids[$column_phid];
275+
271276
$panel = id(new PHUIWorkpanelView())
272277
->setHeader($column->getDisplayName())
273278
->setSubHeader($column->getDisplayType())
@@ -317,22 +322,10 @@ public function handleRequest(AphrontRequest $request) {
317322
));
318323

319324
foreach ($column_tasks as $task) {
320-
$owner = null;
321-
if ($task->getOwnerPHID()) {
322-
$owner = $this->handles[$task->getOwnerPHID()];
323-
}
324-
$can_edit = idx($task_can_edit_map, $task->getPHID(), false);
325-
326-
$handles = array_select_keys($all_handles, $task->getProjectPHIDs());
327-
328-
$cards->addItem(id(new ProjectBoardTaskCard())
329-
->setViewer($viewer)
330-
->setProjectHandles($handles)
331-
->setTask($task)
332-
->setOwner($owner)
333-
->setCanEdit($can_edit)
334-
->getItem());
325+
$card = $rendering_engine->renderCard($task->getPHID());
326+
$cards->addItem($card->getItem());
335327
}
328+
336329
$panel->setCards($cards);
337330
$board->addPanel($panel);
338331
}

src/applications/project/controller/PhabricatorProjectMoveController.php

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -175,24 +175,11 @@ public function handleRequest(AphrontRequest $request) {
175175

176176
$editor->applyTransactions($object, $xactions);
177177

178-
$owner = null;
179-
if ($object->getOwnerPHID()) {
180-
$owner = id(new PhabricatorHandleQuery())
181-
->setViewer($viewer)
182-
->withPHIDs(array($object->getOwnerPHID()))
183-
->executeOne();
184-
}
185-
186178
// Reload the object so it reflects edits which have been applied.
187179
$object = id(new ManiphestTaskQuery())
188180
->setViewer($viewer)
189181
->withPHIDs(array($object_phid))
190182
->needProjectPHIDs(true)
191-
->requireCapabilities(
192-
array(
193-
PhabricatorPolicyCapability::CAN_VIEW,
194-
PhabricatorPolicyCapability::CAN_EDIT,
195-
))
196183
->executeOne();
197184

198185
$except_phids = array($board_phid);
@@ -206,25 +193,21 @@ public function handleRequest(AphrontRequest $request) {
206193
}
207194
}
208195

209-
$except_phids = array_fuse($except_phids);
210-
$handle_phids = array_fuse($object->getProjectPHIDs());
211-
$handle_phids = array_diff_key($handle_phids, $except_phids);
212-
213-
$project_handles = $viewer->loadHandles($handle_phids);
214-
$project_handles = iterator_to_array($project_handles);
215-
216-
$card = id(new ProjectBoardTaskCard())
196+
$rendering_engine = id(new PhabricatorBoardRenderingEngine())
217197
->setViewer($viewer)
218-
->setTask($object)
219-
->setOwner($owner)
220-
->setCanEdit(true)
221-
->setProjectHandles($project_handles)
222-
->getItem();
198+
->setObjects(array($object))
199+
->setExcludedProjectPHIDs($except_phids);
223200

224-
$card->addClass('phui-workcard');
201+
$card = $rendering_engine->renderCard($object->getPHID());
225202

226-
return id(new AphrontAjaxResponse())->setContent(
227-
array('task' => $card));
203+
$item = $card->getItem();
204+
$item->addClass('phui-workcard');
205+
206+
return id(new AphrontAjaxResponse())
207+
->setContent(
208+
array(
209+
'task' => $item,
210+
));
228211
}
229212

230213
}

0 commit comments

Comments
 (0)