Page MenuHomePhabricator

D8544.id20272.diff
No OneTemporary

D8544.id20272.diff

diff --git a/resources/sql/autopatches/20140314.projectcolumn.1.statuscol.sql b/resources/sql/autopatches/20140314.projectcolumn.1.statuscol.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140314.projectcolumn.1.statuscol.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_project.project_column
+ ADD COLUMN status INT UNSIGNED NOT NULL COLLATE utf8_bin AFTER name;
diff --git a/resources/sql/autopatches/20140314.projectcolumn.2.statuskey.sql b/resources/sql/autopatches/20140314.projectcolumn.2.statuskey.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140314.projectcolumn.2.statuskey.sql
@@ -0,0 +1,5 @@
+ALTER TABLE {$NAMESPACE}_project.project_column
+ DROP KEY `key_sequence`;
+
+ALTER TABLE {$NAMESPACE}_project.project_column
+ ADD UNIQUE KEY `key_sequence` (`projectPHID`,`status`,`sequence`);
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1839,6 +1839,7 @@
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
'PhabricatorProjectArchiveController' => 'applications/project/controller/PhabricatorProjectArchiveController.php',
'PhabricatorProjectBoardController' => 'applications/project/controller/PhabricatorProjectBoardController.php',
+ 'PhabricatorProjectBoardDeleteController' => 'applications/project/controller/PhabricatorProjectBoardDeleteController.php',
'PhabricatorProjectBoardEditController' => 'applications/project/controller/PhabricatorProjectBoardEditController.php',
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
'PhabricatorProjectColumnQuery' => 'applications/project/query/PhabricatorProjectColumnQuery.php',
@@ -4601,6 +4602,7 @@
),
'PhabricatorProjectArchiveController' => 'PhabricatorProjectController',
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
+ 'PhabricatorProjectBoardDeleteController' => 'PhabricatorProjectController',
'PhabricatorProjectBoardEditController' => 'PhabricatorProjectController',
'PhabricatorProjectColumn' =>
array(
diff --git a/src/applications/project/application/PhabricatorApplicationProject.php b/src/applications/project/application/PhabricatorApplicationProject.php
--- a/src/applications/project/application/PhabricatorApplicationProject.php
+++ b/src/applications/project/application/PhabricatorApplicationProject.php
@@ -53,6 +53,8 @@
'move/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectMoveController',
'board/(?P<projectID>[1-9]\d*)/edit/(?:(?P<id>\d+)/)?'
=> 'PhabricatorProjectBoardEditController',
+ 'board/(?P<projectID>[1-9]\d*)/delete/(?:(?P<id>\d+)/)?'
+ => 'PhabricatorProjectBoardDeleteController',
'update/(?P<id>[1-9]\d*)/(?P<action>[^/]+)/'
=> 'PhabricatorProjectUpdateController',
'history/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectHistoryController',
diff --git a/src/applications/project/controller/PhabricatorProjectBoardController.php b/src/applications/project/controller/PhabricatorProjectBoardController.php
--- a/src/applications/project/controller/PhabricatorProjectBoardController.php
+++ b/src/applications/project/controller/PhabricatorProjectBoardController.php
@@ -168,6 +168,13 @@
->setHref($this->getApplicationURI('board/'.$this->id.'/edit/'))
->setIcon('create')
->setDisabled(!$can_edit)
+ ->setWorkflow(!$can_edit))
+ ->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Delete Column'))
+ ->setHref($this->getApplicationURI('board/'.$this->id.'/delete/'))
+ ->setIcon('delete')
+ ->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$plist = id(new PHUIPropertyListView());
diff --git a/src/applications/project/controller/PhabricatorProjectBoardDeleteController.php b/src/applications/project/controller/PhabricatorProjectBoardDeleteController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/project/controller/PhabricatorProjectBoardDeleteController.php
@@ -0,0 +1,140 @@
+<?php
+
+final class PhabricatorProjectBoardDeleteController
+ extends PhabricatorProjectController {
+
+ private $id;
+ private $projectID;
+
+ public function willProcessRequest(array $data) {
+ $this->projectID = $data['projectID'];
+ $this->id = idx($data, 'id');
+ }
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $project = id(new PhabricatorProjectQuery())
+ ->setViewer($viewer)
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->withIDs(array($this->projectID))
+ ->executeOne();
+
+ if (!$project) {
+ return new Aphront404Response();
+ }
+
+ $columns = id(new PhabricatorProjectColumnQuery())
+ ->setViewer($viewer)
+ ->withProjectPHIDs(array($project->getPHID()))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT))
+ ->execute();
+
+ if (!$columns) {
+ return new Aphront404Response();
+ }
+
+ $columns = mpull($columns, null, 'getSequence');
+ ksort($columns);
+ $default_column = $columns[0];
+ // don't allow for deleting the default column
+ unset($columns[0]);
+ $options = mpull($columns, 'getName', 'getPHID');
+
+ $view_uri = $this->getApplicationURI('/board/'.$this->projectID.'/');
+ if ($request->isFormPost()) {
+ $columns = mpull($columns, null, 'getPHID');
+ $column_phid = $request->getStr('columnPHID');
+ $column = $columns[$column_phid];
+
+ $move_task_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
+ $column_phid,
+ PhabricatorEdgeConfig::TYPE_COLUMN_HAS_OBJECT);
+
+ if ($move_task_phids) {
+ $template_xaction = id(new ManiphestTransaction())
+ ->setTransactionType(ManiphestTransaction::TYPE_PROJECT_COLUMN)
+ ->setNewValue(array(
+ 'columnPHIDs' => array($default_column->getPHID()),
+ 'projectPHID' => $default_column->getProjectPHID()))
+ ->setOldValue(array(
+ 'columnPHIDs' => array($column_phid),
+ 'projectPHID' => $column->getProjectPHID()));
+
+ $editor = id(new ManiphestTransactionEditor())
+ ->setActor($viewer)
+ ->setContinueOnMissingFields(true)
+ ->setContinueOnNoEffect(true)
+ ->setContentSourceFromRequest($request);
+
+ $move_tasks = id(new ManiphestTaskQuery())
+ ->setViewer($viewer)
+ ->withPHIDs($move_task_phids)
+ ->execute();
+ $first_task = head($move_tasks);
+ $first_task->openTransaction();
+ foreach ($move_tasks as $move_task) {
+ $xaction = clone $template_xaction;
+ $xactions = array($xaction);
+ $editor->applyTransactions($move_task, $xactions);
+ }
+ $first_task->saveTransaction();
+ }
+
+ $column->setStatus(PhabricatorProjectColumn::STATUS_DELETED);
+ $column->save();
+
+ return id(new AphrontRedirectResponse())->setURI($view_uri);
+ }
+
+ $form = id(new AphrontFormView())
+ ->setUser($viewer)
+ ->appendInstructions(pht(
+ 'WARNING: deleting a column will move any tasks in that column to '.
+ 'the project default column. Column deletion can not be undone.'))
+ ->appendChild(id(new AphrontFormSelectControl())
+ ->setName('columnPHID')
+ ->setValue(head_key($options))
+ ->setOptions($options)
+ ->setLabel(pht('Column')));
+
+ $title = pht('Delete Column');
+ $submit = $title;
+
+ $form->appendChild(
+ id(new AphrontFormSubmitControl())
+ ->setValue($submit)
+ ->addCancelButton($view_uri));
+
+ $crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addTextCrumb(
+ $project->getName(),
+ $this->getApplicationURI('view/'.$project->getID().'/'));
+ $crumbs->addTextCrumb(
+ pht('Board'),
+ $this->getApplicationURI('board/'.$project->getID().'/'));
+ $crumbs->addTextCrumb($title);
+
+ $form_box = id(new PHUIObjectBoxView())
+ ->setHeaderText($title)
+ ->setForm($form);
+
+ return $this->buildApplicationPage(
+ array(
+ $crumbs,
+ $form_box,
+ ),
+ array(
+ 'title' => $title,
+ 'device' => true,
+ ));
+ }
+}
diff --git a/src/applications/project/phid/PhabricatorProjectPHIDTypeColumn.php b/src/applications/project/phid/PhabricatorProjectPHIDTypeColumn.php
--- a/src/applications/project/phid/PhabricatorProjectPHIDTypeColumn.php
+++ b/src/applications/project/phid/PhabricatorProjectPHIDTypeColumn.php
@@ -34,6 +34,8 @@
$handle->setName($column->getDisplayName());
$handle->setURI('/project/board/'.$column->getProject()->getID().'/');
+ $handle->setDisabled(
+ $column->getStatus() == PhabricatorProjectColumn::STATUS_DELETED);
}
}
diff --git a/src/applications/project/storage/PhabricatorProjectColumn.php b/src/applications/project/storage/PhabricatorProjectColumn.php
--- a/src/applications/project/storage/PhabricatorProjectColumn.php
+++ b/src/applications/project/storage/PhabricatorProjectColumn.php
@@ -4,7 +4,11 @@
extends PhabricatorProjectDAO
implements PhabricatorPolicyInterface {
+ const STATUS_ACTIVE = 0;
+ const STATUS_DELETED = 1;
+
protected $name;
+ protected $status;
protected $projectPHID;
protected $sequence;
@@ -12,7 +16,8 @@
public static function initializeNewColumn(PhabricatorUser $user) {
return id(new PhabricatorProjectColumn())
- ->setName('');
+ ->setName('')
+ ->setStatus(self::STATUS_ACTIVE);
}
public function getConfiguration() {

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 2, 9:42 PM (5 h, 24 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7703226
Default Alt Text
D8544.id20272.diff (9 KB)

Event Timeline