Skip to content

Commit 416d26b

Browse files
Ricky Elrodepriestley
Ricky Elrod
authored and
epriestley
committed
Allow users to set whether or not textareas are monospaced.
Summary: Some users like monospaced textareas and others don't. This introduces an option to set this as a user preference. Test Plan: Enabled and saw monospaced textareas, disabled and saw non-monospaced textareas. Reviewers: epriestley CC: aran, Korvin Maniphest Tasks: T2114 Differential Revision: https://secure.phabricator.com/D4037
1 parent 71c1706 commit 416d26b

14 files changed

+80
-24
lines changed

src/applications/differential/view/DifferentialAddCommentView.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ public function render() {
118118
->setName('comment')
119119
->setID('comment-content')
120120
->setLabel('Comment')
121-
->setValue($this->draft ? $this->draft->getDraft() : null))
121+
->setValue($this->draft ? $this->draft->getDraft() : null)
122+
->setUser($this->user))
122123
->appendChild(
123124
id(new AphrontFormSubmitControl())
124125
->setValue($is_serious ? 'Submit' : 'Clowncopterize'));

src/applications/diffusion/controller/DiffusionCommitController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,8 @@ private function renderAddCommentPanel(
575575
->setLabel('Comments')
576576
->setName('content')
577577
->setValue($draft)
578-
->setID('audit-content'))
578+
->setID('audit-content')
579+
->setUser($user))
579580
->appendChild(
580581
id(new AphrontFormSubmitControl())
581582
->setValue($is_serious ? 'Submit' : 'Cook the Books'));

src/applications/maniphest/controller/ManiphestTaskDetailController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,8 @@ public function processRequest() {
415415
->setLabel('Comments')
416416
->setName('comments')
417417
->setValue($draft_text)
418-
->setID('transaction-comments'))
418+
->setID('transaction-comments')
419+
->setUser($user))
419420
->appendChild(
420421
id(new AphrontFormDragAndDropUploadControl())
421422
->setLabel('Attached Files')

src/applications/maniphest/controller/ManiphestTaskEditController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ public function processRequest() {
487487
->setLabel('Description')
488488
->setName('description')
489489
->setID('description-textarea')
490-
->setValue($task->getDescription());
490+
->setValue($task->getDescription())
491+
->setUser($user);
491492

492493
$form
493494
->appendChild($description_control);

src/applications/phame/controller/blog/PhameBlogEditController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function processRequest() {
122122
->setName('description')
123123
->setValue($blog->getDescription())
124124
->setID('blog-description')
125-
)
125+
->setUser($user))
126126
->appendChild(
127127
id(new AphrontFormPolicyControl())
128128
->setUser($user)

src/applications/phame/controller/post/PhamePostEditController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public function processRequest() {
132132
->setValue($post->getBody())
133133
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
134134
->setID('post-body')
135+
->setUser($user)
135136
)
136137
->appendChild(
137138
id(new AphrontFormSelectControl())

src/applications/pholio/controller/PholioMockEditController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ public function processRequest() {
193193
id(new PhabricatorRemarkupControl())
194194
->setName('description')
195195
->setValue($v_desc)
196-
->setLabel(pht('Description')))
196+
->setLabel(pht('Description'))
197+
->setUser($user))
197198
->appendChild(
198199
id(new AphrontFormDragAndDropUploadControl($request))
199200
->setName('file_phids')

src/applications/pholio/controller/PholioMockViewController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ private function buildAddCommentView(PholioMock $mock) {
194194
->appendChild(
195195
id(new PhabricatorRemarkupControl())
196196
->setName('comment')
197-
->setLabel(pht('Comment')))
197+
->setLabel(pht('Comment'))
198+
->setUser($user))
198199
->appendChild(
199200
id(new AphrontFormSubmitControl())
200201
->setValue($action));

src/applications/phriction/controller/PhrictionEditController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ public function processRequest() {
222222
->setValue($content_text)
223223
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
224224
->setName('content')
225-
->setID('document-textarea'))
225+
->setID('document-textarea')
226+
->setUser($user))
226227
->appendChild(
227228
id(new AphrontFormTextControl())
228229
->setLabel('Edit Notes')

src/applications/ponder/controller/PonderQuestionAskController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public function processRequest() {
6868
->setName('content')
6969
->setID('content')
7070
->setValue($question->getContent())
71-
->setLabel(pht('Description')))
71+
->setLabel(pht('Description'))
72+
->setUser($user))
7273
->appendChild(
7374
id(new AphrontFormSubmitControl())
7475
->setValue('Ask Away!'));

src/applications/ponder/view/PonderAddAnswerView.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public function render() {
4444
->setName('answer')
4545
->setLabel('Answer')
4646
->setError(true)
47-
->setID('answer-content'))
47+
->setID('answer-content')
48+
->setUser($this->user))
4849
->appendChild(
4950
id(new AphrontFormSubmitControl())
5051
->setValue($is_serious ? 'Submit' : 'Make it so.'));

src/applications/settings/panel/PhabricatorSettingsPanelDisplayPreferences.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public function processRequest(AphrontRequest $request) {
2323
$pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR;
2424
$pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES;
2525
$pref_symbols = PhabricatorUserPreferences::PREFERENCE_DIFFUSION_SYMBOLS;
26+
$pref_monospaced_textareas =
27+
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS;
2628

2729
if ($request->isFormPost()) {
2830
$monospaced = $request->getStr($pref_monospaced);
@@ -32,9 +34,13 @@ public function processRequest(AphrontRequest $request) {
3234

3335
$preferences->setPreference($pref_titles, $request->getStr($pref_titles));
3436
$preferences->setPreference($pref_editor, $request->getStr($pref_editor));
35-
$preferences->setPreference($pref_symbols,
37+
$preferences->setPreference(
38+
$pref_symbols,
3639
$request->getStr($pref_symbols));
3740
$preferences->setPreference($pref_monospaced, $monospaced);
41+
$preferences->setPreference(
42+
$pref_monospaced_textareas,
43+
$request->getStr($pref_monospaced_textareas));
3844

3945
$preferences->save();
4046
return id(new AphrontRedirectResponse())
@@ -60,6 +66,11 @@ function helloWorld() {
6066
$font_default = phutil_escape_html($font_default);
6167

6268
$pref_symbols_value = $preferences->getPreference($pref_symbols);
69+
$pref_monospaced_textareas_value = $preferences
70+
->getPreference($pref_monospaced_textareas);
71+
if (!$pref_monospaced_textareas_value) {
72+
$pref_monospaced_textareas_value = 'disabled';
73+
}
6374

6475
$form = id(new AphrontFormView())
6576
->setUser($user)
@@ -108,6 +119,14 @@ function helloWorld() {
108119
'Use this setting to disable linking symbol names in Differential '.
109120
'and Diffusion to their definitions. This is enabled by default.')
110121
->addButton('disabled', 'Disabled', null))
122+
->appendChild(
123+
id(new AphrontFormRadioButtonControl())
124+
->setLabel('Monospaced Textareas')
125+
->setName($pref_monospaced_textareas)
126+
->setValue($pref_monospaced_textareas_value)
127+
->addButton('enabled', 'Enabled',
128+
'Show all textareas using the monospaced font defined above.')
129+
->addButton('disabled', 'Disabled', null))
111130
->appendChild(
112131
id(new AphrontFormSubmitControl())
113132
->setValue('Save Preferences'));

src/applications/settings/storage/PhabricatorUserPreferences.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22

33
final class PhabricatorUserPreferences extends PhabricatorUserDAO {
44

5-
const PREFERENCE_MONOSPACED = 'monospaced';
6-
const PREFERENCE_EDITOR = 'editor';
7-
const PREFERENCE_TITLES = 'titles';
5+
const PREFERENCE_MONOSPACED = 'monospaced';
6+
const PREFERENCE_EDITOR = 'editor';
7+
const PREFERENCE_TITLES = 'titles';
8+
const PREFERENCE_MONOSPACED_TEXTAREAS = 'monospaced-textareas';
89

9-
const PREFERENCE_RE_PREFIX = 're-prefix';
10-
const PREFERENCE_NO_SELF_MAIL = 'self-mail';
11-
const PREFERENCE_MAILTAGS = 'mailtags';
12-
const PREFERENCE_VARY_SUBJECT = 'vary-subject';
10+
const PREFERENCE_RE_PREFIX = 're-prefix';
11+
const PREFERENCE_NO_SELF_MAIL = 'self-mail';
12+
const PREFERENCE_MAILTAGS = 'mailtags';
13+
const PREFERENCE_VARY_SUBJECT = 'vary-subject';
1314

14-
const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump';
15-
const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut';
15+
const PREFERENCE_SEARCHBAR_JUMP = 'searchbar-jump';
16+
const PREFERENCE_SEARCH_SHORTCUT = 'search-shortcut';
1617

17-
const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view';
18-
const PREFERENCE_DIFFUSION_SYMBOLS = 'diffusion-symbols';
18+
const PREFERENCE_DIFFUSION_VIEW = 'diffusion-view';
19+
const PREFERENCE_DIFFUSION_SYMBOLS = 'diffusion-symbols';
1920

20-
const PREFERENCE_NAV_WIDTH = 'nav-width';
21+
const PREFERENCE_NAV_WIDTH = 'nav-width';
2122

2223
protected $userPHID;
2324
protected $preferences = array();

src/view/form/control/PhabricatorRemarkupControl.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl {
44

5+
private $user;
6+
7+
public function setUser(PhabricatorUser $user) {
8+
$this->user = $user;
9+
return $this;
10+
}
11+
12+
public function getUser() {
13+
return $this->user;
14+
}
15+
516
protected function renderInput() {
617
$id = $this->getID();
718
if (!$id) {
@@ -119,7 +130,22 @@ protected function renderInput() {
119130
),
120131
implode('', $buttons));
121132

122-
$this->setCustomClass('remarkup-assist-textarea');
133+
$monospaced_textareas = null;
134+
$monospaced_textareas_class = null;
135+
$user = $this->getUser();
136+
137+
if ($user) {
138+
$monospaced_textareas = $user
139+
->loadPreferences()
140+
->getPreference(
141+
PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS);
142+
if ($monospaced_textareas == 'enabled') {
143+
$monospaced_textareas_class = 'PhabricatorMonospaced';
144+
}
145+
}
146+
147+
$this->setCustomClass(
148+
'remarkup-assist-textarea '.$monospaced_textareas_class);
123149

124150
return javelin_render_tag(
125151
'div',

0 commit comments

Comments
 (0)