Skip to content

Commit 684ce70

Browse files
author
Chad Little
committed
Add a description/toggle to PHUIObjectItemView
Summary: Gives the ability to hide a big long block of text in an ObjectListItem without cluttering the UI. Test Plan: Added a test case to UIExamples. Click on icon, see content. Click again, content go away. {F4974153} {F4974311} Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D18006
1 parent 1b36252 commit 684ce70

File tree

6 files changed

+82
-6
lines changed

6 files changed

+82
-6
lines changed

resources/celerity/map.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'names' => array(
1010
'conpherence.pkg.css' => 'ff161f2d',
1111
'conpherence.pkg.js' => 'b5b51108',
12-
'core.pkg.css' => '5387f8b6',
12+
'core.pkg.css' => '71865bdf',
1313
'core.pkg.js' => '599698a7',
1414
'darkconsole.pkg.js' => '1f9a31bc',
1515
'differential.pkg.css' => '7d4cfa59',
@@ -71,7 +71,7 @@
7171
'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
7272
'rsrc/css/application/differential/revision-list.css' => 'f3c47d33',
7373
'rsrc/css/application/differential/table-of-contents.css' => 'ae4b7a55',
74-
'rsrc/css/application/diffusion/diffusion-history.css' => 'b4ac65b3',
74+
'rsrc/css/application/diffusion/diffusion-history.css' => '0c596546',
7575
'rsrc/css/application/diffusion/diffusion-icons.css' => 'a6a1e2ba',
7676
'rsrc/css/application/diffusion/diffusion-readme.css' => '18bd3910',
7777
'rsrc/css/application/diffusion/diffusion-source.css' => '750add59',
@@ -132,7 +132,7 @@
132132
'rsrc/css/phui/object-item/phui-oi-color.css' => 'cd2b9b77',
133133
'rsrc/css/phui/object-item/phui-oi-drag-ui.css' => '08f4ccc3',
134134
'rsrc/css/phui/object-item/phui-oi-flush-ui.css' => '9d9685d6',
135-
'rsrc/css/phui/object-item/phui-oi-list-view.css' => '412bef1a',
135+
'rsrc/css/phui/object-item/phui-oi-list-view.css' => '78fdc98e',
136136
'rsrc/css/phui/object-item/phui-oi-simple-ui.css' => 'a8beebea',
137137
'rsrc/css/phui/phui-action-list.css' => 'c01858f4',
138138
'rsrc/css/phui/phui-action-panel.css' => '91c7b835',
@@ -575,7 +575,7 @@
575575
'differential-revision-history-css' => '0e8eb855',
576576
'differential-revision-list-css' => 'f3c47d33',
577577
'differential-table-of-contents-css' => 'ae4b7a55',
578-
'diffusion-history-css' => 'b4ac65b3',
578+
'diffusion-history-css' => '0c596546',
579579
'diffusion-icons-css' => 'a6a1e2ba',
580580
'diffusion-readme-css' => '18bd3910',
581581
'diffusion-source-css' => '750add59',
@@ -875,7 +875,7 @@
875875
'phui-oi-color-css' => 'cd2b9b77',
876876
'phui-oi-drag-ui-css' => '08f4ccc3',
877877
'phui-oi-flush-ui-css' => '9d9685d6',
878-
'phui-oi-list-view-css' => '412bef1a',
878+
'phui-oi-list-view-css' => '78fdc98e',
879879
'phui-oi-simple-ui-css' => 'a8beebea',
880880
'phui-pager-css' => '77d8a794',
881881
'phui-pinboard-view-css' => '2495140e',

src/applications/diffusion/view/DiffusionHistoryListView.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ public function buildList() {
102102
$commit_desc = $this->getCommitDescription($commit_phid);
103103
$committed = phabricator_datetime($commit->getEpoch(), $viewer);
104104

105+
$engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
106+
$engine->setConfig('viewer', $viewer);
107+
$commit_data = $commit->getCommitData();
108+
$message = $commit_data->getCommitMessage();
109+
$message = $engine->markupText($message);
110+
$message = phutil_tag_div(
111+
'diffusion-history-message phabricator-remarkup', $message);
112+
105113
$author_phid = $commit->getAuthorPHID();
106114
if ($author_phid) {
107115
$author_name = $handles[$author_phid]->renderLink();
@@ -122,6 +130,7 @@ public function buildList() {
122130
->setHeader($commit_desc)
123131
->setHref($commit_link)
124132
->setDisabled($commit->isUnreachable())
133+
->setDescription($message)
125134
->setImageURI($author_image_uri)
126135
->addByline(pht('Author: %s', $author_name))
127136
->addIcon('none', $committed)

src/applications/uiexample/examples/PHUIObjectItemListExample.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function renderExample() {
202202
$list->addItem(
203203
id(new PHUIObjectItemView())
204204
->setHeader(pht('Ace of Hearts'))
205-
->setSubHead(
205+
->setDescription(
206206
pht('This is a powerful card in the game "Hearts".'))
207207
->setHref('#')
208208
->addAttribute(pht('Suit: Hearts'))

src/view/phui/PHUIObjectItemView.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ final class PHUIObjectItemView extends AphrontTagView {
2626
private $countdownNoun;
2727
private $launchButton;
2828
private $coverImage;
29+
private $description;
2930

3031
public function setDisabled($disabled) {
3132
$this->disabled = $disabled;
@@ -148,6 +149,11 @@ public function setCoverImage($image) {
148149
return $this;
149150
}
150151

152+
public function setDescription($description) {
153+
$this->description = $description;
154+
return $this;
155+
}
156+
151157
public function setEpoch($epoch) {
152158
$date = phabricator_datetime($epoch, $this->getUser());
153159
$this->addIcon('none', $date);
@@ -334,6 +340,23 @@ protected function getTagContent() {
334340
),
335341
$this->header);
336342

343+
$description_tag = null;
344+
if ($this->description) {
345+
$decription_id = celerity_generate_unique_node_id();
346+
$description_tag = id(new PHUITagView())
347+
->setIcon('fa-ellipsis-h')
348+
->addClass('phui-oi-description-tag')
349+
->setType(PHUITagView::TYPE_SHADE)
350+
->setColor(PHUITagView::COLOR_GREY)
351+
->addSigil('jx-toggle-class')
352+
->setSlimShady(true)
353+
->setMetaData(array(
354+
'map' => array(
355+
$decription_id => 'phui-oi-description-reveal',
356+
),
357+
));
358+
}
359+
337360
// Wrap the header content in a <span> with the "slippery" sigil. This
338361
// prevents us from beginning a drag if you click the text (like "T123"),
339362
// but not if you click the white space after the header.
@@ -351,6 +374,7 @@ protected function getTagContent() {
351374
$this->headIcons,
352375
$header_name,
353376
$header_link,
377+
$description_tag,
354378
)));
355379

356380
$icons = array();
@@ -453,6 +477,16 @@ protected function getTagContent() {
453477
$this->subhead);
454478
}
455479

480+
if ($this->description) {
481+
$subhead = phutil_tag(
482+
'div',
483+
array(
484+
'class' => 'phui-oi-subhead phui-oi-description',
485+
'id' => $decription_id,
486+
),
487+
$this->description);
488+
}
489+
456490
if ($icons) {
457491
$icons = phutil_tag(
458492
'div',

webroot/rsrc/css/application/diffusion/diffusion-history.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@
1010
.diffusion-history-list .phui-oi-attribute .phui-tag-core {
1111
border-color: transparent;
1212
}
13+
14+
.diffusion-history-message {
15+
background-color: {$bluebackground};
16+
padding: 16px;
17+
margin: 4px 0;
18+
border-radius: 5px;
19+
color: {$darkbluetext};
20+
}

webroot/rsrc/css/phui/object-item/phui-oi-list-view.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,31 @@ ul.phui-oi-list-view {
285285
padding: 0 8px 6px;
286286
}
287287

288+
.phui-oi-description {
289+
display: none;
290+
}
291+
292+
.phui-oi-description.phui-oi-description-reveal {
293+
display: block;
294+
}
295+
296+
.phui-oi-description-tag {
297+
margin-left: 4px;
298+
}
299+
300+
.phui-oi-description-tag:hover .phui-tag-core {
301+
cursor: pointer;
302+
background: {$darkgreybackground};
303+
}
304+
305+
.phui-oi-description-tag .phui-tag-core {
306+
border: none;
307+
}
308+
309+
.phui-oi-description-tag.phui-tag-view .phui-icon-view {
310+
margin: 2px;
311+
}
312+
288313

289314
/* - Attribute List ------------------------------------------------------------
290315

0 commit comments

Comments
 (0)