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
This commit is contained in:
@@ -21,17 +21,28 @@ final class PhabricatorProjectBoardImportController
|
|||||||
}
|
}
|
||||||
$this->setProject($project);
|
$this->setProject($project);
|
||||||
|
|
||||||
|
$project_id = $project->getID();
|
||||||
|
$board_uri = $this->getApplicationURI("board/{$project_id}/");
|
||||||
|
|
||||||
|
// See PHI1025. We only want to prevent the import if the board already has
|
||||||
|
// real columns. If it has proxy columns (for example, for milestones) you
|
||||||
|
// can still import columns from another board.
|
||||||
$columns = id(new PhabricatorProjectColumnQuery())
|
$columns = id(new PhabricatorProjectColumnQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withProjectPHIDs(array($project->getPHID()))
|
->withProjectPHIDs(array($project->getPHID()))
|
||||||
|
->withIsProxyColumn(false)
|
||||||
->execute();
|
->execute();
|
||||||
if ($columns) {
|
if ($columns) {
|
||||||
return new Aphront400Response();
|
return $this->newDialog()
|
||||||
|
->setTitle(pht('Workboard Already Has Columns'))
|
||||||
|
->appendParagraph(
|
||||||
|
pht(
|
||||||
|
'You can not import columns into this workboard because it '.
|
||||||
|
'already has columns. You can only import into an empty '.
|
||||||
|
'workboard.'))
|
||||||
|
->addCancelButton($board_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
$project_id = $project->getID();
|
|
||||||
$board_uri = $this->getApplicationURI("board/{$project_id}/");
|
|
||||||
|
|
||||||
if ($request->isFormPost()) {
|
if ($request->isFormPost()) {
|
||||||
$import_phid = $request->getArr('importProjectPHID');
|
$import_phid = $request->getArr('importProjectPHID');
|
||||||
$import_phid = reset($import_phid);
|
$import_phid = reset($import_phid);
|
||||||
@@ -39,9 +50,16 @@ final class PhabricatorProjectBoardImportController
|
|||||||
$import_columns = id(new PhabricatorProjectColumnQuery())
|
$import_columns = id(new PhabricatorProjectColumnQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withProjectPHIDs(array($import_phid))
|
->withProjectPHIDs(array($import_phid))
|
||||||
|
->withIsProxyColumn(false)
|
||||||
->execute();
|
->execute();
|
||||||
if (!$import_columns) {
|
if (!$import_columns) {
|
||||||
return new Aphront400Response();
|
return $this->newDialog()
|
||||||
|
->setTitle(pht('Source Workboard Has No Columns'))
|
||||||
|
->appendParagraph(
|
||||||
|
pht(
|
||||||
|
'You can not import columns from that workboard because it has '.
|
||||||
|
'no importable columns.'))
|
||||||
|
->addCancelButton($board_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
$table = id(new PhabricatorProjectColumn())
|
$table = id(new PhabricatorProjectColumn())
|
||||||
@@ -50,9 +68,6 @@ final class PhabricatorProjectBoardImportController
|
|||||||
if ($import_column->isHidden()) {
|
if ($import_column->isHidden()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($import_column->getProxy()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_column = PhabricatorProjectColumn::initializeNewColumn($viewer)
|
$new_column = PhabricatorProjectColumn::initializeNewColumn($viewer)
|
||||||
->setSequence($import_column->getSequence())
|
->setSequence($import_column->getSequence())
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ final class PhabricatorProjectColumnQuery
|
|||||||
private $projectPHIDs;
|
private $projectPHIDs;
|
||||||
private $proxyPHIDs;
|
private $proxyPHIDs;
|
||||||
private $statuses;
|
private $statuses;
|
||||||
|
private $isProxyColumn;
|
||||||
|
|
||||||
public function withIDs(array $ids) {
|
public function withIDs(array $ids) {
|
||||||
$this->ids = $ids;
|
$this->ids = $ids;
|
||||||
@@ -34,6 +35,11 @@ final class PhabricatorProjectColumnQuery
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withIsProxyColumn($is_proxy) {
|
||||||
|
$this->isProxyColumn = $is_proxy;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function newResultObject() {
|
public function newResultObject() {
|
||||||
return new PhabricatorProjectColumn();
|
return new PhabricatorProjectColumn();
|
||||||
}
|
}
|
||||||
@@ -156,6 +162,14 @@ final class PhabricatorProjectColumnQuery
|
|||||||
$this->statuses);
|
$this->statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->isProxyColumn !== null) {
|
||||||
|
if ($this->isProxyColumn) {
|
||||||
|
$where[] = qsprintf($conn, 'proxyPHID IS NOT NULL');
|
||||||
|
} else {
|
||||||
|
$where[] = qsprintf($conn, 'proxyPHID IS NULL');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ final class PhabricatorProjectDatasource
|
|||||||
$columns = id(new PhabricatorProjectColumnQuery())
|
$columns = id(new PhabricatorProjectColumnQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withProjectPHIDs(array_keys($projs))
|
->withProjectPHIDs(array_keys($projs))
|
||||||
|
->withIsProxyColumn(false)
|
||||||
->execute();
|
->execute();
|
||||||
$has_cols = mgroup($columns, 'getProjectPHID');
|
$has_cols = mgroup($columns, 'getProjectPHID');
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user