Commit 557cc5b2 authored by Bob Trahan's avatar Bob Trahan
Browse files

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

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
parent 670ddf21
......@@ -944,6 +944,7 @@ phutil_register_library_map(array(
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php',
'PhabricatorRefreshCSRFController' => 'applications/auth/controller/PhabricatorRefreshCSRFController.php',
'PhabricatorRemarkupControl' => 'view/form/control/PhabricatorRemarkupControl.php',
'PhabricatorRemarkupRuleCountdown' => 'infrastructure/markup/rule/PhabricatorRemarkupRuleCountdown.php',
'PhabricatorRemarkupRuleDifferential' => 'infrastructure/markup/rule/PhabricatorRemarkupRuleDifferential.php',
'PhabricatorRemarkupRuleDifferentialHandle' => 'infrastructure/markup/rule/handle/PhabricatorRemarkupRuleDifferentialHandle.php',
......@@ -2057,6 +2058,7 @@ phutil_register_library_map(array(
'PhabricatorPropertyListView' => 'AphrontView',
'PhabricatorRedirectController' => 'PhabricatorController',
'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController',
'PhabricatorRemarkupControl' => 'AphrontFormTextAreaControl',
'PhabricatorRemarkupRuleCountdown' => 'PhutilRemarkupRule',
'PhabricatorRemarkupRuleDifferential' => 'PhabricatorRemarkupRuleObjectName',
'PhabricatorRemarkupRuleDifferentialHandle' => 'PhabricatorRemarkupRuleObjectHandle',
......
......@@ -108,21 +108,12 @@ final class DifferentialAddCommentView extends AphrontView {
->setID('add-ccs-tokenizer')
->setDisableBehavior(true))
->appendChild(
id(new AphrontFormTextAreaControl())
id(new PhabricatorRemarkupControl())
->setName('comment')
->setID('comment-content')
->setLabel('Comment')
->setEnableDragAndDropFileUploads(true)
->setValue($this->draft)
->setCaption(phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference')))
->setValue($this->draft))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Clowncopterize'));
......
......@@ -565,20 +565,11 @@ final class DiffusionCommitController extends DiffusionController {
->setID('add-ccs-tokenizer')
->setDisableBehavior(true))
->appendChild(
id(new AphrontFormTextAreaControl())
id(new PhabricatorRemarkupControl())
->setLabel('Comments')
->setName('content')
->setValue($draft)
->setID('audit-content')
->setCaption(phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference')))
->setID('audit-content'))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Cook the Books'));
......
......@@ -374,9 +374,6 @@ final class ManiphestTaskDetailController extends ManiphestController {
unset($resolution_types[ManiphestTaskStatus::STATUS_CLOSED_SPITE]);
}
$remarkup_href = PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html');
$comment_form = new AphrontFormView();
$comment_form
->setUser($user)
......@@ -435,19 +432,10 @@ final class ManiphestTaskDetailController extends ManiphestController {
->setControlID('file')
->setControlStyle('display: none'))
->appendChild(
id(new AphrontFormTextAreaControl())
id(new PhabricatorRemarkupControl())
->setLabel('Comments')
->setName('comments')
->setValue($draft_text)
->setCaption(
phutil_render_tag(
'a',
array(
'href' => $remarkup_href,
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference'))
->setID('transaction-comments'))
->appendChild(
id(new AphrontFormDragAndDropUploadControl())
......
......@@ -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(
'metamta.maniphest.public-create-email');
$email_hint = null;
if (!$task->getID() && $email_create) {
$email_hint = 'You can also create tasks by sending an email to: '.
'<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
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Description')
->setName('description')
->setID('description-textarea')
->setCaption($email_hint)
->setValue($task->getDescription()));
->appendChild($description_control);
$panel_id = celerity_generate_unique_node_id();
if (!$task->getID()) {
$form
......
......@@ -181,16 +181,6 @@ final class PhameBlogEditController
$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())
->setUser($user)
->appendChild(
......@@ -202,13 +192,12 @@ final class PhameBlogEditController
->setError($e_name)
)
->appendChild(
id(new AphrontFormTextAreaControl())
id(new PhabricatorRemarkupControl())
->setLabel('Description')
->setName('description')
->setValue($blog->getDescription())
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setID('blog-description')
->setCaption($remarkup_reference)
)
->appendChild(
id(new AphrontFormTokenizerControl())
......
......@@ -232,16 +232,6 @@ final class PhamePostEditController
$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())
->setUser($user)
->appendChild(
......@@ -264,14 +254,13 @@ final class PhamePostEditController
->setError($e_phame_title)
)
->appendChild(
id(new AphrontFormTextAreaControl())
id(new PhabricatorRemarkupControl())
->setLabel('Body')
->setName('body')
->setValue($post->getBody())
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setEnableDragAndDropFileUploads(true)
->setID('post-body')
->setCaption($remarkup_reference)
)
->appendChild(
id(new AphrontFormSelectControl())
......
......@@ -177,15 +177,6 @@ final class PhrictionEditController
$uri = PhrictionDocument::getSlugURI($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());
if ($draft &&
......@@ -227,14 +218,13 @@ final class PhrictionEditController
->setLabel('URI')
->setValue($uri))
->appendChild(
id(new AphrontFormTextAreaControl())
id(new PhabricatorRemarkupControl())
->setLabel('Content')
->setValue($content_text)
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setName('content')
->setID('document-textarea')
->setEnableDragAndDropFileUploads(true)
->setCaption($remarkup_reference))
->setEnableDragAndDropFileUploads(true))
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Edit Notes')
......
......@@ -100,20 +100,11 @@ final class PonderQuestionAskController extends PonderController {
->setName('title')
->setValue($title))
->appendChild(
id(new AphrontFormTextAreaControl())
id(new PhabricatorRemarkupControl())
->setName('content')
->setID('content')
->setValue($content)
->setLabel("Question")
->setCaption(phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
"Formatting Reference")))
->setLabel("Question"))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Ask Away!'));
......
......@@ -56,19 +56,10 @@ final class PonderAddAnswerView extends AphrontView {
->setWorkflow(true)
->addHiddenInput('question_id', $question->getID())
->appendChild(
id(new AphrontFormTextAreaControl())
id(new PhabricatorRemarkupControl())
->setName('answer')
->setID('answer-content')
->setEnableDragAndDropFileUploads(true)
->setCaption(phutil_render_tag(
'a',
array(
'href' => PhabricatorEnv::getDoclink(
'article/Remarkup_Reference.html'),
'tabindex' => '-1',
'target' => '_blank',
),
'Formatting Reference')))
->setEnableDragAndDropFileUploads(true))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($is_serious ? 'Submit' : 'Make it so.'));
......
......@@ -16,7 +16,10 @@
* limitations under the License.
*/
final class AphrontFormTextAreaControl extends AphrontFormControl {
/**
* @concrete-extensible
*/
class AphrontFormTextAreaControl extends AphrontFormControl {
const HEIGHT_VERY_SHORT = 'very-short';
const HEIGHT_SHORT = 'short';
......
<?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;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment