mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-26 13:39:08 +01:00
Summary: Fixes T6641. This allows users who have permission to edit a project to use "Save as Default" to save the current order and filter as defaults for the project. These are per-board defaults, and apply to all users. The rationale is that I think the best default ordering/filtering depends mostly on the board, not the viewer. This seems to align with most requests in the task, although rationale is a bit light. But, for example, it seems reasonable you might want to change the default filter to "All Tasks" on a sprint board, so you can see what's in the "Done" column. This also fixes some minor issues I ran into: - Herald could hit an issue while checking permissions if the project was a subproject and a non-member had a triggering rule. - "Advanced filter..." did not prefill with the current filter. Test Plan: - Set default order and filter on a workboard. - Reloaded board, saw settings stick. - Tried to edit a board as an unprivileged user (disabled menu items, error). - Reviewed transaction log. Reviewers: chad Reviewed By: chad Maniphest Tasks: T6641 Differential Revision: https://secure.phabricator.com/D15260
90 lines
2.8 KiB
PHP
90 lines
2.8 KiB
PHP
<?php
|
|
|
|
final class PhabricatorProjectDefaultController
|
|
extends PhabricatorProjectBoardController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$viewer = $request->getViewer();
|
|
$project_id = $request->getURIData('projectID');
|
|
|
|
$project = id(new PhabricatorProjectQuery())
|
|
->setViewer($viewer)
|
|
->requireCapabilities(
|
|
array(
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
))
|
|
->withIDs(array($project_id))
|
|
->executeOne();
|
|
if (!$project) {
|
|
return new Aphront404Response();
|
|
}
|
|
$this->setProject($project);
|
|
|
|
$target = $request->getURIData('target');
|
|
switch ($target) {
|
|
case 'filter':
|
|
$title = pht('Set Board Default Filter');
|
|
$body = pht(
|
|
'Make the current filter the new default filter for this board? '.
|
|
'All users will see the new filter as the default when they view '.
|
|
'the board.');
|
|
$button = pht('Save Default Filter');
|
|
|
|
$xaction_value = $request->getStr('filter');
|
|
$xaction_type = PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER;
|
|
break;
|
|
case 'sort':
|
|
$title = pht('Set Board Default Order');
|
|
$body = pht(
|
|
'Make the current sort order the new default order for this board? '.
|
|
'All users will see the new order as the default when they view '.
|
|
'the board.');
|
|
$button = pht('Save Default Order');
|
|
|
|
$xaction_value = $request->getStr('order');
|
|
$xaction_type = PhabricatorProjectTransaction::TYPE_DEFAULT_SORT;
|
|
break;
|
|
default:
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$id = $project->getID();
|
|
|
|
$view_uri = $this->getApplicationURI("board/{$id}/");
|
|
$view_uri = new PhutilURI($view_uri);
|
|
foreach ($request->getPassthroughRequestData() as $key => $value) {
|
|
$view_uri->setQueryParam($key, $value);
|
|
}
|
|
|
|
if ($request->isFormPost()) {
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
|
->setTransactionType($xaction_type)
|
|
->setNewValue($xaction_value);
|
|
|
|
id(new PhabricatorProjectTransactionEditor())
|
|
->setActor($viewer)
|
|
->setContentSourceFromRequest($request)
|
|
->setContinueOnNoEffect(true)
|
|
->setContinueOnMissingFields(true)
|
|
->applyTransactions($project, $xactions);
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
|
}
|
|
|
|
$dialog = $this->newDialog()
|
|
->setTitle($title)
|
|
->appendChild($body)
|
|
->setDisableWorkflowOnCancel(true)
|
|
->addCancelButton($view_uri)
|
|
->addSubmitButton($title);
|
|
|
|
foreach ($request->getPassthroughRequestData() as $key => $value) {
|
|
$dialog->addHiddenInput($key, $value);
|
|
}
|
|
|
|
return $dialog;
|
|
}
|
|
}
|