Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/project/controller/PhabricatorProjectBoardController.php b/src/applications/project/controller/PhabricatorProjectBoardController.php
index e93bda71fd..5a5b0422ee 100644
--- a/src/applications/project/controller/PhabricatorProjectBoardController.php
+++ b/src/applications/project/controller/PhabricatorProjectBoardController.php
@@ -1,138 +1,149 @@
<?php
final class PhabricatorProjectBoardController
extends PhabricatorProjectController {
private $id;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$project = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->executeOne();
if (!$project) {
return new Aphront404Response();
}
$columns = id(new PhabricatorProjectColumnQuery())
->setViewer($viewer)
->withProjectPHIDs(array($project->getPHID()))
->execute();
msort($columns, 'getSequence');
$tasks = id(new ManiphestTaskQuery())
->setViewer($viewer)
->withAllProjects(array($project->getPHID()))
->withStatus(ManiphestTaskQuery::STATUS_OPEN)
->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY)
->execute();
$tasks = mpull($tasks, null, 'getPHID');
// TODO: This is so made up.
$task_map = array();
foreach ($tasks as $task) {
if ($columns) {
$random_column = $columns[array_rand($columns)]->getPHID();
} else {
$random_column = 0;
}
$task_map[$random_column][] = $task->getPHID();
}
$board = id(new PHUIWorkboardView())
->setUser($viewer)
->setFluidishLayout(true);
foreach ($columns as $column) {
$panel = id(new PHUIWorkpanelView())
->setHeader($column->getName())
->setEditURI('edit/'.$column->getID().'/');
$cards = id(new PHUIObjectItemListView())
->setUser($viewer)
->setCards(true)
->setFlush(true);
$task_phids = idx($task_map, $column->getPHID(), array());
foreach (array_select_keys($tasks, $task_phids) as $task) {
$cards->addItem($this->renderTaskCard($task));
}
$panel->setCards($cards);
$board->addPanel($panel);
}
$crumbs = $this->buildApplicationCrumbs();
+ $crumbs->addTextCrumb(
+ $project->getName(),
+ $this->getApplicationURI('view/'.$project->getID().'/'));
+ $crumbs->addTextCrumb(pht('Board'));
+
+ $can_edit = PhabricatorPolicyFilter::hasCapability(
+ $viewer,
+ $project,
+ PhabricatorPolicyCapability::CAN_EDIT);
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->addAction(
id(new PhabricatorActionView())
->setName(pht('Add Column/Milestone/Sprint'))
->setHref($this->getApplicationURI('board/'.$this->id.'/edit/'))
- ->setIcon('create'));
+ ->setIcon('create')
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(!$can_edit));
$plist = id(new PHUIPropertyListView());
// TODO: Need this to get actions to render.
$plist->addProperty(pht('Ignore'), pht('This Property'));
$plist->setActionList($actions);
$header = id(new PHUIObjectBoxView())
->setHeaderText($project->getName())
->addPropertyList($plist);
$board_box = id(new PHUIBoxView())
->appendChild($board)
->addMargin(PHUI::MARGIN_LARGE);
return $this->buildApplicationPage(
array(
$crumbs,
$header,
$board_box,
),
array(
'title' => pht('Board'),
'device' => true,
));
}
private function renderTaskCard(ManiphestTask $task) {
$request = $this->getRequest();
$viewer = $request->getUser();
$color_map = ManiphestTaskPriority::getColorMap();
$bar_color = idx($color_map, $task->getPriority(), 'grey');
// TODO: Batch this earlier on.
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$task,
PhabricatorPolicyCapability::CAN_EDIT);
return id(new PHUIObjectItemView())
->setObjectName('T'.$task->getID())
->setHeader($task->getTitle())
->setGrippable($can_edit)
->setHref('/T'.$task->getID())
->addAction(
id(new PHUIListItemView())
->setName(pht('Edit'))
->setIcon('edit')
->setHref('/maniphest/task/edit/'.$task->getID().'/')
->setWorkflow(true))
->setBarColor($bar_color);
}
}
diff --git a/src/applications/project/controller/PhabricatorProjectBoardEditController.php b/src/applications/project/controller/PhabricatorProjectBoardEditController.php
index f9cea6169f..266609e259 100644
--- a/src/applications/project/controller/PhabricatorProjectBoardEditController.php
+++ b/src/applications/project/controller/PhabricatorProjectBoardEditController.php
@@ -1,132 +1,138 @@
<?php
final class PhabricatorProjectBoardEditController
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();
}
$is_new = ($this->id ? false : true);
if (!$is_new) {
$column = id(new PhabricatorProjectColumnQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$column) {
return new Aphront404Response();
}
} else {
$column = new PhabricatorProjectColumn();
}
$errors = array();
$e_name = true;
$error_view = null;
$view_uri = $this->getApplicationURI('/board/'.$this->projectID.'/');
if ($request->isFormPost()) {
$new_name = $request->getStr('name');
$column->setName($new_name);
if (!strlen($column->getName())) {
$errors[] = pht('Column name is required.');
$e_name = pht('Required');
} else {
$e_name = null;
}
if ($is_new) {
$column->setProjectPHID($project->getPHID());
$column->attachProject($project);
$columns = id(new PhabricatorProjectColumnQuery())
->setViewer($viewer)
->withProjectPHIDs(array($project->getPHID()))
->execute();
$new_sequence = 1;
if ($columns) {
$values = mpull($columns, 'getSequence');
$new_sequence = max($values) + 1;
}
$column->setSequence($new_sequence);
}
if (!$errors) {
$column->save();
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
}
$form = new AphrontFormView();
$form->setUser($request->getUser())
->appendChild(
id(new AphrontFormTextControl())
->setValue($column->getName())
->setLabel(pht('Name'))
->setName('name')
->setError($e_name)
->setCaption(
pht('This will be displayed as the header of the column.')));
if ($is_new) {
$title = pht('Create Column');
$submit = pht('Create Column');
} else {
$title = pht('Edit %s', $column->getName());
$submit = pht('Save Column');
}
$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)
->setFormErrors($errors)
->setForm($form);
return $this->buildApplicationPage(
array(
$crumbs,
$form_box,
),
array(
'title' => $title,
'device' => true,
));
}
}
diff --git a/src/applications/project/controller/PhabricatorProjectController.php b/src/applications/project/controller/PhabricatorProjectController.php
index a50d0afedf..02a6fd1d45 100644
--- a/src/applications/project/controller/PhabricatorProjectController.php
+++ b/src/applications/project/controller/PhabricatorProjectController.php
@@ -1,41 +1,24 @@
<?php
abstract class PhabricatorProjectController extends PhabricatorController {
public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
$nav->addFilter('create', pht('Create Project'));
}
id(new PhabricatorProjectSearchEngine())
->setViewer($user)
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
- public function buildApplicationCrumbs() {
- $crumbs = parent::buildApplicationCrumbs();
-
- $can_create = $this->hasApplicationCapability(
- ProjectCapabilityCreateProjects::CAPABILITY);
-
- $crumbs->addAction(
- id(new PHUIListItemView())
- ->setName(pht('Create Project'))
- ->setHref($this->getApplicationURI('create/'))
- ->setIcon('create')
- ->setWorkflow(!$can_create)
- ->setDisabled(!$can_create));
-
- return $crumbs;
- }
-
}
diff --git a/src/applications/project/controller/PhabricatorProjectListController.php b/src/applications/project/controller/PhabricatorProjectListController.php
index 81fdab8823..743375c4a7 100644
--- a/src/applications/project/controller/PhabricatorProjectListController.php
+++ b/src/applications/project/controller/PhabricatorProjectListController.php
@@ -1,54 +1,71 @@
<?php
final class PhabricatorProjectListController
extends PhabricatorProjectController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new PhabricatorProjectSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function renderResultsList(
array $projects,
PhabricatorSavedQuery $query) {
assert_instances_of($projects, 'PhabricatorProject');
$viewer = $this->getRequest()->getUser();
$list = new PHUIObjectItemListView();
$list->setUser($viewer);
foreach ($projects as $project) {
$id = $project->getID();
$item = id(new PHUIObjectItemView())
->setHeader($project->getName())
->setHref($this->getApplicationURI("view/{$id}/"));
if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ARCHIVED) {
$item->addIcon('delete-grey', pht('Archived'));
$item->setDisabled(true);
}
$list->addItem($item);
}
return $list;
}
+ public function buildApplicationCrumbs() {
+ $crumbs = parent::buildApplicationCrumbs();
+
+ $can_create = $this->hasApplicationCapability(
+ ProjectCapabilityCreateProjects::CAPABILITY);
+
+ $crumbs->addAction(
+ id(new PHUIListItemView())
+ ->setName(pht('Create Project'))
+ ->setHref($this->getApplicationURI('create/'))
+ ->setIcon('create')
+ ->setWorkflow(!$can_create)
+ ->setDisabled(!$can_create));
+
+ return $crumbs;
+ }
+
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jun 10, 11:39 AM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
140361
Default Alt Text
(12 KB)

Event Timeline