2011-02-08 19:53:59 +01:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class ManiphestTaskEditController extends ManiphestController {
|
2011-02-20 23:15:53 +01:00
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = idx($data, 'id');
|
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
$can_edit_assign = $this->hasApplicationCapability(
|
|
|
|
ManiphestCapabilityEditAssign::CAPABILITY);
|
|
|
|
$can_edit_policies = $this->hasApplicationCapability(
|
|
|
|
ManiphestCapabilityEditPolicies::CAPABILITY);
|
|
|
|
$can_edit_priority = $this->hasApplicationCapability(
|
|
|
|
ManiphestCapabilityEditPriority::CAPABILITY);
|
|
|
|
$can_edit_projects = $this->hasApplicationCapability(
|
|
|
|
ManiphestCapabilityEditProjects::CAPABILITY);
|
|
|
|
$can_edit_status = $this->hasApplicationCapability(
|
|
|
|
ManiphestCapabilityEditStatus::CAPABILITY);
|
|
|
|
|
2011-05-06 18:17:55 +02:00
|
|
|
$files = array();
|
2011-08-03 17:48:42 +02:00
|
|
|
$parent_task = null;
|
|
|
|
$template_id = null;
|
2011-05-06 18:17:55 +02:00
|
|
|
|
2011-02-20 23:15:53 +01:00
|
|
|
if ($this->id) {
|
2013-09-25 22:44:14 +02:00
|
|
|
$task = id(new ManiphestTaskQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->withIDs(array($this->id))
|
|
|
|
->executeOne();
|
2011-02-20 23:15:53 +01:00
|
|
|
if (!$task) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
} else {
|
2013-10-09 22:53:17 +02:00
|
|
|
$task = ManiphestTask::initializeNewTask($user);
|
2011-05-06 18:17:55 +02:00
|
|
|
|
|
|
|
// These allow task creation with defaults.
|
|
|
|
if (!$request->isFormPost()) {
|
|
|
|
$task->setTitle($request->getStr('title'));
|
2011-08-01 22:51:27 +02:00
|
|
|
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
if ($can_edit_projects) {
|
2013-10-25 19:16:39 +02:00
|
|
|
$projects = $request->getStr('projects');
|
|
|
|
if ($projects) {
|
|
|
|
$tokens = explode(';', $projects);
|
|
|
|
|
|
|
|
$slug_map = id(new PhabricatorProjectQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withPhrictionSlugs($tokens)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$name_map = id(new PhabricatorProjectQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withNames($tokens)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$phid_map = id(new PhabricatorProjectQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withPHIDs($tokens)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$all_map = mpull($slug_map, null, 'getPhrictionSlug') +
|
|
|
|
mpull($name_map, null, 'getName') +
|
|
|
|
mpull($phid_map, null, 'getPHID');
|
|
|
|
|
|
|
|
$default_projects = array();
|
|
|
|
foreach ($tokens as $token) {
|
|
|
|
if (isset($all_map[$token])) {
|
|
|
|
$default_projects[] = $all_map[$token]->getPHID();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($default_projects) {
|
|
|
|
$task->setProjectPHIDs($default_projects);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($can_edit_priority) {
|
|
|
|
$priority = $request->getInt('priority');
|
|
|
|
if ($priority !== null) {
|
|
|
|
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
|
|
|
|
if (isset($priority_map[$priority])) {
|
|
|
|
$task->setPriority($priority);
|
|
|
|
}
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
}
|
2011-08-01 22:51:27 +02:00
|
|
|
}
|
2013-06-05 19:45:07 +02:00
|
|
|
|
|
|
|
$task->setDescription($request->getStr('description'));
|
|
|
|
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
if ($can_edit_assign) {
|
|
|
|
$assign = $request->getStr('assign');
|
|
|
|
if (strlen($assign)) {
|
2013-10-25 20:35:22 +02:00
|
|
|
$assign_user = id(new PhabricatorPeopleQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withUsernames(array($assign))
|
|
|
|
->executeOne();
|
|
|
|
if (!$assign_user) {
|
|
|
|
$assign_user = id(new PhabricatorPeopleQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withPHIDs(array($assign))
|
|
|
|
->executeOne();
|
|
|
|
}
|
|
|
|
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
if ($assign_user) {
|
|
|
|
$task->setOwnerPHID($assign_user->getPHID());
|
|
|
|
}
|
2013-06-05 19:45:07 +02:00
|
|
|
}
|
|
|
|
}
|
2011-05-06 18:17:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$file_phids = $request->getArr('files', array());
|
|
|
|
if (!$file_phids) {
|
|
|
|
// Allow a single 'file' key instead, mostly since Mac OS X urlencodes
|
|
|
|
// square brackets in URLs when passed to 'open', so you can't 'open'
|
|
|
|
// a URL like '?files[]=xyz' and have PHP interpret it correctly.
|
|
|
|
$phid = $request->getStr('file');
|
|
|
|
if ($phid) {
|
|
|
|
$file_phids = array($phid);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($file_phids) {
|
2013-09-30 18:38:13 +02:00
|
|
|
$files = id(new PhabricatorFileQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withPHIDs($file_phids)
|
|
|
|
->execute();
|
2011-05-06 18:17:55 +02:00
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2011-08-03 17:48:42 +02:00
|
|
|
$template_id = $request->getInt('template');
|
|
|
|
|
|
|
|
// You can only have a parent task if you're creating a new task.
|
|
|
|
$parent_id = $request->getInt('parent');
|
|
|
|
if ($parent_id) {
|
2013-09-25 22:44:14 +02:00
|
|
|
$parent_task = id(new ManiphestTaskQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($parent_id))
|
|
|
|
->executeOne();
|
2013-03-31 21:39:54 +02:00
|
|
|
if (!$template_id) {
|
|
|
|
$template_id = $parent_id;
|
|
|
|
}
|
2011-08-03 17:48:42 +02:00
|
|
|
}
|
|
|
|
}
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$errors = array();
|
|
|
|
$e_title = true;
|
|
|
|
|
2013-09-17 00:58:35 +02:00
|
|
|
$field_list = PhabricatorCustomField::getObjectFields(
|
|
|
|
$task,
|
|
|
|
PhabricatorCustomField::ROLE_EDIT);
|
|
|
|
|
|
|
|
foreach ($field_list->getFields() as $field) {
|
|
|
|
$field->setObject($task);
|
|
|
|
$field->setViewer($user);
|
|
|
|
}
|
|
|
|
|
2013-09-17 01:03:01 +02:00
|
|
|
$field_list->readFieldsFromStorage($task);
|
2013-09-17 00:58:35 +02:00
|
|
|
|
|
|
|
$aux_fields = $field_list->getFields();
|
2011-07-27 18:49:50 +02:00
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
if ($request->isFormPost()) {
|
2011-02-20 23:15:53 +01:00
|
|
|
$changes = array();
|
|
|
|
|
|
|
|
$new_title = $request->getStr('title');
|
|
|
|
$new_desc = $request->getStr('description');
|
2011-07-24 21:39:04 +02:00
|
|
|
$new_status = $request->getStr('status');
|
2011-02-20 23:15:53 +01:00
|
|
|
|
2013-09-25 20:16:55 +02:00
|
|
|
if (!$task->getID()) {
|
2011-07-26 19:39:36 +02:00
|
|
|
$workflow = 'create';
|
2013-09-25 20:18:38 +02:00
|
|
|
} else {
|
|
|
|
$workflow = '';
|
2011-02-20 23:15:53 +01:00
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2013-09-25 20:18:38 +02:00
|
|
|
$changes[ManiphestTransaction::TYPE_TITLE] = $new_title;
|
|
|
|
$changes[ManiphestTransaction::TYPE_DESCRIPTION] = $new_desc;
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
if ($can_edit_status) {
|
|
|
|
$changes[ManiphestTransaction::TYPE_STATUS] = $new_status;
|
|
|
|
}
|
2013-09-25 20:18:38 +02:00
|
|
|
|
2011-02-09 21:47:24 +01:00
|
|
|
$owner_tokenizer = $request->getArr('assigned_to');
|
|
|
|
$owner_phid = reset($owner_tokenizer);
|
|
|
|
|
2011-02-20 23:15:53 +01:00
|
|
|
if (!strlen($new_title)) {
|
2013-01-22 23:03:10 +01:00
|
|
|
$e_title = pht('Required');
|
|
|
|
$errors[] = pht('Title is required.');
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
|
|
|
|
2013-09-17 01:03:01 +02:00
|
|
|
$old_values = array();
|
2013-06-22 00:13:48 +02:00
|
|
|
foreach ($aux_fields as $aux_arr_key => $aux_field) {
|
2013-09-17 01:03:01 +02:00
|
|
|
// TODO: This should be buildFieldTransactionsFromRequest() once we
|
|
|
|
// switch to ApplicationTransactions properly.
|
|
|
|
|
|
|
|
$aux_old_value = $aux_field->getOldValueForApplicationTransactions();
|
|
|
|
$aux_field->readValueFromRequest($request);
|
|
|
|
$aux_new_value = $aux_field->getNewValueForApplicationTransactions();
|
2013-06-22 00:13:48 +02:00
|
|
|
|
2013-09-19 20:55:54 +02:00
|
|
|
// TODO: We're faking a call to the ApplicaitonTransaction validation
|
|
|
|
// logic here. We need valid objects to pass, but they aren't used
|
|
|
|
// in a meaningful way. For now, build User objects. Once the Maniphest
|
|
|
|
// objects exist, this will switch over automatically. This is a big
|
|
|
|
// hack but shouldn't be long for this world.
|
|
|
|
$placeholder_editor = new PhabricatorUserProfileEditor();
|
|
|
|
|
|
|
|
$field_errors = $aux_field->validateApplicationTransactions(
|
|
|
|
$placeholder_editor,
|
|
|
|
PhabricatorTransactions::TYPE_CUSTOMFIELD,
|
|
|
|
array(
|
2013-09-24 19:49:06 +02:00
|
|
|
id(new ManiphestTransaction())
|
2013-09-19 20:55:54 +02:00
|
|
|
->setOldValue($aux_old_value)
|
|
|
|
->setNewValue($aux_new_value),
|
|
|
|
));
|
2011-07-27 18:49:50 +02:00
|
|
|
|
2013-09-19 20:55:54 +02:00
|
|
|
foreach ($field_errors as $error) {
|
|
|
|
$errors[] = $error->getMessage();
|
2011-07-27 18:49:50 +02:00
|
|
|
}
|
2013-09-17 01:03:01 +02:00
|
|
|
|
|
|
|
$old_values[$aux_field->getFieldKey()] = $aux_old_value;
|
2011-07-27 18:49:50 +02:00
|
|
|
}
|
|
|
|
|
2011-07-26 19:39:36 +02:00
|
|
|
if ($errors) {
|
2013-09-25 20:16:55 +02:00
|
|
|
$task->setTitle($new_title);
|
|
|
|
$task->setDescription($new_desc);
|
2011-07-26 19:39:36 +02:00
|
|
|
$task->setPriority($request->getInt('priority'));
|
|
|
|
$task->setOwnerPHID($owner_phid);
|
|
|
|
$task->setCCPHIDs($request->getArr('cc'));
|
|
|
|
$task->setProjectPHIDs($request->getArr('projects'));
|
|
|
|
} else {
|
2011-02-09 21:47:24 +01:00
|
|
|
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
if ($can_edit_priority) {
|
|
|
|
$changes[ManiphestTransaction::TYPE_PRIORITY] =
|
|
|
|
$request->getInt('priority');
|
|
|
|
}
|
|
|
|
if ($can_edit_assign) {
|
|
|
|
$changes[ManiphestTransaction::TYPE_OWNER] = $owner_phid;
|
|
|
|
}
|
|
|
|
|
2013-09-25 20:18:38 +02:00
|
|
|
$changes[ManiphestTransaction::TYPE_CCS] = $request->getArr('cc');
|
2011-02-21 05:08:16 +01:00
|
|
|
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
if ($can_edit_projects) {
|
|
|
|
$changes[ManiphestTransaction::TYPE_PROJECTS] =
|
|
|
|
$request->getArr('projects');
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($can_edit_policies) {
|
|
|
|
$changes[PhabricatorTransactions::TYPE_VIEW_POLICY] =
|
|
|
|
$request->getStr('viewPolicy');
|
|
|
|
$changes[PhabricatorTransactions::TYPE_EDIT_POLICY] =
|
|
|
|
$request->getStr('editPolicy');
|
|
|
|
}
|
2013-09-25 22:44:45 +02:00
|
|
|
|
2011-05-06 18:17:55 +02:00
|
|
|
if ($files) {
|
|
|
|
$file_map = mpull($files, 'getPHID');
|
Fix some minor issues with Maniphest file/attachment handling
Summary:
@danielraffel is reporting an issue with file attachments which I can't
reproduce, but I did find a couple of minor things.
- Elsewhere, we store array() as the value of these PHID dictionaries (the
idea being that we might store metadata there some day). While we may or may not
do this, we should at least be consistent.
- When you edit a task, there's a file upload control but it doesn't actually
do anything. Just don't show it, there's no real reason to have it there.
Test Plan: Created a new task with attached files, verified they encoded as "[]"
instead of "true" in the database. Edited a task and didn't get a file control.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: aran
CC: danielraffel, aran
Differential Revision: 1003
2011-10-12 04:30:11 +02:00
|
|
|
$file_map = array_fill_keys($file_map, array());
|
2013-09-25 20:16:43 +02:00
|
|
|
$changes[ManiphestTransaction::TYPE_ATTACH] = array(
|
2013-07-22 17:02:56 +02:00
|
|
|
PhabricatorFilePHIDTypeFile::TYPECONST => $file_map,
|
2011-05-06 18:17:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-09-24 19:49:06 +02:00
|
|
|
$template = new ManiphestTransaction();
|
2011-02-09 21:47:24 +01:00
|
|
|
$transactions = array();
|
|
|
|
|
|
|
|
foreach ($changes as $type => $value) {
|
|
|
|
$transaction = clone $template;
|
|
|
|
$transaction->setTransactionType($type);
|
|
|
|
$transaction->setNewValue($value);
|
|
|
|
$transactions[] = $transaction;
|
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2011-12-24 04:03:28 +01:00
|
|
|
if ($aux_fields) {
|
|
|
|
foreach ($aux_fields as $aux_field) {
|
|
|
|
$transaction = clone $template;
|
|
|
|
$transaction->setTransactionType(
|
Migrate all Maniphest transaction data to new storage
Summary:
Ref T2217. This is the risky, hard part; everything after this should be smooth sailing. This is //mostly// clean, except:
- The old format would opportunistically combine a comment with some other transaction type if it could. We no longer do that, so:
- When migrating, "edit" + "comment" transactions need to be split in two.
- When editing now, we should no longer combine these transaction types.
- These changes are pretty straightforward and low-impact.
- This migration promotes "auxiliary field" data to the new CustomField/StandardField format, so that's not a straight migration either. The formats are very similar, though.
Broadly, this takes the same attack that the auth migration did: proxy all the code through to the new storage. `ManiphestTransaction` is now just an API on top of `ManiphestTransactionPro`, which is the new storage format. The two formats are very similar, so this was mostly a straight copy from one table to the other.
Test Plan:
- Without performing the migration, made a bunch of edits and comments on tasks and verified the new code works correctly.
- Droped the test data and performed the migration.
- Looked at the resulting data for obvious discrepancies.
- Looked at a bunch of tasks and their transaction history.
- Used Conduit to pull transaction data.
- Edited task description and clicked "View Details" on transaction.
- Used batch editor.
- Made a bunch more edits.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2217
Differential Revision: https://secure.phabricator.com/D7068
2013-09-23 23:25:28 +02:00
|
|
|
PhabricatorTransactions::TYPE_CUSTOMFIELD);
|
2013-09-17 01:03:01 +02:00
|
|
|
$aux_key = $aux_field->getFieldKey();
|
Migrate all Maniphest transaction data to new storage
Summary:
Ref T2217. This is the risky, hard part; everything after this should be smooth sailing. This is //mostly// clean, except:
- The old format would opportunistically combine a comment with some other transaction type if it could. We no longer do that, so:
- When migrating, "edit" + "comment" transactions need to be split in two.
- When editing now, we should no longer combine these transaction types.
- These changes are pretty straightforward and low-impact.
- This migration promotes "auxiliary field" data to the new CustomField/StandardField format, so that's not a straight migration either. The formats are very similar, though.
Broadly, this takes the same attack that the auth migration did: proxy all the code through to the new storage. `ManiphestTransaction` is now just an API on top of `ManiphestTransactionPro`, which is the new storage format. The two formats are very similar, so this was mostly a straight copy from one table to the other.
Test Plan:
- Without performing the migration, made a bunch of edits and comments on tasks and verified the new code works correctly.
- Droped the test data and performed the migration.
- Looked at the resulting data for obvious discrepancies.
- Looked at a bunch of tasks and their transaction history.
- Used Conduit to pull transaction data.
- Edited task description and clicked "View Details" on transaction.
- Used batch editor.
- Made a bunch more edits.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T2217
Differential Revision: https://secure.phabricator.com/D7068
2013-09-23 23:25:28 +02:00
|
|
|
$transaction->setMetadataValue('customfield:key', $aux_key);
|
2013-09-19 20:56:15 +02:00
|
|
|
$old = idx($old_values, $aux_key);
|
|
|
|
$new = $aux_field->getNewValueForApplicationTransactions();
|
|
|
|
|
|
|
|
$transaction->setOldValue($old);
|
|
|
|
$transaction->setNewValue($new);
|
|
|
|
|
2011-12-24 04:03:28 +01:00
|
|
|
$transactions[] = $transaction;
|
|
|
|
}
|
|
|
|
}
|
2011-08-31 22:25:13 +02:00
|
|
|
|
2011-12-24 04:03:28 +01:00
|
|
|
if ($transactions) {
|
2012-04-17 21:09:04 +02:00
|
|
|
$is_new = !$task->getID();
|
|
|
|
|
2011-08-31 22:25:13 +02:00
|
|
|
$event = new PhabricatorEvent(
|
|
|
|
PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK,
|
|
|
|
array(
|
|
|
|
'task' => $task,
|
2012-04-17 21:09:04 +02:00
|
|
|
'new' => $is_new,
|
2011-08-31 22:25:13 +02:00
|
|
|
'transactions' => $transactions,
|
|
|
|
));
|
|
|
|
$event->setUser($user);
|
|
|
|
$event->setAphrontRequest($request);
|
2011-11-10 02:23:33 +01:00
|
|
|
PhutilEventEngine::dispatchEvent($event);
|
2011-08-31 22:25:13 +02:00
|
|
|
|
|
|
|
$task = $event->getValue('task');
|
|
|
|
$transactions = $event->getValue('transactions');
|
|
|
|
|
2013-10-22 01:58:37 +02:00
|
|
|
$editor = id(new ManiphestTransactionEditor())
|
2013-09-24 15:26:59 +02:00
|
|
|
->setActor($user)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->applyTransactions($task, $transactions);
|
2012-04-17 21:09:04 +02:00
|
|
|
|
|
|
|
$event = new PhabricatorEvent(
|
|
|
|
PhabricatorEventType::TYPE_MANIPHEST_DIDEDITTASK,
|
|
|
|
array(
|
|
|
|
'task' => $task,
|
|
|
|
'new' => $is_new,
|
|
|
|
'transactions' => $transactions,
|
|
|
|
));
|
|
|
|
$event->setUser($user);
|
|
|
|
$event->setAphrontRequest($request);
|
|
|
|
PhutilEventEngine::dispatchEvent($event);
|
2011-05-07 02:22:48 +02:00
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2012-04-17 21:09:04 +02:00
|
|
|
|
2011-08-03 17:48:42 +02:00
|
|
|
if ($parent_task) {
|
2012-07-20 17:59:39 +02:00
|
|
|
id(new PhabricatorEdgeEditor())
|
2012-10-16 22:39:35 +02:00
|
|
|
->setActor($user)
|
2012-07-20 17:59:39 +02:00
|
|
|
->addEdge(
|
|
|
|
$parent_task->getPHID(),
|
|
|
|
PhabricatorEdgeConfig::TYPE_TASK_DEPENDS_ON_TASK,
|
|
|
|
$task->getPHID())
|
|
|
|
->save();
|
2011-08-03 17:48:42 +02:00
|
|
|
$workflow = $parent_task->getID();
|
|
|
|
}
|
|
|
|
|
2013-05-31 03:55:25 +02:00
|
|
|
if ($request->isAjax()) {
|
|
|
|
return id(new AphrontAjaxResponse())->setContent(
|
|
|
|
array(
|
|
|
|
'tasks' => $this->renderSingleTask($task),
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2011-07-26 19:39:36 +02:00
|
|
|
$redirect_uri = '/T'.$task->getID();
|
|
|
|
|
|
|
|
if ($workflow) {
|
|
|
|
$redirect_uri .= '?workflow='.$workflow;
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
return id(new AphrontRedirectResponse())
|
2011-07-26 19:39:36 +02:00
|
|
|
->setURI($redirect_uri);
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
2011-02-09 21:47:24 +01:00
|
|
|
} else {
|
2011-02-20 23:15:53 +01:00
|
|
|
if (!$task->getID()) {
|
|
|
|
$task->setCCPHIDs(array(
|
|
|
|
$user->getPHID(),
|
|
|
|
));
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
if ($template_id) {
|
2013-09-25 22:44:14 +02:00
|
|
|
$template_task = id(new ManiphestTaskQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withIDs(array($template_id))
|
|
|
|
->executeOne();
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
if ($template_task) {
|
|
|
|
$task->setCCPHIDs($template_task->getCCPHIDs());
|
|
|
|
$task->setProjectPHIDs($template_task->getProjectPHIDs());
|
|
|
|
$task->setOwnerPHID($template_task->getOwnerPHID());
|
2012-08-06 04:10:20 +02:00
|
|
|
$task->setPriority($template_task->getPriority());
|
2012-05-07 22:38:27 +02:00
|
|
|
|
2013-09-17 01:03:01 +02:00
|
|
|
$template_fields = PhabricatorCustomField::getObjectFields(
|
|
|
|
$template_task,
|
|
|
|
PhabricatorCustomField::ROLE_EDIT);
|
|
|
|
|
|
|
|
$fields = $template_fields->getFields();
|
|
|
|
foreach ($fields as $key => $field) {
|
|
|
|
if (!$field->shouldCopyWhenCreatingSimilarTask()) {
|
|
|
|
unset($fields[$key]);
|
|
|
|
}
|
|
|
|
if (empty($aux_fields[$key])) {
|
|
|
|
unset($fields[$key]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($fields) {
|
|
|
|
id(new PhabricatorCustomFieldList($fields))
|
|
|
|
->readFieldsFromStorage($template_task);
|
2012-05-07 22:38:27 +02:00
|
|
|
|
2013-09-17 01:03:01 +02:00
|
|
|
foreach ($fields as $key => $field) {
|
|
|
|
$aux_fields[$key]->setValueFromStorage(
|
|
|
|
$field->getValueForStorage());
|
2012-05-07 22:38:27 +02:00
|
|
|
}
|
|
|
|
}
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
}
|
|
|
|
}
|
2011-02-20 23:15:53 +01:00
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$phids = array_merge(
|
|
|
|
array($task->getOwnerPHID()),
|
2011-02-21 05:08:16 +01:00
|
|
|
$task->getCCPHIDs(),
|
2013-09-19 20:56:30 +02:00
|
|
|
$task->getProjectPHIDs());
|
2011-07-26 19:39:36 +02:00
|
|
|
|
2011-08-03 17:48:42 +02:00
|
|
|
if ($parent_task) {
|
|
|
|
$phids[] = $parent_task->getPHID();
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$phids = array_filter($phids);
|
|
|
|
$phids = array_unique($phids);
|
|
|
|
|
2012-09-05 04:02:56 +02:00
|
|
|
$handles = $this->loadViewerHandles($phids);
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
$error_view = null;
|
|
|
|
if ($errors) {
|
|
|
|
$error_view = new AphrontErrorView();
|
|
|
|
$error_view->setErrors($errors);
|
2013-01-22 23:03:10 +01:00
|
|
|
$error_view->setTitle(pht('Form Errors'));
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
|
|
|
|
|
|
|
|
if ($task->getOwnerPHID()) {
|
2013-10-07 21:51:24 +02:00
|
|
|
$assigned_value = array($handles[$task->getOwnerPHID()]);
|
2011-02-08 19:53:59 +01:00
|
|
|
} else {
|
|
|
|
$assigned_value = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($task->getCCPHIDs()) {
|
2013-10-07 21:51:24 +02:00
|
|
|
$cc_value = array_select_keys($handles, $task->getCCPHIDs());
|
2011-02-08 19:53:59 +01:00
|
|
|
} else {
|
|
|
|
$cc_value = array();
|
|
|
|
}
|
|
|
|
|
2011-02-21 05:08:16 +01:00
|
|
|
if ($task->getProjectPHIDs()) {
|
2013-10-07 21:51:24 +02:00
|
|
|
$projects_value = array_select_keys($handles, $task->getProjectPHIDs());
|
2011-02-21 05:08:16 +01:00
|
|
|
} else {
|
|
|
|
$projects_value = array();
|
|
|
|
}
|
|
|
|
|
Tweak style on "Create Another Task" button
Summary:
Not totally sure I'm in love with this but I think it's somewhat non-terrible,
despite the lack of lens flare.
Also made "Cancel" take you back to the task if you got to "Create" from "Create
Another Task".
Test Plan:
- Style:
https://secure.phabricator.com/file/view/PHID-FILE-ad37d3c1f3b2c7a7a7d1/
- Hit "Cancel" from "Create Another", got sent back to task.
- Hit "Cancel" from normal create, got sent back to list.
- Tried to save an invalid task after making changes to CC/Projects, changes
were preserved.
Reviewed By: codeblock
Reviewers: hunterbridges, jungejason, tuomaspelkonen, aran, codeblock
CC: aran, epriestley, codeblock
Differential Revision: 736
2011-07-27 19:46:22 +02:00
|
|
|
$cancel_id = nonempty($task->getID(), $template_id);
|
|
|
|
if ($cancel_id) {
|
|
|
|
$cancel_uri = '/T'.$cancel_id;
|
|
|
|
} else {
|
|
|
|
$cancel_uri = '/maniphest/';
|
|
|
|
}
|
|
|
|
|
2011-02-20 23:15:53 +01:00
|
|
|
if ($task->getID()) {
|
2013-01-22 23:03:10 +01:00
|
|
|
$button_name = pht('Save Task');
|
|
|
|
$header_name = pht('Edit Task');
|
2011-08-03 17:48:42 +02:00
|
|
|
} else if ($parent_task) {
|
|
|
|
$cancel_uri = '/T'.$parent_task->getID();
|
2013-01-22 23:03:10 +01:00
|
|
|
$button_name = pht('Create Task');
|
|
|
|
$header_name = pht('Create New Subtask');
|
2011-02-20 23:15:53 +01:00
|
|
|
} else {
|
2013-01-22 23:03:10 +01:00
|
|
|
$button_name = pht('Create Task');
|
|
|
|
$header_name = pht('Create New Task');
|
2011-02-20 23:15:53 +01:00
|
|
|
}
|
|
|
|
|
2012-01-25 20:23:00 +01:00
|
|
|
require_celerity_resource('maniphest-task-edit-css');
|
|
|
|
|
2011-06-10 00:28:29 +02:00
|
|
|
$project_tokenizer_id = celerity_generate_unique_node_id();
|
|
|
|
|
2013-05-31 03:55:25 +02:00
|
|
|
if ($request->isAjax()) {
|
2013-08-26 20:53:11 +02:00
|
|
|
$form = new PHUIFormLayoutView();
|
2013-05-31 03:55:25 +02:00
|
|
|
} else {
|
|
|
|
$form = new AphrontFormView();
|
|
|
|
$form
|
|
|
|
->setUser($user)
|
|
|
|
->addHiddenInput('template', $template_id);
|
|
|
|
}
|
2011-08-03 17:48:42 +02:00
|
|
|
|
|
|
|
if ($parent_task) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormStaticControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Parent Task'))
|
2011-08-03 17:48:42 +02:00
|
|
|
->setValue($handles[$parent_task->getPHID()]->getFullName()))
|
|
|
|
->addHiddenInput('parent', $parent_task->getID());
|
|
|
|
}
|
|
|
|
|
|
|
|
$form
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Title'))
|
2011-02-08 19:53:59 +01:00
|
|
|
->setName('title')
|
|
|
|
->setError($e_title)
|
|
|
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
|
2011-07-24 21:39:04 +02:00
|
|
|
->setValue($task->getTitle()));
|
|
|
|
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
if ($task->getID() && $can_edit_status) {
|
2011-07-24 21:39:04 +02:00
|
|
|
// Only show this in "edit" mode, not "create" mode, since creating a
|
|
|
|
// non-open task is kind of silly and it would just clutter up the
|
|
|
|
// "create" interface.
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Status'))
|
2011-07-24 21:39:04 +02:00
|
|
|
->setName('status')
|
|
|
|
->setValue($task->getStatus())
|
|
|
|
->setOptions(ManiphestTaskStatus::getTaskStatusMap()));
|
|
|
|
}
|
|
|
|
|
2013-09-25 22:44:45 +02:00
|
|
|
$policies = id(new PhabricatorPolicyQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->setObject($task)
|
|
|
|
->execute();
|
|
|
|
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
if ($can_edit_assign) {
|
|
|
|
$form->appendChild(
|
2011-02-08 19:53:59 +01:00
|
|
|
id(new AphrontFormTokenizerControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Assigned To'))
|
2011-02-08 19:53:59 +01:00
|
|
|
->setName('assigned_to')
|
|
|
|
->setValue($assigned_value)
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-10 00:46:39 +01:00
|
|
|
->setUser($user)
|
2011-02-08 19:53:59 +01:00
|
|
|
->setDatasource('/typeahead/common/users/')
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
->setLimit(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
$form
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('CC'))
|
2011-02-08 19:53:59 +01:00
|
|
|
->setName('cc')
|
|
|
|
->setValue($cc_value)
|
Use Javelin placeholders and new sorting rules broadly; consolidate tokenizer construction code
Summary:
- We have three nearly-identical blocks of Tokenizer construction code; consolidate them into Prefab.
- Add placeholder support.
- Augment server-side stuff to specify placeholder text.
Test Plan: Verified behavior of Differential edit tokenizers, Differential comment tokenizers, Maniphest edit tokenizers, Maniphest comment tokenizers, Maniphest filter tokenizers, Differential filter tokenizers, Owners filter tokenizers, Owners edit tokenizers, Herald edit tokenizers, Audit filter tokenizers.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran, epriestley
Maniphest Tasks: T772, T946
Differential Revision: https://secure.phabricator.com/D1844
2012-03-10 00:46:39 +01:00
|
|
|
->setUser($user)
|
Add capabilities for editing task triage details (priority, assignee, etc)
Summary:
This is primarily a client request, and a little bit use-case specific, but policies seem to be holding up well and I'm getting more comfortable about maintaining this. Much if it can run through ApplicationTransactions.
Allow the ability to edit status, policies, priorities, assignees and projects of a task to be restricted to some subset of users. Also allow bulk edit to be locked. This affects the editor itself and the edit, view and list interfaces.
Test Plan: As a restricted user, created, edited and commented on tasks. Tried to drag them around.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7357
2013-10-22 01:59:06 +02:00
|
|
|
->setDatasource('/typeahead/common/mailable/'));
|
|
|
|
|
|
|
|
if ($can_edit_priority) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Priority'))
|
|
|
|
->setName('priority')
|
|
|
|
->setOptions($priority_map)
|
|
|
|
->setValue($task->getPriority()));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($can_edit_policies) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormPolicyControl())
|
|
|
|
->setUser($user)
|
|
|
|
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
|
|
|
|
->setPolicyObject($task)
|
|
|
|
->setPolicies($policies)
|
|
|
|
->setName('viewPolicy'))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormPolicyControl())
|
|
|
|
->setUser($user)
|
|
|
|
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
|
|
|
|
->setPolicyObject($task)
|
|
|
|
->setPolicies($policies)
|
|
|
|
->setName('editPolicy'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($can_edit_projects) {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
->setLabel(pht('Projects'))
|
|
|
|
->setName('projects')
|
|
|
|
->setValue($projects_value)
|
|
|
|
->setID($project_tokenizer_id)
|
|
|
|
->setCaption(
|
|
|
|
javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => '/project/create/',
|
|
|
|
'mustcapture' => true,
|
|
|
|
'sigil' => 'project-create',
|
|
|
|
),
|
|
|
|
pht('Create New Project')))
|
|
|
|
->setDatasource('/typeahead/common/projects/'));
|
|
|
|
}
|
2011-05-06 18:17:55 +02:00
|
|
|
|
2013-03-08 02:24:58 +01:00
|
|
|
foreach ($aux_fields as $aux_field) {
|
2013-09-19 20:55:45 +02:00
|
|
|
$aux_control = $aux_field->renderEditControl();
|
2013-03-08 02:24:58 +01:00
|
|
|
$form->appendChild($aux_control);
|
2011-07-27 18:49:50 +02:00
|
|
|
}
|
|
|
|
|
2011-06-26 17:37:47 +02:00
|
|
|
require_celerity_resource('aphront-error-view-css');
|
|
|
|
|
2012-08-08 19:03:41 +02:00
|
|
|
Javelin::initBehavior('project-create', array(
|
2011-06-10 00:28:29 +02:00
|
|
|
'tokenizerID' => $project_tokenizer_id,
|
|
|
|
));
|
|
|
|
|
2011-05-06 18:17:55 +02:00
|
|
|
if ($files) {
|
2013-02-05 23:30:29 +01:00
|
|
|
$file_display = mpull($files, 'getName');
|
2013-02-13 23:50:15 +01:00
|
|
|
$file_display = phutil_implode_html(phutil_tag('br'), $file_display);
|
2011-05-06 18:17:55 +02:00
|
|
|
|
|
|
|
$form->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Files'))
|
2011-05-06 18:17:55 +02:00
|
|
|
->setValue($file_display));
|
|
|
|
|
|
|
|
foreach ($files as $ii => $file) {
|
|
|
|
$form->addHiddenInput('files['.$ii.']', $file->getPHID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-19 21:27:28 +02:00
|
|
|
|
|
|
|
$description_control = new PhabricatorRemarkupControl();
|
|
|
|
// "Upsell" creating tasks via email in create flows if the instance is
|
|
|
|
// configured for this awesomeness.
|
2011-07-04 18:45:42 +02:00
|
|
|
$email_create = PhabricatorEnv::getEnvConfig(
|
|
|
|
'metamta.maniphest.public-create-email');
|
|
|
|
if (!$task->getID() && $email_create) {
|
2013-02-05 22:23:05 +01:00
|
|
|
$email_hint = pht(
|
|
|
|
'You can also create tasks by sending an email to: %s',
|
|
|
|
phutil_tag('tt', array(), $email_create));
|
2012-09-19 21:27:28 +02:00
|
|
|
$description_control->setCaption($email_hint);
|
2011-07-04 18:45:42 +02:00
|
|
|
}
|
|
|
|
|
2012-09-19 21:27:28 +02:00
|
|
|
$description_control
|
2013-01-22 23:03:10 +01:00
|
|
|
->setLabel(pht('Description'))
|
2012-09-19 21:27:28 +02:00
|
|
|
->setName('description')
|
|
|
|
->setID('description-textarea')
|
2012-11-27 23:06:31 +01:00
|
|
|
->setValue($task->getDescription())
|
|
|
|
->setUser($user);
|
2011-08-19 18:36:41 +02:00
|
|
|
|
2011-05-06 18:17:55 +02:00
|
|
|
$form
|
2012-09-19 21:27:28 +02:00
|
|
|
->appendChild($description_control);
|
|
|
|
|
2013-05-31 03:55:25 +02:00
|
|
|
|
|
|
|
if ($request->isAjax()) {
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
|
|
->setUser($user)
|
|
|
|
->setWidth(AphrontDialogView::WIDTH_FULL)
|
|
|
|
->setTitle($header_name)
|
|
|
|
->appendChild(
|
|
|
|
array(
|
|
|
|
$error_view,
|
|
|
|
$form,
|
|
|
|
))
|
|
|
|
->addCancelButton($cancel_uri)
|
|
|
|
->addSubmitButton($button_name);
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
}
|
|
|
|
|
Fix some minor issues with Maniphest file/attachment handling
Summary:
@danielraffel is reporting an issue with file attachments which I can't
reproduce, but I did find a couple of minor things.
- Elsewhere, we store array() as the value of these PHID dictionaries (the
idea being that we might store metadata there some day). While we may or may not
do this, we should at least be consistent.
- When you edit a task, there's a file upload control but it doesn't actually
do anything. Just don't show it, there's no real reason to have it there.
Test Plan: Created a new task with attached files, verified they encoded as "[]"
instead of "true" in the database. Edited a task and didn't get a file control.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: aran
CC: danielraffel, aran
Differential Revision: 1003
2011-10-12 04:30:11 +02:00
|
|
|
$form
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2011-02-20 23:15:53 +01:00
|
|
|
->addCancelButton($cancel_uri)
|
|
|
|
->setValue($button_name));
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-26 20:53:11 +02:00
|
|
|
->setHeaderText($header_name)
|
|
|
|
->setFormError($error_view)
|
|
|
|
->setForm($form);
|
|
|
|
|
2013-08-05 19:46:39 +02:00
|
|
|
$preview = id(new PHUIRemarkupPreviewPanel())
|
|
|
|
->setHeader(pht('Description Preview'))
|
|
|
|
->setControlID('description-textarea')
|
|
|
|
->setPreviewURI($this->getApplicationURI('task/descriptionpreview/'));
|
2012-01-25 20:23:00 +01:00
|
|
|
|
2012-06-14 02:28:21 +02:00
|
|
|
if ($task->getID()) {
|
Add a secret board view to Projects
Summary:
Ref T1344. This is //very// rough. Some UI issues:
- Empty states for the board and columns are junky.
- Column widths are crazy. I think we need to set them to fixed-width, since we may have an arbitrarily large number of columns?
- I don't think we have the header UI elements in M10 yet and that mock is pretty old, so I sort of very roughly approximated it.
- What should we do when you click a task title? Popping the whole task in a dialog is possible but needs a bunch of work to actually work. Might need to build "sheets" or something.
- Icons are slightly clipped for some reason.
- All the backend stuff is totally faked.
Generally, my plan is just to use these to implement all of T390. Specifically:
- "Kanban" projects will have "Backlog" on the left. You'll drag them toward the right as you make progress.
- "Milestone" projects will have "No Milestone" on the left, then "Milestone 9", "Milestone 8", etc.
- "Sprint" projects will have "Backlog" on the left, then "Sprint 31", "Sprint 30", etc.
So all of these things end up being pretty much exactly the same, with some minor text changes and new columns showing up on the left vs the right or whatever.
Test Plan: See screenshot.
Reviewers: chad, btrahan
Reviewed By: btrahan
CC: chad, aran, sascha-egerer
Maniphest Tasks: T1344
Differential Revision: https://secure.phabricator.com/D7374
2013-10-22 06:11:36 +02:00
|
|
|
$page_objects = array($task->getPHID());
|
2012-06-14 02:28:21 +02:00
|
|
|
} else {
|
|
|
|
$page_objects = array();
|
|
|
|
}
|
|
|
|
|
2013-03-26 21:15:15 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
2013-09-13 20:29:08 +02:00
|
|
|
->setName($header_name));
|
2013-03-26 21:15:15 +01:00
|
|
|
|
2013-01-22 23:03:10 +01:00
|
|
|
return $this->buildApplicationPage(
|
2011-02-08 19:53:59 +01:00
|
|
|
array(
|
2013-03-26 21:15:15 +01:00
|
|
|
$crumbs,
|
2013-08-26 20:53:11 +02:00
|
|
|
$form_box,
|
2013-08-05 19:46:39 +02:00
|
|
|
$preview,
|
2011-02-08 19:53:59 +01:00
|
|
|
),
|
|
|
|
array(
|
2012-01-25 20:23:00 +01:00
|
|
|
'title' => $header_name,
|
2012-06-14 02:28:21 +02:00
|
|
|
'pageObjects' => $page_objects,
|
2013-03-13 07:30:03 +01:00
|
|
|
'device' => true,
|
2011-02-08 19:53:59 +01:00
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|