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
This commit is contained in:
@@ -2,37 +2,41 @@
|
||||
|
||||
abstract class PhabricatorPasteController extends PhabricatorController {
|
||||
|
||||
public function buildSideNavView(PhabricatorPaste $paste = null) {
|
||||
public function buildSideNavView($filter = null, $for_app = false) {
|
||||
$user = $this->getRequest()->getUser();
|
||||
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('filter/')));
|
||||
|
||||
if ($paste) {
|
||||
$nav->addFilter('paste', 'P'.$paste->getID(), '/P'.$paste->getID());
|
||||
$nav->addSpacer();
|
||||
if ($for_app) {
|
||||
$nav->addFilter('', 'Create Paste', $this->getApplicationURI('/create/'));
|
||||
}
|
||||
|
||||
$nav->addLabel('Create');
|
||||
$nav->addFilter(
|
||||
'edit',
|
||||
'New Paste',
|
||||
$this->getApplicationURI(),
|
||||
$relative = false,
|
||||
$class = ($user->isLoggedIn() ? null : 'disabled'));
|
||||
|
||||
$nav->addSpacer();
|
||||
$nav->addLabel('Pastes');
|
||||
$nav->addLabel('Filters');
|
||||
$nav->addFilter('all', 'All Pastes');
|
||||
if ($user->isLoggedIn()) {
|
||||
$nav->addFilter('my', 'My Pastes');
|
||||
}
|
||||
$nav->addFilter('all', 'All Pastes');
|
||||
|
||||
$nav->selectFilter($filter, 'all');
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
return $this->buildSideNavView(null)->getMenu();
|
||||
return $this->buildSideNavView(null, true)->getMenu();
|
||||
}
|
||||
|
||||
public function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
$crumbs->addAction(
|
||||
id(new PhabricatorMenuItemView())
|
||||
->setName(pht('Create Paste'))
|
||||
->setHref($this->getApplicationURI('create/'))
|
||||
->setIcon('create'));
|
||||
|
||||
return $crumbs;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -173,27 +173,35 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
||||
|
||||
if (!$is_create) {
|
||||
$submit->addCancelButton($paste->getURI());
|
||||
$submit->setValue('Save Paste');
|
||||
$title = 'Edit '.$paste->getFullName();
|
||||
$submit->setValue(pht('Save Paste'));
|
||||
$title = pht('Edit %s', $paste->getFullName());
|
||||
$short = pht('Edit');
|
||||
} else {
|
||||
$submit->setValue('Create Paste');
|
||||
$title = 'Create Paste';
|
||||
$submit->setValue(pht('Create Paste'));
|
||||
$title = pht('Create Paste');
|
||||
$short = pht('Create');
|
||||
}
|
||||
|
||||
$form
|
||||
->appendChild($submit);
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->selectFilter('edit');
|
||||
$nav->appendChild(
|
||||
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
|
||||
if (!$is_create) {
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName('P'.$paste->getID())
|
||||
->setHref('/P'.$paste->getID()));
|
||||
}
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())->setName($short));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
id(new PhabricatorHeaderView())->setHeader($title),
|
||||
$error_view,
|
||||
$form,
|
||||
));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
'device' => true,
|
||||
|
||||
@@ -19,8 +19,8 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
|
||||
$query = new PhabricatorPasteQuery();
|
||||
$query->setViewer($user);
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$filter = $nav->selectFilter($this->filter, 'my');
|
||||
$nav = $this->buildSideNavView($this->filter);
|
||||
$filter = $nav->getSelectedFilter();
|
||||
|
||||
switch ($filter) {
|
||||
case 'my':
|
||||
@@ -45,6 +45,15 @@ final class PhabricatorPasteListController extends PhabricatorPasteController {
|
||||
|
||||
$nav->appendChild($list);
|
||||
|
||||
$crumbs = $this
|
||||
->buildApplicationCrumbs($nav)
|
||||
->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName($title)
|
||||
->setHref($this->getApplicationURI('filter/'.$filter.'/')));
|
||||
|
||||
$nav->setCrumbs($crumbs);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
array(
|
||||
|
||||
@@ -51,19 +51,20 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||
$properties = $this->buildPropertyView($paste, $fork_phids);
|
||||
$source_code = $this->buildSourceCodeView($paste, $file);
|
||||
|
||||
$nav = $this->buildSideNavView($paste);
|
||||
$nav->selectFilter('paste');
|
||||
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView())
|
||||
->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName('P'.$paste->getID())
|
||||
->setHref('/P'.$paste->getID()));
|
||||
|
||||
$nav->appendChild(
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$header,
|
||||
$actions,
|
||||
$properties,
|
||||
$source_code,
|
||||
));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$nav,
|
||||
),
|
||||
array(
|
||||
'title' => $paste->getFullName(),
|
||||
'device' => true,
|
||||
@@ -87,6 +88,7 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$can_fork = $user->isLoggedIn();
|
||||
$fork_uri = $this->getApplicationURI('/create/?parent='.$paste->getID());
|
||||
|
||||
return id(new PhabricatorActionListView())
|
||||
->setUser($user)
|
||||
@@ -97,7 +99,7 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||
->setIcon('fork')
|
||||
->setDisabled(!$can_fork)
|
||||
->setWorkflow(!$can_fork)
|
||||
->setHref($this->getApplicationURI('?parent='.$paste->getID())))
|
||||
->setHref($fork_uri))
|
||||
->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('View Raw File'))
|
||||
|
||||
Reference in New Issue
Block a user