@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix an issue where "Import Columns" could fail on a board for a project with milestones

Summary:
See PHI1025. When you "Import Columns", we test if you're trying to import into a board that already has columns. However, this test is too broad (it incorrectly detects "proxy" columns for milestones as columns) and not user-friendly (it returns 400 instead of a readable error).

Correct these issues, and refine some of the logic around proxy columns.

Test Plan:
- Created a project, A.
- Created a milestone under that project.
- Imported another project's columns to A's workboard.
- Before change: Unhelpful 400.
- After change: import worked fine.
- Also, hit the new error dialogs and read through them.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D19978

+38 -8
+23 -8
src/applications/project/controller/PhabricatorProjectBoardImportController.php
··· 21 21 } 22 22 $this->setProject($project); 23 23 24 + $project_id = $project->getID(); 25 + $board_uri = $this->getApplicationURI("board/{$project_id}/"); 26 + 27 + // See PHI1025. We only want to prevent the import if the board already has 28 + // real columns. If it has proxy columns (for example, for milestones) you 29 + // can still import columns from another board. 24 30 $columns = id(new PhabricatorProjectColumnQuery()) 25 31 ->setViewer($viewer) 26 32 ->withProjectPHIDs(array($project->getPHID())) 33 + ->withIsProxyColumn(false) 27 34 ->execute(); 28 35 if ($columns) { 29 - return new Aphront400Response(); 36 + return $this->newDialog() 37 + ->setTitle(pht('Workboard Already Has Columns')) 38 + ->appendParagraph( 39 + pht( 40 + 'You can not import columns into this workboard because it '. 41 + 'already has columns. You can only import into an empty '. 42 + 'workboard.')) 43 + ->addCancelButton($board_uri); 30 44 } 31 45 32 - $project_id = $project->getID(); 33 - $board_uri = $this->getApplicationURI("board/{$project_id}/"); 34 - 35 46 if ($request->isFormPost()) { 36 47 $import_phid = $request->getArr('importProjectPHID'); 37 48 $import_phid = reset($import_phid); ··· 39 50 $import_columns = id(new PhabricatorProjectColumnQuery()) 40 51 ->setViewer($viewer) 41 52 ->withProjectPHIDs(array($import_phid)) 53 + ->withIsProxyColumn(false) 42 54 ->execute(); 43 55 if (!$import_columns) { 44 - return new Aphront400Response(); 56 + return $this->newDialog() 57 + ->setTitle(pht('Source Workboard Has No Columns')) 58 + ->appendParagraph( 59 + pht( 60 + 'You can not import columns from that workboard because it has '. 61 + 'no importable columns.')) 62 + ->addCancelButton($board_uri); 45 63 } 46 64 47 65 $table = id(new PhabricatorProjectColumn()) 48 66 ->openTransaction(); 49 67 foreach ($import_columns as $import_column) { 50 68 if ($import_column->isHidden()) { 51 - continue; 52 - } 53 - if ($import_column->getProxy()) { 54 69 continue; 55 70 } 56 71
+14
src/applications/project/query/PhabricatorProjectColumnQuery.php
··· 8 8 private $projectPHIDs; 9 9 private $proxyPHIDs; 10 10 private $statuses; 11 + private $isProxyColumn; 11 12 12 13 public function withIDs(array $ids) { 13 14 $this->ids = $ids; ··· 31 32 32 33 public function withStatuses(array $status) { 33 34 $this->statuses = $status; 35 + return $this; 36 + } 37 + 38 + public function withIsProxyColumn($is_proxy) { 39 + $this->isProxyColumn = $is_proxy; 34 40 return $this; 35 41 } 36 42 ··· 154 160 $conn, 155 161 'status IN (%Ld)', 156 162 $this->statuses); 163 + } 164 + 165 + if ($this->isProxyColumn !== null) { 166 + if ($this->isProxyColumn) { 167 + $where[] = qsprintf($conn, 'proxyPHID IS NOT NULL'); 168 + } else { 169 + $where[] = qsprintf($conn, 'proxyPHID IS NULL'); 170 + } 157 171 } 158 172 159 173 return $where;
+1
src/applications/project/typeahead/PhabricatorProjectDatasource.php
··· 53 53 $columns = id(new PhabricatorProjectColumnQuery()) 54 54 ->setViewer($viewer) 55 55 ->withProjectPHIDs(array_keys($projs)) 56 + ->withIsProxyColumn(false) 56 57 ->execute(); 57 58 $has_cols = mgroup($columns, 'getProjectPHID'); 58 59 } else {