Christopher Johnson (WMDE) has submitted this change and it was merged. Change subject: adds Conduit methods for Sprint creation ......................................................................
adds Conduit methods for Sprint creation Bug: T91529 Bug: T89859 Bug: T91516 Bug: T95079 Change-Id: If1ce84eb13605cb3c0373cc6392e9135be8eec02 --- M src/__phutil_library_map__.php A src/conduit/SprintConduitAPIMethod.php A src/conduit/SprintCreateConduitAPIMethod.php M src/controller/SprintController.php D src/view/burndown/BurndownChartExporter.php 5 files changed, 146 insertions(+), 12 deletions(-) Approvals: Christopher Johnson (WMDE): Verified; Looks good to me, approved Objections: jenkins-bot: Fails diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 4536c4e..296ba37 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -14,6 +14,7 @@ 'BoardDataProvider' => 'storage/BoardDataProvider.php', 'BoardDataTableView' => 'view/burndown/BoardDataTableView.php', 'BurndownActionMenuEventListener' => 'events/BurndownActionMenuEventListener.php', + 'BurndownChartExporter' => 'view/burndown/BurndownChartExporter.php', 'BurndownChartView' => 'view/burndown/BurndownChartView.php', 'BurndownDataDate' => 'util/BurndownDataDate.php', 'BurndownException' => 'exception/BurndownException.php', @@ -37,9 +38,11 @@ 'SprintBoardTaskEditController' => 'controller/board/SprintBoardTaskEditController.php', 'SprintBoardViewController' => 'controller/board/SprintBoardViewController.php', 'SprintColumnTransaction' => 'storage/SprintColumnTransaction.php', + 'SprintConduitAPIMethod' => 'conduit/SprintConduitAPIMethod.php', 'SprintConstants' => 'constants/SprintConstants.php', 'SprintController' => 'controller/SprintController.php', 'SprintControllerTest' => 'tests/SprintControllerTest.php', + 'SprintCreateConduitAPIMethod' => 'conduit/SprintCreateConduitAPIMethod.php', 'SprintCustomFieldTest' => 'tests/SprintCustomFieldTest.php', 'SprintDAO' => 'storage/SprintDAO.php', 'SprintDataView' => 'view/burndown/SprintDataView.php', @@ -90,8 +93,10 @@ 'SprintBoardReorderController' => 'SprintBoardController', 'SprintBoardTaskEditController' => 'ManiphestController', 'SprintBoardViewController' => 'SprintBoardController', + 'SprintConduitAPIMethod' => 'ConduitAPIMethod', 'SprintController' => 'PhabricatorController', 'SprintControllerTest' => 'SprintTestCase', + 'SprintCreateConduitAPIMethod' => 'SprintConduitAPIMethod', 'SprintCustomFieldTest' => 'SprintTestCase', 'SprintDAO' => 'PhabricatorLiskDAO', 'SprintDataView' => 'SprintView', diff --git a/src/conduit/SprintConduitAPIMethod.php b/src/conduit/SprintConduitAPIMethod.php new file mode 100644 index 0000000..2cf96f8 --- /dev/null +++ b/src/conduit/SprintConduitAPIMethod.php @@ -0,0 +1,48 @@ +<?php + +abstract class SprintConduitAPIMethod extends ConduitAPIMethod { + + final public function getApplication() { + return PhabricatorApplication::getByClass('SprintApplication'); + } + + protected function buildProjectInfoDictionary(PhabricatorProject $project) { + $results = $this->buildProjectInfoDictionaries(array($project)); + return idx($results, $project->getPHID()); + } + + protected function buildProjectInfoDictionaries(array $projects) { + assert_instances_of($projects, 'PhabricatorProject'); + if (!$projects) { + return array(); + } + + $result = array(); + foreach ($projects as $project) { + + $member_phids = $project->getMemberPHIDs(); + $member_phids = array_values($member_phids); + + $project_slugs = $project->getSlugs(); + $project_slugs = array_values(mpull($project_slugs, 'getSlug')); + + $project_icon = PhabricatorProjectIcon::getAPIName($project->getIcon()); + + $result[$project->getPHID()] = array( + 'id' => $project->getID(), + 'phid' => $project->getPHID(), + 'name' => $project->getName(), + 'profileImagePHID' => $project->getProfileImagePHID(), + 'icon' => $project_icon, + 'color' => $project->getColor(), + 'members' => $member_phids, + 'slugs' => $project_slugs, + 'dateCreated' => $project->getDateCreated(), + 'dateModified' => $project->getDateModified(), + ); + } + + return $result; + } + +} diff --git a/src/conduit/SprintCreateConduitAPIMethod.php b/src/conduit/SprintCreateConduitAPIMethod.php new file mode 100644 index 0000000..920e40b --- /dev/null +++ b/src/conduit/SprintCreateConduitAPIMethod.php @@ -0,0 +1,92 @@ +<?php + +final class SprintCreateConduitAPIMethod extends SprintConduitAPIMethod { + + public function getAPIMethodName() { + return 'sprint.create'; + } + + public function getMethodDescription() { + return pht('Create a Sprint Project'); + } + + public function defineParamTypes() { + return array( + 'name' => 'required string ("name")', + 'members' => 'optional list ([<phid>]) - empty list enter []', + 'startdate' => 'required string ("YYYY-MM-DD H:i")', + 'enddate' => 'required string ("YYYY-MM-DD H:i")', + ); + } + + public function defineReturnType() { + return 'dict'; + } + + public function defineErrorTypes() { + return array(); + } + + protected function execute(ConduitAPIRequest $request) { + $user = $request->getUser(); + + $this->requireApplicationCapability( + ProjectCreateProjectsCapability::CAPABILITY, + $user); + + $project = PhabricatorProject::initializeNewProject($user); + $type_name = PhabricatorProjectTransaction::TYPE_NAME; + $members = $request->getValue('members'); + $xactions = array(); + + $xactions[] = id(new PhabricatorProjectTransaction()) + ->setTransactionType($type_name) + ->setNewValue($request->getValue('name')); + + $xactions[] = id(new PhabricatorProjectTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) + ->setMetadataValue( + 'edge:type', + PhabricatorProjectProjectHasMemberEdgeType::EDGECONST) + ->setNewValue( + array( + '+' => array_fuse($members), + )); + + $xactions[] = id(new PhabricatorProjectTransaction()) + ->setTransactionType(PhabricatorProjectTransaction::TYPE_ICON) + ->setNewValue('fa-calendar'); + + $xactions[] = id(new PhabricatorProjectTransaction()) + ->setTransactionType(PhabricatorProjectTransaction::TYPE_COLOR) + ->setNewValue('green'); + + $xactions[] = id(new PhabricatorProjectTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD) + ->setMetadataValue('customfield:key', 'isdc:sprint:issprint') + ->setOldValue(null) + ->setNewValue(1); + + $xactions[] = id(new PhabricatorProjectTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD) + ->setMetadataValue('customfield:key', 'isdc:sprint:startdate') + ->setOldValue(null) + ->setNewValue(strtotime($request->getValue('startdate'))); + + $xactions[] = id(new PhabricatorProjectTransaction()) + ->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD) + ->setMetadataValue('customfield:key', 'isdc:sprint:enddate') + ->setOldValue(0) + ->setNewValue(strtotime($request->getValue('enddate'))); + + $editor = id(new PhabricatorProjectTransactionEditor()) + ->setActor($user) + ->setContinueOnNoEffect(true) + ->setContentSourceFromConduitRequest($request); + + $editor->applyTransactions($project, $xactions); + + return $this->buildProjectInfoDictionary($project); + } + +} diff --git a/src/controller/SprintController.php b/src/controller/SprintController.php index 461c19e..957a51e 100644 --- a/src/controller/SprintController.php +++ b/src/controller/SprintController.php @@ -73,7 +73,7 @@ $crumbs->addAction( id(new PHUIListItemView()) ->setName(pht('Create Sprint')) - ->setHref($this->getProjectsURI().'create/') + ->setHref('/conduit/method/sprint.create/') ->setIcon('fa-calendar') ->setDisabled(!$can_create)); diff --git a/src/view/burndown/BurndownChartExporter.php b/src/view/burndown/BurndownChartExporter.php deleted file mode 100644 index f41e889..0000000 --- a/src/view/burndown/BurndownChartExporter.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -/** - * Created by PhpStorm. - * User: christopher - * Date: 27.03.15 - * Time: 17:53 - */ - -class BurndownChartExporter { - -} -- To view, visit https://gerrit.wikimedia.org/r/201894 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If1ce84eb13605cb3c0373cc6392e9135be8eec02 Gerrit-PatchSet: 4 Gerrit-Project: phabricator/extensions/Sprint Gerrit-Branch: master Gerrit-Owner: Christopher Johnson (WMDE) <christopher.john...@wikimedia.de> Gerrit-Reviewer: Christopher Johnson (WMDE) <christopher.john...@wikimedia.de> Gerrit-Reviewer: Jakob <jakob.warkot...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits