2011-02-08 19:53:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Facebook, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class ManiphestTaskDetailController extends ManiphestController {
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->id = $data['id'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$e_title = null;
|
|
|
|
|
|
|
|
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
|
|
|
|
|
|
|
|
$task = id(new ManiphestTask())->load($this->id);
|
2011-03-31 06:38:24 +02:00
|
|
|
if (!$task) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
$transactions = id(new ManiphestTransaction())->loadAllWhere(
|
2011-04-11 11:45:53 +02:00
|
|
|
'taskID = %d ORDER BY id ASC',
|
2011-02-08 19:53:59 +01:00
|
|
|
$task->getID());
|
|
|
|
|
|
|
|
$phids = array();
|
|
|
|
foreach ($transactions as $transaction) {
|
|
|
|
foreach ($transaction->extractPHIDs() as $phid) {
|
|
|
|
$phids[$phid] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($task->getCCPHIDs() as $phid) {
|
|
|
|
$phids[$phid] = true;
|
|
|
|
}
|
2011-02-21 05:08:16 +01:00
|
|
|
foreach ($task->getProjectPHIDs() as $phid) {
|
|
|
|
$phids[$phid] = true;
|
|
|
|
}
|
2011-02-08 19:53:59 +01:00
|
|
|
if ($task->getOwnerPHID()) {
|
|
|
|
$phids[$task->getOwnerPHID()] = true;
|
|
|
|
}
|
|
|
|
$phids[$task->getAuthorPHID()] = true;
|
|
|
|
$phids = array_keys($phids);
|
|
|
|
|
2011-02-17 23:32:01 +01:00
|
|
|
$attached = $task->getAttached();
|
|
|
|
foreach ($attached as $type => $list) {
|
|
|
|
foreach ($list as $phid => $info) {
|
|
|
|
$phids[$phid] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$handles = id(new PhabricatorObjectHandleData($phids))
|
|
|
|
->loadHandles();
|
|
|
|
|
|
|
|
$factory = new DifferentialMarkupEngineFactory();
|
|
|
|
$engine = $factory->newDifferentialCommentMarkupEngine();
|
|
|
|
|
|
|
|
$dict = array();
|
|
|
|
$dict['Status'] =
|
|
|
|
'<strong>'.
|
|
|
|
ManiphestTaskStatus::getTaskStatusFullName($task->getStatus()).
|
|
|
|
'</strong>';
|
|
|
|
|
|
|
|
$dict['Assigned To'] = $task->getOwnerPHID()
|
2011-02-09 06:01:42 +01:00
|
|
|
? $handles[$task->getOwnerPHID()]->renderLink()
|
|
|
|
: '<em>None</em>';
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
$dict['Priority'] = ManiphestTaskPriority::getTaskPriorityName(
|
|
|
|
$task->getPriority());
|
|
|
|
|
|
|
|
$cc = $task->getCCPHIDs();
|
|
|
|
if ($cc) {
|
|
|
|
$cc_links = array();
|
|
|
|
foreach ($cc as $phid) {
|
|
|
|
$cc_links[] = $handles[$phid]->renderLink();
|
|
|
|
}
|
|
|
|
$dict['CC'] = implode(', ', $cc_links);
|
|
|
|
} else {
|
|
|
|
$dict['CC'] = '<em>None</em>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$dict['Author'] = $handles[$task->getAuthorPHID()]->renderLink();
|
|
|
|
|
2011-02-21 05:08:16 +01:00
|
|
|
$projects = $task->getProjectPHIDs();
|
|
|
|
if ($projects) {
|
|
|
|
$project_links = array();
|
|
|
|
foreach ($projects as $phid) {
|
|
|
|
$project_links[] = $handles[$phid]->renderLink();
|
|
|
|
}
|
|
|
|
$dict['Projects'] = implode(', ', $project_links);
|
|
|
|
} else {
|
|
|
|
$dict['Projects'] = '<em>None</em>';
|
|
|
|
}
|
|
|
|
|
2011-03-03 03:58:21 +01:00
|
|
|
if (idx($attached, PhabricatorPHIDConstants::PHID_TYPE_DREV)) {
|
|
|
|
$revs = idx($attached, PhabricatorPHIDConstants::PHID_TYPE_DREV);
|
2011-02-17 23:32:01 +01:00
|
|
|
$rev_links = array();
|
|
|
|
foreach ($revs as $rev => $info) {
|
|
|
|
$rev_links[] = $handles[$rev]->renderLink();
|
|
|
|
}
|
|
|
|
$rev_links = implode(', ', $rev_links);
|
|
|
|
$dict['Revisions'] = $rev_links;
|
|
|
|
}
|
|
|
|
|
2011-03-03 03:58:21 +01:00
|
|
|
if (idx($attached, PhabricatorPHIDConstants::PHID_TYPE_FILE)) {
|
|
|
|
$revs = idx($attached, PhabricatorPHIDConstants::PHID_TYPE_FILE);
|
2011-02-21 05:08:16 +01:00
|
|
|
$rev_links = array();
|
|
|
|
foreach ($revs as $rev => $info) {
|
|
|
|
$rev_links[] = $handles[$rev]->renderLink();
|
|
|
|
}
|
|
|
|
$rev_links = implode(', ', $rev_links);
|
|
|
|
$dict['Files'] = $rev_links;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-09 23:10:12 +01:00
|
|
|
$dict['Description'] =
|
|
|
|
'<div class="maniphest-task-description">'.
|
|
|
|
'<div class="phabricator-remarkup">'.
|
|
|
|
$engine->markupText($task->getDescription()).
|
|
|
|
'</div>'.
|
|
|
|
'</div>';
|
2011-02-08 19:53:59 +01:00
|
|
|
|
|
|
|
require_celerity_resource('mainphest-task-detail-css');
|
|
|
|
|
|
|
|
$table = array();
|
|
|
|
foreach ($dict as $key => $value) {
|
|
|
|
$table[] =
|
|
|
|
'<tr>'.
|
|
|
|
'<th>'.phutil_escape_html($key).':</th>'.
|
|
|
|
'<td>'.$value.'</td>'.
|
|
|
|
'</tr>';
|
|
|
|
}
|
|
|
|
$table =
|
|
|
|
'<table class="maniphest-task-properties">'.
|
|
|
|
implode("\n", $table).
|
|
|
|
'</table>';
|
|
|
|
|
2011-02-20 23:15:53 +01:00
|
|
|
|
2011-02-20 21:50:28 +01:00
|
|
|
$actions = array();
|
2011-02-20 23:15:53 +01:00
|
|
|
|
2011-02-20 21:50:28 +01:00
|
|
|
$action = new AphrontHeadsupActionView();
|
|
|
|
$action->setName('Edit Task');
|
2011-02-20 23:15:53 +01:00
|
|
|
$action->setURI('/maniphest/task/edit/'.$task->getID().'/');
|
2011-02-20 21:50:28 +01:00
|
|
|
$action->setClass('action-edit');
|
|
|
|
$actions[] = $action;
|
|
|
|
|
2011-05-16 20:43:39 +02:00
|
|
|
require_celerity_resource('phabricator-object-selector-css');
|
|
|
|
require_celerity_resource('javelin-behavior-phabricator-object-selector');
|
|
|
|
|
2011-02-20 21:50:28 +01:00
|
|
|
$action = new AphrontHeadsupActionView();
|
|
|
|
$action->setName('Edit Differential Revisions');
|
2011-05-16 20:43:39 +02:00
|
|
|
$action->setURI('/search/attach/'.$task->getPHID().'/DREV/');
|
|
|
|
$action->setWorkflow(true);
|
|
|
|
$action->setClass('action-attach');
|
2011-02-20 21:50:28 +01:00
|
|
|
$actions[] = $action;
|
2011-02-20 23:15:53 +01:00
|
|
|
|
2011-02-20 21:50:28 +01:00
|
|
|
$action_list = new AphrontHeadsupActionListView();
|
|
|
|
$action_list->setActions($actions);
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$panel =
|
|
|
|
'<div class="maniphest-panel">'.
|
2011-02-20 21:50:28 +01:00
|
|
|
$action_list->render().
|
2011-02-08 19:53:59 +01:00
|
|
|
'<div class="maniphest-task-detail-core">'.
|
|
|
|
'<h1>'.
|
|
|
|
phutil_escape_html('T'.$task->getID().' '.$task->getTitle()).
|
|
|
|
'</h1>'.
|
|
|
|
$table.
|
|
|
|
'</div>'.
|
|
|
|
'</div>';
|
|
|
|
|
|
|
|
$transaction_types = ManiphestTransactionType::getTransactionTypeMap();
|
|
|
|
$resolution_types = ManiphestTaskStatus::getTaskStatusMap();
|
|
|
|
|
|
|
|
if ($task->getStatus() == ManiphestTaskStatus::STATUS_OPEN) {
|
|
|
|
$resolution_types = array_select_keys(
|
|
|
|
$resolution_types,
|
|
|
|
array(
|
|
|
|
ManiphestTaskStatus::STATUS_CLOSED_RESOLVED,
|
|
|
|
ManiphestTaskStatus::STATUS_CLOSED_WONTFIX,
|
|
|
|
ManiphestTaskStatus::STATUS_CLOSED_INVALID,
|
|
|
|
ManiphestTaskStatus::STATUS_CLOSED_SPITE,
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
$resolution_types = array(
|
|
|
|
ManiphestTaskStatus::STATUS_OPEN => 'Reopened',
|
|
|
|
);
|
|
|
|
$transaction_types[ManiphestTransactionType::TYPE_STATUS] =
|
|
|
|
'Reopen Task';
|
|
|
|
unset($transaction_types[ManiphestTransactionType::TYPE_PRIORITY]);
|
|
|
|
unset($transaction_types[ManiphestTransactionType::TYPE_OWNER]);
|
|
|
|
}
|
|
|
|
|
|
|
|
$default_claim = array(
|
|
|
|
$user->getPHID() => $user->getUsername().' ('.$user->getRealName().')',
|
|
|
|
);
|
|
|
|
|
2011-05-11 01:18:47 +02:00
|
|
|
$draft = id(new PhabricatorDraft())->loadOneWhere(
|
|
|
|
'authorPHID = %s AND draftKey = %s',
|
|
|
|
$user->getPHID(),
|
|
|
|
$task->getPHID());
|
|
|
|
if ($draft) {
|
|
|
|
$draft_text = $draft->getDraft();
|
|
|
|
} else {
|
|
|
|
$draft_text = null;
|
|
|
|
}
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$comment_form = new AphrontFormView();
|
|
|
|
$comment_form
|
|
|
|
->setUser($user)
|
|
|
|
->setAction('/maniphest/transaction/save/')
|
2011-02-21 05:08:16 +01:00
|
|
|
->setEncType('multipart/form-data')
|
2011-02-08 19:53:59 +01:00
|
|
|
->addHiddenInput('taskID', $task->getID())
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel('Action')
|
|
|
|
->setName('action')
|
|
|
|
->setOptions($transaction_types)
|
|
|
|
->setID('transaction-action'))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel('Resolution')
|
|
|
|
->setName('resolution')
|
|
|
|
->setControlID('resolution')
|
|
|
|
->setControlStyle('display: none')
|
|
|
|
->setOptions($resolution_types))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
->setLabel('Assign To')
|
|
|
|
->setName('assign_to')
|
|
|
|
->setControlID('assign_to')
|
|
|
|
->setControlStyle('display: none')
|
|
|
|
->setID('assign-tokenizer')
|
|
|
|
->setDisableBehavior(true))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
->setLabel('CCs')
|
|
|
|
->setName('ccs')
|
|
|
|
->setControlID('ccs')
|
|
|
|
->setControlStyle('display: none')
|
|
|
|
->setID('cc-tokenizer')
|
|
|
|
->setDisableBehavior(true))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel('Priority')
|
|
|
|
->setName('priority')
|
|
|
|
->setOptions($priority_map)
|
|
|
|
->setControlID('priority')
|
|
|
|
->setControlStyle('display: none')
|
|
|
|
->setValue($task->getPriority()))
|
2011-02-21 05:08:16 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTokenizerControl())
|
|
|
|
->setLabel('Projects')
|
|
|
|
->setName('projects')
|
|
|
|
->setControlID('projects')
|
|
|
|
->setControlStyle('display: none')
|
|
|
|
->setID('projects-tokenizer')
|
|
|
|
->setDisableBehavior(true))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormFileControl())
|
|
|
|
->setLabel('File')
|
|
|
|
->setName('file')
|
|
|
|
->setControlID('file')
|
|
|
|
->setControlStyle('display: none'))
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
|
|
|
->setLabel('Comments')
|
|
|
|
->setName('comments')
|
2011-05-11 01:18:47 +02:00
|
|
|
->setValue($draft_text)
|
2011-05-10 17:29:28 +02:00
|
|
|
->setID('transaction-comments'))
|
2011-05-22 20:55:10 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormMarkupControl())
|
|
|
|
->setLabel('Attached Files')
|
|
|
|
->setValue(
|
|
|
|
'<div id="file-list">'.
|
|
|
|
'None'.
|
|
|
|
'</div>'))
|
2011-02-08 19:53:59 +01:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
|
|
|
->setValue('Avast!'));
|
|
|
|
|
2011-05-11 13:17:48 +02:00
|
|
|
$control_map = array(
|
|
|
|
ManiphestTransactionType::TYPE_STATUS => 'resolution',
|
|
|
|
ManiphestTransactionType::TYPE_OWNER => 'assign_to',
|
|
|
|
ManiphestTransactionType::TYPE_CCS => 'ccs',
|
|
|
|
ManiphestTransactionType::TYPE_PRIORITY => 'priority',
|
|
|
|
ManiphestTransactionType::TYPE_PROJECTS => 'projects',
|
|
|
|
ManiphestTransactionType::TYPE_ATTACH => 'file',
|
|
|
|
);
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
Javelin::initBehavior('maniphest-transaction-controls', array(
|
|
|
|
'select' => 'transaction-action',
|
2011-05-11 13:17:48 +02:00
|
|
|
'controlMap' => $control_map,
|
2011-02-08 19:53:59 +01:00
|
|
|
'tokenizers' => array(
|
2011-02-21 05:08:16 +01:00
|
|
|
ManiphestTransactionType::TYPE_PROJECTS => array(
|
|
|
|
'id' => 'projects-tokenizer',
|
|
|
|
'src' => '/typeahead/common/projects/',
|
|
|
|
),
|
2011-02-08 19:53:59 +01:00
|
|
|
ManiphestTransactionType::TYPE_OWNER => array(
|
|
|
|
'id' => 'assign-tokenizer',
|
|
|
|
'src' => '/typeahead/common/users/',
|
|
|
|
'value' => $default_claim,
|
|
|
|
'limit' => 1,
|
|
|
|
),
|
|
|
|
ManiphestTransactionType::TYPE_CCS => array(
|
|
|
|
'id' => 'cc-tokenizer',
|
|
|
|
'src' => '/typeahead/common/mailable/',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
2011-05-10 17:29:28 +02:00
|
|
|
|
|
|
|
Javelin::initBehavior('maniphest-transaction-preview', array(
|
|
|
|
'uri' => '/maniphest/transaction/preview/'.$task->getID().'/',
|
|
|
|
'preview' => 'transaction-preview',
|
|
|
|
'comments' => 'transaction-comments',
|
2011-05-11 13:17:48 +02:00
|
|
|
'action' => 'transaction-action',
|
|
|
|
'map' => $control_map,
|
2011-05-10 17:29:28 +02:00
|
|
|
));
|
|
|
|
|
2011-05-22 20:55:10 +02:00
|
|
|
$id = celerity_generate_unique_node_id();
|
2011-05-10 17:29:28 +02:00
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$comment_panel = new AphrontPanelView();
|
|
|
|
$comment_panel->appendChild($comment_form);
|
2011-05-22 20:55:10 +02:00
|
|
|
$comment_panel->setID($id);
|
Tweak Maniphest CSS, fix remarkup in description change views
Summary:
Various CSS tweaks and fixes:
- Add remarkup styling to description change views, missed this before.
- Fix CSS so that transactions with only one item (e.g., changed priority)
don't have weird floater underneath them.
- Add more space between transaction items.
- Make default background color lighter and less heavy.
- Use beigey color for comment form in Maniphest.
- Share more CSS between Maniphest and Differential (previews, feedback).
- Move "Leap Into Action" call to Differential, replace Maniphest with
thematically-consistent "Weigh In" (obviously, Maniphest has a nautical theme).
Test Plan:
Browsed Maniphest and Differential in a couple browsers, styling all seems
correct.
Reviewed By: tomo
Reviewers: tomo, aran, jungejason, tuomaspelkonen
CC: anjali, aran, tomo
Differential Revision: 328
2011-05-22 17:49:07 +02:00
|
|
|
$comment_panel->addClass('aphront-panel-accent');
|
2011-05-22 20:55:10 +02:00
|
|
|
$comment_panel->setHeader('Leap Into Action');
|
|
|
|
|
|
|
|
Javelin::initBehavior(
|
|
|
|
'maniphest-transaction-drag-and-drop',
|
|
|
|
array(
|
|
|
|
'target' => $id,
|
|
|
|
'activatedClass' => 'aphront-panel-view-drag-and-drop',
|
|
|
|
'uri' => '/file/dropupload/',
|
|
|
|
'list' => 'file-list',
|
|
|
|
));
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2011-05-10 17:29:28 +02:00
|
|
|
$preview_panel =
|
Tweak Maniphest CSS, fix remarkup in description change views
Summary:
Various CSS tweaks and fixes:
- Add remarkup styling to description change views, missed this before.
- Fix CSS so that transactions with only one item (e.g., changed priority)
don't have weird floater underneath them.
- Add more space between transaction items.
- Make default background color lighter and less heavy.
- Use beigey color for comment form in Maniphest.
- Share more CSS between Maniphest and Differential (previews, feedback).
- Move "Leap Into Action" call to Differential, replace Maniphest with
thematically-consistent "Weigh In" (obviously, Maniphest has a nautical theme).
Test Plan:
Browsed Maniphest and Differential in a couple browsers, styling all seems
correct.
Reviewed By: tomo
Reviewers: tomo, aran, jungejason, tuomaspelkonen
CC: anjali, aran, tomo
Differential Revision: 328
2011-05-22 17:49:07 +02:00
|
|
|
'<div class="aphront-panel-preview">
|
2011-05-10 17:29:28 +02:00
|
|
|
<div id="transaction-preview">
|
Tweak Maniphest CSS, fix remarkup in description change views
Summary:
Various CSS tweaks and fixes:
- Add remarkup styling to description change views, missed this before.
- Fix CSS so that transactions with only one item (e.g., changed priority)
don't have weird floater underneath them.
- Add more space between transaction items.
- Make default background color lighter and less heavy.
- Use beigey color for comment form in Maniphest.
- Share more CSS between Maniphest and Differential (previews, feedback).
- Move "Leap Into Action" call to Differential, replace Maniphest with
thematically-consistent "Weigh In" (obviously, Maniphest has a nautical theme).
Test Plan:
Browsed Maniphest and Differential in a couple browsers, styling all seems
correct.
Reviewed By: tomo
Reviewers: tomo, aran, jungejason, tuomaspelkonen
CC: anjali, aran, tomo
Differential Revision: 328
2011-05-22 17:49:07 +02:00
|
|
|
<div class="aphront-panel-preview-loading-text">
|
2011-05-10 17:29:28 +02:00
|
|
|
Loading preview...
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
$transaction_view = new ManiphestTransactionListView();
|
|
|
|
$transaction_view->setTransactions($transactions);
|
|
|
|
$transaction_view->setHandles($handles);
|
|
|
|
$transaction_view->setUser($user);
|
|
|
|
$transaction_view->setMarkupEngine($engine);
|
|
|
|
|
|
|
|
return $this->buildStandardPageResponse(
|
|
|
|
array(
|
|
|
|
$panel,
|
|
|
|
$transaction_view,
|
|
|
|
$comment_panel,
|
2011-05-10 17:29:28 +02:00
|
|
|
$preview_panel,
|
2011-02-08 19:53:59 +01:00
|
|
|
),
|
|
|
|
array(
|
2011-02-10 01:38:31 +01:00
|
|
|
'title' => 'T'.$task->getID().' '.$task->getTitle(),
|
2011-02-08 19:53:59 +01:00
|
|
|
));
|
|
|
|
}
|
2011-02-19 07:15:28 +01:00
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|