mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
Clean up initialization of Differential Show More Behavior in Maniphest
Summary: add a static variable to the method and use it so we don't init more than once! Test Plan: add a "phlog" and noted only init'd one time. verified "show more" links worked correctly. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Maniphest Tasks: T666 Differential Revision: https://secure.phabricator.com/D1553
This commit is contained in:
parent
2ff36b7cad
commit
e15b3fc6f3
8 changed files with 68 additions and 25 deletions
|
@ -395,6 +395,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestTask' => 'applications/maniphest/storage/task',
|
||||
'ManiphestTaskAuxiliaryStorage' => 'applications/maniphest/storage/auxiliary',
|
||||
'ManiphestTaskDescriptionChangeController' => 'applications/maniphest/controller/descriptionchange',
|
||||
'ManiphestTaskDescriptionDiffController' => 'applications/maniphest/controller/descriptiondiff',
|
||||
'ManiphestTaskDescriptionPreviewController' => 'applications/maniphest/controller/descriptionpreview',
|
||||
'ManiphestTaskDetailController' => 'applications/maniphest/controller/taskdetail',
|
||||
'ManiphestTaskEditController' => 'applications/maniphest/controller/taskedit',
|
||||
|
@ -1131,6 +1132,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestTask' => 'ManiphestDAO',
|
||||
'ManiphestTaskAuxiliaryStorage' => 'ManiphestDAO',
|
||||
'ManiphestTaskDescriptionChangeController' => 'ManiphestController',
|
||||
'ManiphestTaskDescriptionDiffController' => 'ManiphestTaskDescriptionChangeController',
|
||||
'ManiphestTaskDescriptionPreviewController' => 'ManiphestController',
|
||||
'ManiphestTaskDetailController' => 'ManiphestController',
|
||||
'ManiphestTaskEditController' => 'ManiphestController',
|
||||
|
|
|
@ -167,6 +167,8 @@ class AphrontDefaultApplicationConfiguration
|
|||
'edit/(?P<id>\d+)/$' => 'ManiphestTaskEditController',
|
||||
'descriptionchange/(?P<id>\d+)/$' =>
|
||||
'ManiphestTaskDescriptionChangeController',
|
||||
'descriptiondiff/$' =>
|
||||
'ManiphestTaskDescriptionDiffController',
|
||||
'descriptionpreview/$' =>
|
||||
'ManiphestTaskDescriptionPreviewController',
|
||||
),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,7 +23,7 @@ class ManiphestTaskDescriptionChangeController extends ManiphestController {
|
|||
|
||||
private $transactionID;
|
||||
|
||||
private function setTransactionID($transaction_id) {
|
||||
protected function setTransactionID($transaction_id) {
|
||||
$this->transactionID = $transaction_id;
|
||||
return $this;
|
||||
}
|
||||
|
@ -37,17 +37,9 @@ class ManiphestTaskDescriptionChangeController extends ManiphestController {
|
|||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
// this means we're using "show more" on a diff of a description and
|
||||
// should thus use the rendering reference to identify the transaction
|
||||
$ref = $request->getStr('ref');
|
||||
if ($ref) {
|
||||
$this->setTransactionID($ref);
|
||||
}
|
||||
|
||||
$transaction_id = $this->getTransactionID();
|
||||
$transaction = id(new ManiphestTransaction())->load($transaction_id);
|
||||
if (!$transaction) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2012 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group maniphest
|
||||
*/
|
||||
final class ManiphestTaskDescriptionDiffController
|
||||
extends ManiphestTaskDescriptionChangeController {
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$ref = $this->getRequest()->getStr('ref');
|
||||
$this->setTransactionID($ref);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/maniphest/controller/descriptionchange');
|
||||
|
||||
|
||||
phutil_require_source('ManiphestTaskDescriptionDiffController.php');
|
|
@ -563,6 +563,7 @@ class ManiphestTransactionDetailView extends ManiphestView {
|
|||
switch ($transaction->getTransactionType()) {
|
||||
case ManiphestTransactionType::TYPE_DESCRIPTION:
|
||||
$id = $transaction->getID();
|
||||
|
||||
$old_text = wordwrap($transaction->getOldValue(), 80);
|
||||
$new_text = wordwrap($transaction->getNewValue(), 80);
|
||||
|
||||
|
@ -593,20 +594,6 @@ class ManiphestTransactionDetailView extends ManiphestView {
|
|||
|
||||
Javelin::initBehavior('maniphest-transaction-expand');
|
||||
|
||||
switch ($transaction->getTransactionType()) {
|
||||
case ManiphestTransactionType::TYPE_DESCRIPTION:
|
||||
require_celerity_resource('differential-changeset-view-css');
|
||||
require_celerity_resource('syntax-highlighting-css');
|
||||
$whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
|
||||
Javelin::initBehavior('differential-show-more', array(
|
||||
'uri' => '/maniphest/task/descriptionchange/'.$id.'/',
|
||||
'whitespace' => $whitespace_mode,
|
||||
));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return javelin_render_tag(
|
||||
'a',
|
||||
array(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
* Copyright 2012 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -60,7 +60,12 @@ class ManiphestTransactionListView extends ManiphestView {
|
|||
$last = null;
|
||||
$group = array();
|
||||
$groups = array();
|
||||
$has_description_transaction = false;
|
||||
foreach ($this->transactions as $transaction) {
|
||||
if ($transaction->getTransactionType() ==
|
||||
ManiphestTransactionType::TYPE_DESCRIPTION) {
|
||||
$has_description_transaction = true;
|
||||
}
|
||||
if ($last === null) {
|
||||
$last = $transaction;
|
||||
$group[] = $transaction;
|
||||
|
@ -80,6 +85,16 @@ class ManiphestTransactionListView extends ManiphestView {
|
|||
$groups[] = $group;
|
||||
}
|
||||
|
||||
if ($has_description_transaction) {
|
||||
require_celerity_resource('differential-changeset-view-css');
|
||||
require_celerity_resource('syntax-highlighting-css');
|
||||
$whitespace_mode = DifferentialChangesetParser::WHITESPACE_SHOW_ALL;
|
||||
Javelin::initBehavior('differential-show-more', array(
|
||||
'uri' => '/maniphest/task/descriptiondiff/',
|
||||
'whitespace' => $whitespace_mode,
|
||||
));
|
||||
}
|
||||
|
||||
$sequence = 1;
|
||||
foreach ($groups as $group) {
|
||||
$view = new ManiphestTransactionDetailView();
|
||||
|
|
|
@ -6,8 +6,12 @@
|
|||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/differential/parser/changeset');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/view/base');
|
||||
phutil_require_module('phabricator', 'applications/maniphest/view/transactiondetail');
|
||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||
phutil_require_module('phabricator', 'infrastructure/javelin/api');
|
||||
|
||||
|
||||
phutil_require_source('ManiphestTransactionListView.php');
|
||||
|
|
Loading…
Reference in a new issue