Skip to content

Commit 1c9a6be

Browse files
author
epriestley
committedDec 7, 2012
Add a breadcrumbs element
Summary: Add a basic breadcrumbs element, and implement it in Paste. This needs some polish but is most of the way there. Test Plan: {F26443} {F26444} {F26445} (This element is not visible on devices.) Reviewers: chad Reviewed By: chad CC: aran, btrahan Maniphest Tasks: T1960 Differential Revision: https://secure.phabricator.com/D4087
1 parent f910e38 commit 1c9a6be

18 files changed

+354
-179
lines changed
 

‎scripts/celerity_mapper.php

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
'javelin-typeahead-preloaded-source',
2323
'javelin-typeahead-ondemand-source',
2424
'javelin-tokenizer',
25-
'javelin-fx',
26-
'javelin-color',
2725
),
2826
'core.pkg.js' => array(
2927
'javelin-behavior-aphront-basic-tokenizer',

‎src/__phutil_library_map__.php

+4
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,8 @@
656656
'PhabricatorCountdownEditController' => 'applications/countdown/controller/PhabricatorCountdownEditController.php',
657657
'PhabricatorCountdownListController' => 'applications/countdown/controller/PhabricatorCountdownListController.php',
658658
'PhabricatorCountdownViewController' => 'applications/countdown/controller/PhabricatorCountdownViewController.php',
659+
'PhabricatorCrumbView' => 'view/layout/PhabricatorCrumbView.php',
660+
'PhabricatorCrumbsView' => 'view/layout/PhabricatorCrumbsView.php',
659661
'PhabricatorCursorPagedPolicyAwareQuery' => 'infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php',
660662
'PhabricatorDaemon' => 'infrastructure/daemon/PhabricatorDaemon.php',
661663
'PhabricatorDaemonCombinedLogController' => 'applications/daemon/controller/PhabricatorDaemonCombinedLogController.php',
@@ -1905,6 +1907,8 @@
19051907
'PhabricatorCountdownEditController' => 'PhabricatorCountdownController',
19061908
'PhabricatorCountdownListController' => 'PhabricatorCountdownController',
19071909
'PhabricatorCountdownViewController' => 'PhabricatorCountdownController',
1910+
'PhabricatorCrumbView' => 'AphrontView',
1911+
'PhabricatorCrumbsView' => 'AphrontView',
19081912
'PhabricatorCursorPagedPolicyAwareQuery' => 'PhabricatorPolicyAwareQuery',
19091913
'PhabricatorDaemon' => 'PhutilDaemon',
19101914
'PhabricatorDaemonCombinedLogController' => 'PhabricatorDaemonController',

‎src/applications/base/controller/PhabricatorController.php

+24
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,28 @@ protected function buildApplicationMenu() {
247247
return null;
248248
}
249249

250+
protected function buildApplicationCrumbs() {
251+
252+
$crumbs = array();
253+
254+
$application = $this->getCurrentApplication();
255+
if ($application) {
256+
$sprite = $application->getAutospriteName();
257+
if (!$sprite) {
258+
$sprite = 'default';
259+
}
260+
261+
$crumbs[] = id(new PhabricatorCrumbView())
262+
->setHref($this->getApplicationURI())
263+
->setIcon('temporary-icon-apps');
264+
}
265+
266+
$view = new PhabricatorCrumbsView();
267+
foreach ($crumbs as $crumb) {
268+
$view->addCrumb($crumb);
269+
}
270+
271+
return $view;
272+
}
273+
250274
}

‎src/applications/directory/controller/PhabricatorDirectoryMainController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ private function buildAppPanel() {
496496
'Share Files');
497497
$nav_buttons[] = array(
498498
'Create Paste',
499-
'/paste/',
499+
'/paste/create/',
500500
'create-paste',
501501
'Share Text');
502502

‎src/applications/paste/application/PhabricatorApplicationPaste.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ public function getRoutes() {
2222
return array(
2323
'/P(?P<id>[1-9]\d*)' => 'PhabricatorPasteViewController',
2424
'/paste/' => array(
25-
'' => 'PhabricatorPasteEditController',
26-
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorPasteEditController',
25+
'' => 'PhabricatorPasteListController',
26+
'create/' => 'PhabricatorPasteEditController',
27+
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorPasteEditController',
2728
'filter/(?P<filter>\w+)/' => 'PhabricatorPasteListController',
2829
),
2930
);

‎src/applications/paste/controller/PhabricatorPasteController.php

+20-16
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,41 @@
22

33
abstract class PhabricatorPasteController extends PhabricatorController {
44

5-
public function buildSideNavView(PhabricatorPaste $paste = null) {
5+
public function buildSideNavView($filter = null, $for_app = false) {
66
$user = $this->getRequest()->getUser();
77

88
$nav = new AphrontSideNavFilterView();
99
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('filter/')));
1010

11-
if ($paste) {
12-
$nav->addFilter('paste', 'P'.$paste->getID(), '/P'.$paste->getID());
13-
$nav->addSpacer();
11+
if ($for_app) {
12+
$nav->addFilter('', 'Create Paste', $this->getApplicationURI('/create/'));
1413
}
1514

16-
$nav->addLabel('Create');
17-
$nav->addFilter(
18-
'edit',
19-
'New Paste',
20-
$this->getApplicationURI(),
21-
$relative = false,
22-
$class = ($user->isLoggedIn() ? null : 'disabled'));
23-
24-
$nav->addSpacer();
25-
$nav->addLabel('Pastes');
15+
$nav->addLabel('Filters');
16+
$nav->addFilter('all', 'All Pastes');
2617
if ($user->isLoggedIn()) {
2718
$nav->addFilter('my', 'My Pastes');
2819
}
29-
$nav->addFilter('all', 'All Pastes');
20+
21+
$nav->selectFilter($filter, 'all');
3022

3123
return $nav;
3224
}
3325

3426
public function buildApplicationMenu() {
35-
return $this->buildSideNavView(null)->getMenu();
27+
return $this->buildSideNavView(null, true)->getMenu();
28+
}
29+
30+
public function buildApplicationCrumbs() {
31+
$crumbs = parent::buildApplicationCrumbs();
32+
33+
$crumbs->addAction(
34+
id(new PhabricatorMenuItemView())
35+
->setName(pht('Create Paste'))
36+
->setHref($this->getApplicationURI('create/'))
37+
->setIcon('create'));
38+
39+
return $crumbs;
3640
}
3741

3842
}

‎src/applications/paste/controller/PhabricatorPasteEditController.php

+19-11
Original file line numberDiff line numberDiff line change
@@ -173,27 +173,35 @@ public function processRequest() {
173173

174174
if (!$is_create) {
175175
$submit->addCancelButton($paste->getURI());
176-
$submit->setValue('Save Paste');
177-
$title = 'Edit '.$paste->getFullName();
176+
$submit->setValue(pht('Save Paste'));
177+
$title = pht('Edit %s', $paste->getFullName());
178+
$short = pht('Edit');
178179
} else {
179-
$submit->setValue('Create Paste');
180-
$title = 'Create Paste';
180+
$submit->setValue(pht('Create Paste'));
181+
$title = pht('Create Paste');
182+
$short = pht('Create');
181183
}
182184

183185
$form
184186
->appendChild($submit);
185187

186-
$nav = $this->buildSideNavView();
187-
$nav->selectFilter('edit');
188-
$nav->appendChild(
188+
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
189+
if (!$is_create) {
190+
$crumbs->addCrumb(
191+
id(new PhabricatorCrumbView())
192+
->setName('P'.$paste->getID())
193+
->setHref('/P'.$paste->getID()));
194+
}
195+
$crumbs->addCrumb(
196+
id(new PhabricatorCrumbView())->setName($short));
197+
198+
return $this->buildApplicationPage(
189199
array(
200+
$crumbs,
190201
id(new PhabricatorHeaderView())->setHeader($title),
191202
$error_view,
192203
$form,
193-
));
194-
195-
return $this->buildApplicationPage(
196-
$nav,
204+
),
197205
array(
198206
'title' => $title,
199207
'device' => true,

‎src/applications/paste/controller/PhabricatorPasteListController.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public function processRequest() {
1919
$query = new PhabricatorPasteQuery();
2020
$query->setViewer($user);
2121

22-
$nav = $this->buildSideNavView();
23-
$filter = $nav->selectFilter($this->filter, 'my');
22+
$nav = $this->buildSideNavView($this->filter);
23+
$filter = $nav->getSelectedFilter();
2424

2525
switch ($filter) {
2626
case 'my':
@@ -45,6 +45,15 @@ public function processRequest() {
4545

4646
$nav->appendChild($list);
4747

48+
$crumbs = $this
49+
->buildApplicationCrumbs($nav)
50+
->addCrumb(
51+
id(new PhabricatorCrumbView())
52+
->setName($title)
53+
->setHref($this->getApplicationURI('filter/'.$filter.'/')));
54+
55+
$nav->setCrumbs($crumbs);
56+
4857
return $this->buildApplicationPage(
4958
$nav,
5059
array(

‎src/applications/paste/controller/PhabricatorPasteViewController.php

+10-8
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,20 @@ public function processRequest() {
5151
$properties = $this->buildPropertyView($paste, $fork_phids);
5252
$source_code = $this->buildSourceCodeView($paste, $file);
5353

54-
$nav = $this->buildSideNavView($paste);
55-
$nav->selectFilter('paste');
54+
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView())
55+
->addCrumb(
56+
id(new PhabricatorCrumbView())
57+
->setName('P'.$paste->getID())
58+
->setHref('/P'.$paste->getID()));
5659

57-
$nav->appendChild(
60+
return $this->buildApplicationPage(
5861
array(
62+
$crumbs,
5963
$header,
6064
$actions,
6165
$properties,
6266
$source_code,
63-
));
64-
65-
return $this->buildApplicationPage(
66-
$nav,
67+
),
6768
array(
6869
'title' => $paste->getFullName(),
6970
'device' => true,
@@ -87,6 +88,7 @@ private function buildActionView(
8788
PhabricatorPolicyCapability::CAN_EDIT);
8889

8990
$can_fork = $user->isLoggedIn();
91+
$fork_uri = $this->getApplicationURI('/create/?parent='.$paste->getID());
9092

9193
return id(new PhabricatorActionListView())
9294
->setUser($user)
@@ -97,7 +99,7 @@ private function buildActionView(
9799
->setIcon('fork')
98100
->setDisabled(!$can_fork)
99101
->setWorkflow(!$can_fork)
100-
->setHref($this->getApplicationURI('?parent='.$paste->getID())))
102+
->setHref($fork_uri))
101103
->addAction(
102104
id(new PhabricatorActionView())
103105
->setName(pht('View Raw File'))

‎src/view/layout/AphrontSideNavFilterView.php

+26-11
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,21 @@ final class AphrontSideNavFilterView extends AphrontView {
2929
private $user;
3030
private $active;
3131
private $menu;
32+
private $crumbs;
3233

3334
public function __construct() {
3435
$this->menu = new PhabricatorMenuView();
3536
}
3637

38+
public function setCrumbs(PhabricatorCrumbsView $crumbs) {
39+
$this->crumbs = $crumbs;
40+
return $this;
41+
}
42+
43+
public function getCrumbs() {
44+
return $this->crumbs;
45+
}
46+
3747
public function setActive($active) {
3848
$this->active = $active;
3949
return $this;
@@ -54,6 +64,10 @@ public function setFlexible($flexible) {
5464
return $this;
5565
}
5666

67+
public function getMenuView() {
68+
return $this->menu;
69+
}
70+
5771
public function addMenuItem(PhabricatorMenuItemView $item) {
5872
$this->menu->addMenuItem($item);
5973
return $this;
@@ -120,6 +134,10 @@ public function selectFilter($key, $default = null) {
120134
return $this->selectedFilter;
121135
}
122136

137+
public function getSelectedFilter() {
138+
return $this->selectedFilter;
139+
}
140+
123141
public function render() {
124142
if ($this->menu->getItems()) {
125143
if (!$this->baseURI) {
@@ -187,13 +205,20 @@ private function renderFlexNav() {
187205
self::renderSingleView($this->menu));
188206
}
189207

208+
$crumbs = null;
209+
if ($this->crumbs) {
210+
$crumbs = $this->crumbs->render();
211+
$nav_classes[] = 'has-crumbs';
212+
}
213+
190214
Javelin::initBehavior(
191215
'phabricator-nav',
192216
array(
193217
'mainID' => $main_id,
194218
'localID' => $local_id,
195219
'dragID' => $drag_id,
196220
'contentID' => $content_id,
221+
'menuSize' => ($crumbs ? 78 : 44),
197222
));
198223

199224
if ($this->active && $local_id) {
@@ -204,17 +229,7 @@ private function renderFlexNav() {
204229
));
205230
}
206231

207-
$header_part =
208-
'<div class="phabricator-nav-head">'.
209-
'<div class="phabricator-nav-head-tablet">'.
210-
'<a href="#" class="nav-button nav-button-w nav-button-menu" '.
211-
'id="tablet-menu1"></a>'.
212-
'<a href="#" class="nav-button nav-button-e nav-button-content '.
213-
'nav-button-selected" id="tablet-menu2"></a>'.
214-
'</div>'.
215-
'</div>';
216-
217-
return $header_part.phutil_render_tag(
232+
return $crumbs.phutil_render_tag(
218233
'div',
219234
array(
220235
'class' => implode(' ', $nav_classes),

0 commit comments

Comments
 (0)
Failed to load comments.