1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-10 23:01:04 +01:00

Make a PhabricatorRemarkupControl to de-duplicate code usage around adding a Remarkup reference to a TextAreaControl.

Summary: ...also makes Maniphest Task Edit Controller use this when its not appropriate to upsell email.

Test Plan: played around with each tool and verified the Remarkup reference was present

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T1756

Differential Revision: https://secure.phabricator.com/D3468
This commit is contained in:
Bob Trahan 2012-09-19 12:27:28 -07:00
parent 670ddf2178
commit 557cc5b29c
12 changed files with 74 additions and 103 deletions

View file

@ -944,6 +944,7 @@ phutil_register_library_map(array(
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php', 'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php', 'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php',
'PhabricatorRefreshCSRFController' => 'applications/auth/controller/PhabricatorRefreshCSRFController.php', 'PhabricatorRefreshCSRFController' => 'applications/auth/controller/PhabricatorRefreshCSRFController.php',
'PhabricatorRemarkupControl' => 'view/form/control/PhabricatorRemarkupControl.php',
'PhabricatorRemarkupRuleCountdown' => 'infrastructure/markup/rule/PhabricatorRemarkupRuleCountdown.php', 'PhabricatorRemarkupRuleCountdown' => 'infrastructure/markup/rule/PhabricatorRemarkupRuleCountdown.php',
'PhabricatorRemarkupRuleDifferential' => 'infrastructure/markup/rule/PhabricatorRemarkupRuleDifferential.php', 'PhabricatorRemarkupRuleDifferential' => 'infrastructure/markup/rule/PhabricatorRemarkupRuleDifferential.php',
'PhabricatorRemarkupRuleDifferentialHandle' => 'infrastructure/markup/rule/handle/PhabricatorRemarkupRuleDifferentialHandle.php', 'PhabricatorRemarkupRuleDifferentialHandle' => 'infrastructure/markup/rule/handle/PhabricatorRemarkupRuleDifferentialHandle.php',
@ -2057,6 +2058,7 @@ phutil_register_library_map(array(
'PhabricatorPropertyListView' => 'AphrontView', 'PhabricatorPropertyListView' => 'AphrontView',
'PhabricatorRedirectController' => 'PhabricatorController', 'PhabricatorRedirectController' => 'PhabricatorController',
'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController', 'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController',
'PhabricatorRemarkupControl' => 'AphrontFormTextAreaControl',
'PhabricatorRemarkupRuleCountdown' => 'PhutilRemarkupRule', 'PhabricatorRemarkupRuleCountdown' => 'PhutilRemarkupRule',
'PhabricatorRemarkupRuleDifferential' => 'PhabricatorRemarkupRuleObjectName', 'PhabricatorRemarkupRuleDifferential' => 'PhabricatorRemarkupRuleObjectName',
'PhabricatorRemarkupRuleDifferentialHandle' => 'PhabricatorRemarkupRuleObjectHandle', 'PhabricatorRemarkupRuleDifferentialHandle' => 'PhabricatorRemarkupRuleObjectHandle',

View file

@ -108,21 +108,12 @@ final class DifferentialAddCommentView extends AphrontView {
->setID('add-ccs-tokenizer') ->setID('add-ccs-tokenizer')
->setDisableBehavior(true)) ->setDisableBehavior(true))
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new PhabricatorRemarkupControl())
->setName('comment') ->setName('comment')
->setID('comment-content') ->setID('comment-content')
->setLabel('Comment') ->setLabel('Comment')
->setEnableDragAndDropFileUploads(true) ->setEnableDragAndDropFileUploads(true)
->setValue($this->draft) ->setValue($this->draft))
->setCaption(phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference')))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Clowncopterize')); ->setValue($is_serious ? 'Submit' : 'Clowncopterize'));

View file

@ -565,20 +565,11 @@ final class DiffusionCommitController extends DiffusionController {
->setID('add-ccs-tokenizer') ->setID('add-ccs-tokenizer')
->setDisableBehavior(true)) ->setDisableBehavior(true))
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new PhabricatorRemarkupControl())
->setLabel('Comments') ->setLabel('Comments')
->setName('content') ->setName('content')
->setValue($draft) ->setValue($draft)
->setID('audit-content') ->setID('audit-content'))
->setCaption(phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference')))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Cook the Books')); ->setValue($is_serious ? 'Submit' : 'Cook the Books'));

View file

@ -374,9 +374,6 @@ final class ManiphestTaskDetailController extends ManiphestController {
unset($resolution_types[ManiphestTaskStatus::STATUS_CLOSED_SPITE]); unset($resolution_types[ManiphestTaskStatus::STATUS_CLOSED_SPITE]);
} }
$remarkup_href = PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html');
$comment_form = new AphrontFormView(); $comment_form = new AphrontFormView();
$comment_form $comment_form
->setUser($user) ->setUser($user)
@ -435,19 +432,10 @@ final class ManiphestTaskDetailController extends ManiphestController {
->setControlID('file') ->setControlID('file')
->setControlStyle('display: none')) ->setControlStyle('display: none'))
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new PhabricatorRemarkupControl())
->setLabel('Comments') ->setLabel('Comments')
->setName('comments') ->setName('comments')
->setValue($draft_text) ->setValue($draft_text)
->setCaption(
phutil_render_tag(
'a',
array(
'href' => $remarkup_href,
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference'))
->setID('transaction-comments')) ->setID('transaction-comments'))
->appendChild( ->appendChild(
id(new AphrontFormDragAndDropUploadControl()) id(new AphrontFormDragAndDropUploadControl())

View file

@ -486,24 +486,28 @@ final class ManiphestTaskEditController extends ManiphestController {
} }
} }
$description_control = new PhabricatorRemarkupControl();
// "Upsell" creating tasks via email in create flows if the instance is
// configured for this awesomeness.
$email_create = PhabricatorEnv::getEnvConfig( $email_create = PhabricatorEnv::getEnvConfig(
'metamta.maniphest.public-create-email'); 'metamta.maniphest.public-create-email');
$email_hint = null;
if (!$task->getID() && $email_create) { if (!$task->getID() && $email_create) {
$email_hint = 'You can also create tasks by sending an email to: '. $email_hint = 'You can also create tasks by sending an email to: '.
'<tt>'.phutil_escape_html($email_create).'</tt>'; '<tt>'.phutil_escape_html($email_create).'</tt>';
$description_control->setCaption($email_hint);
} }
$panel_id = celerity_generate_unique_node_id(); $description_control
->setLabel('Description')
->setName('description')
->setID('description-textarea')
->setValue($task->getDescription());
$form $form
->appendChild( ->appendChild($description_control);
id(new AphrontFormTextAreaControl())
->setLabel('Description') $panel_id = celerity_generate_unique_node_id();
->setName('description')
->setID('description-textarea')
->setCaption($email_hint)
->setValue($task->getDescription()));
if (!$task->getID()) { if (!$task->getID()) {
$form $form

View file

@ -181,16 +181,6 @@ final class PhameBlogEditController
$panel->addButton($delete_button); $panel->addButton($delete_button);
} }
$remarkup_reference = phutil_render_tag(
'a',
array(
'href' =>
PhabricatorEnv::getDoclink('article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference');
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($user)
->appendChild( ->appendChild(
@ -202,13 +192,12 @@ final class PhameBlogEditController
->setError($e_name) ->setError($e_name)
) )
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new PhabricatorRemarkupControl())
->setLabel('Description') ->setLabel('Description')
->setName('description') ->setName('description')
->setValue($blog->getDescription()) ->setValue($blog->getDescription())
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setID('blog-description') ->setID('blog-description')
->setCaption($remarkup_reference)
) )
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())

View file

@ -232,16 +232,6 @@ final class PhamePostEditController
$panel->addButton($delete_button); $panel->addButton($delete_button);
} }
$remarkup_reference = phutil_render_tag(
'a',
array(
'href' =>
PhabricatorEnv::getDoclink('article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference');
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($user) ->setUser($user)
->appendChild( ->appendChild(
@ -264,14 +254,13 @@ final class PhamePostEditController
->setError($e_phame_title) ->setError($e_phame_title)
) )
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new PhabricatorRemarkupControl())
->setLabel('Body') ->setLabel('Body')
->setName('body') ->setName('body')
->setValue($post->getBody()) ->setValue($post->getBody())
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setEnableDragAndDropFileUploads(true) ->setEnableDragAndDropFileUploads(true)
->setID('post-body') ->setID('post-body')
->setCaption($remarkup_reference)
) )
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())

View file

@ -177,15 +177,6 @@ final class PhrictionEditController
$uri = PhrictionDocument::getSlugURI($uri); $uri = PhrictionDocument::getSlugURI($uri);
$uri = PhabricatorEnv::getProductionURI($uri); $uri = PhabricatorEnv::getProductionURI($uri);
$remarkup_reference = phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink('article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference');
$cancel_uri = PhrictionDocument::getSlugURI($document->getSlug()); $cancel_uri = PhrictionDocument::getSlugURI($document->getSlug());
if ($draft && if ($draft &&
@ -227,14 +218,13 @@ final class PhrictionEditController
->setLabel('URI') ->setLabel('URI')
->setValue($uri)) ->setValue($uri))
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new PhabricatorRemarkupControl())
->setLabel('Content') ->setLabel('Content')
->setValue($content_text) ->setValue($content_text)
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setName('content') ->setName('content')
->setID('document-textarea') ->setID('document-textarea')
->setEnableDragAndDropFileUploads(true) ->setEnableDragAndDropFileUploads(true))
->setCaption($remarkup_reference))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Edit Notes') ->setLabel('Edit Notes')

View file

@ -100,20 +100,11 @@ final class PonderQuestionAskController extends PonderController {
->setName('title') ->setName('title')
->setValue($title)) ->setValue($title))
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new PhabricatorRemarkupControl())
->setName('content') ->setName('content')
->setID('content') ->setID('content')
->setValue($content) ->setValue($content)
->setLabel("Question") ->setLabel("Question"))
->setCaption(phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
"Formatting Reference")))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Ask Away!')); ->setValue('Ask Away!'));

View file

@ -56,19 +56,10 @@ final class PonderAddAnswerView extends AphrontView {
->setWorkflow(true) ->setWorkflow(true)
->addHiddenInput('question_id', $question->getID()) ->addHiddenInput('question_id', $question->getID())
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new PhabricatorRemarkupControl())
->setName('answer') ->setName('answer')
->setID('answer-content') ->setID('answer-content')
->setEnableDragAndDropFileUploads(true) ->setEnableDragAndDropFileUploads(true))
->setCaption(phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference')))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Make it so.')); ->setValue($is_serious ? 'Submit' : 'Make it so.'));

View file

@ -16,7 +16,10 @@
* limitations under the License. * limitations under the License.
*/ */
final class AphrontFormTextAreaControl extends AphrontFormControl { /**
* @concrete-extensible
*/
class AphrontFormTextAreaControl extends AphrontFormControl {
const HEIGHT_VERY_SHORT = 'very-short'; const HEIGHT_VERY_SHORT = 'very-short';
const HEIGHT_SHORT = 'short'; const HEIGHT_SHORT = 'short';

View file

@ -0,0 +1,42 @@
<?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.
*/
final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
public function getCaption() {
$caption = parent::getCaption();
if ($caption) {
$caption_suffix = '<br />'.$caption;
} else {
$caption_suffix = '';
}
return phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference') .
$caption_suffix;
}
}