1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-21 08:40:08 +01:00

Don't show meme Remarkup hint button if Macro application is not usable

Summary: See <https://phabricator.wikimedia.org/T906>. This behavior is a bug; we should remove the button if the user can't use the application.

Test Plan:
- With Macro uninstalled, did these things verifying the button vanished:
  - Sent a user a message.
  - Edited a revision.
  - Edited repository basic information.
  - Edited an initiative.
  - Edited a Harbormaster build step.
  - Added task comments.
  - Edited profile blurb.
  - Edited blog description.
  - Commented on Pholio mock.
  - Uploaded Pholio image.
  - Edited Phortune merchant.
  - Edited Phriction document.
  - Edited Ponder answer.
  - Edited Ponder question.
  - Edited Slowvote poll.
  - Edited a comment.
- Reinstalled Macro and saw button come back.
- Used button to put silly text on a funny picture.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D10900
This commit is contained in:
epriestley 2014-11-24 15:25:25 -08:00
parent e5777cc849
commit 10b86c2aa3
20 changed files with 66 additions and 32 deletions

View file

@ -87,10 +87,11 @@ final class ConpherenceNewController extends ConpherenceController {
->setError($e_participants))
->appendChild(
id(new PhabricatorRemarkupControl())
->setName('message')
->setValue($message)
->setLabel(pht('Message'))
->setError($e_message));
->setUser($user)
->setName('message')
->setValue($message)
->setLabel(pht('Message'))
->setError($e_message));
$dialog->appendChild($form);

View file

@ -85,6 +85,7 @@ final class DifferentialRevertPlanField
public function renderEditControl(array $handles) {
return id(new PhabricatorRemarkupControl())
->setUser($this->getViewer())
->setName($this->getFieldKey())
->setValue($this->getValue())
->setLabel($this->getFieldName());

View file

@ -39,6 +39,7 @@ final class DifferentialSummaryField
public function renderEditControl(array $handles) {
return id(new PhabricatorRemarkupControl())
->setUser($this->getViewer())
->setName($this->getFieldKey())
->setValue($this->getValue())
->setError($this->getFieldError())

View file

@ -53,6 +53,7 @@ final class DifferentialTestPlanField
public function renderEditControl(array $handles) {
return id(new PhabricatorRemarkupControl())
->setUser($this->getViewer())
->setName($this->getFieldKey())
->setValue($this->getValue())
->setError($this->getFieldError())

View file

@ -120,6 +120,7 @@ final class DiffusionRepositoryEditBasicController
$form
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setName('description')
->setLabel(pht('Description'))
->setValue($v_desc))

View file

@ -200,11 +200,13 @@ final class FundInitiativeEditController
->setOptions($merchant_options))
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($viewer)
->setName('description')
->setLabel(pht('Description'))
->setValue($v_desc))
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($viewer)
->setName('risks')
->setLabel(pht('Risks/Challenges'))
->setValue($v_risk))

View file

@ -155,6 +155,7 @@ final class HarbormasterStepEditController extends HarbormasterController {
$form
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($viewer)
->setName('description')
->setLabel(pht('Description'))
->setError($e_description)

View file

@ -143,20 +143,22 @@ final class LegalpadDocumentEditController extends LegalpadController {
$form
->appendChild(
id(new PhabricatorRemarkupControl())
->setID('preamble')
->setLabel(pht('Preamble'))
->setValue($v_preamble)
->setName('preamble')
->setCaption(
pht('Optional help text for users signing this document.')))
->setUser($user)
->setID('preamble')
->setLabel(pht('Preamble'))
->setValue($v_preamble)
->setName('preamble')
->setCaption(
pht('Optional help text for users signing this document.')))
->appendChild(
id(new PhabricatorRemarkupControl())
->setID('document-text')
->setLabel(pht('Document Body'))
->setError($e_text)
->setValue($text)
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setName('text'));
->setUser($user)
->setID('document-text')
->setLabel(pht('Document Body'))
->setError($e_text)
->setValue($text)
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setName('text'));
$policies = id(new PhabricatorPolicyQuery())
->setViewer($user)

View file

@ -254,6 +254,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
->setControlStyle('display: none'))
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setLabel(pht('Comments'))
->setName('comments')
->setValue($draft_text)

View file

@ -52,6 +52,7 @@ final class PhabricatorUserBlurbField
public function renderEditControl(array $handles) {
return id(new PhabricatorRemarkupControl())
->setUser($this->getViewer())
->setName($this->getFieldKey())
->setValue($this->value)
->setLabel($this->getFieldName());

View file

@ -122,12 +122,13 @@ final class PhameBlogEditController
->setError($e_name))
->appendChild(
id(new PhabricatorRemarkupControl())
->setLabel(pht('Description'))
->setName('description')
->setValue($blog->getDescription())
->setID('blog-description')
->setUser($user)
->setDisableMacros(true))
->setUser($user)
->setLabel(pht('Description'))
->setName('description')
->setValue($blog->getDescription())
->setID('blog-description')
->setUser($user)
->setDisableMacros(true))
->appendChild(
id(new AphrontFormPolicyControl())
->setUser($user)

View file

@ -157,6 +157,7 @@ final class PholioInlineController extends PholioController {
$form
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($viewer)
->setName('content')
->setLabel(pht('Comment'))
->setValue($v_content));

View file

@ -32,6 +32,7 @@ final class PholioUploadedImageView extends AphrontView {
->setLabel(pht('Title'));
$description = id(new PhabricatorRemarkupControl())
->setUser($this->getUser())
->setName('description_'.$phid)
->setValue($image->getDescription())
->setSigil('image-description')

View file

@ -131,6 +131,7 @@ final class PhortuneMerchantEditController
->setError($e_name))
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($viewer)
->setName('desc')
->setLabel(pht('Description'))
->setValue($v_desc))

View file

@ -71,6 +71,7 @@ final class PonderAnswerEditController extends PonderController {
->setValue($question->getTitle()))
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($viewer)
->setLabel(pht('Answer'))
->setName('content')
->setID($answer_content_id)

View file

@ -98,6 +98,7 @@ final class PonderQuestionEditController extends PonderController {
->setError($e_title))
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setName('content')
->setID('content')
->setValue($v_content)

View file

@ -163,6 +163,7 @@ final class PhabricatorSlowvoteEditController
->setError($e_question))
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setLabel(pht('Description'))
->setName('description')
->setValue($v_description))

View file

@ -73,6 +73,7 @@ final class PhabricatorApplicationTransactionCommentEditController
->setFullWidth(true)
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setName('text')
->setValue($xaction->getComment()->getContent())));

View file

@ -9,6 +9,7 @@ final class PhabricatorStandardCustomFieldRemarkup
public function renderEditControl(array $handles) {
return id(new PhabricatorRemarkupControl())
->setUser($this->getViewer())
->setLabel($this->getFieldName())
->setName($this->getFieldKey())
->setCaption($this->getCaption())

View file

@ -22,6 +22,12 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
$this->setID($id);
}
$viewer = $this->getUser();
if (!$viewer) {
throw new Exception(
pht('Call setUser() before rendering a PhabricatorRemarkupControl!'));
}
// We need to have this if previews render images, since Ajax can not
// currently ship JS or CSS.
require_celerity_resource('lightbox-attachment-css');
@ -82,7 +88,17 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
),
);
if (!$this->disableMacro and function_exists('imagettftext')) {
$can_use_macros =
(!$this->disableMacro) &&
(function_exists('imagettftext'));
if ($can_use_macros) {
$can_use_macros = PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorMacroApplication',
$viewer);
}
if ($can_use_macros) {
$actions[] = array(
'spacer' => true,
);
@ -184,16 +200,13 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
$monospaced_textareas = null;
$monospaced_textareas_class = null;
$user = $this->getUser();
if ($user) {
$monospaced_textareas = $user
->loadPreferences()
->getPreference(
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS);
if ($monospaced_textareas == 'enabled') {
$monospaced_textareas_class = 'PhabricatorMonospaced';
}
$monospaced_textareas = $viewer
->loadPreferences()
->getPreference(
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS);
if ($monospaced_textareas == 'enabled') {
$monospaced_textareas_class = 'PhabricatorMonospaced';
}
$this->setCustomClass(