Make documentation items in user menu update as you navigate in Quicksand
Summary: Ref T5867. I sure love Javascript. Test Plan: Navigated between Home, Diffusion and Differential, opening the user profile menu. Saw appropraite help items. Reviewers: chad Reviewed By: chad Maniphest Tasks: T5867 Differential Revision: https://secure.phabricator.com/D17214
This commit is contained in:
@@ -175,7 +175,9 @@ abstract class PhabricatorApplication
|
||||
foreach ($articles as $article) {
|
||||
$item = id(new PhabricatorActionView())
|
||||
->setName($article['name'])
|
||||
->setHref($article['href']);
|
||||
->setHref($article['href'])
|
||||
->addSigil('help-item')
|
||||
->setOpenInNewWindow(true);
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
@@ -189,12 +191,21 @@ abstract class PhabricatorApplication
|
||||
$href = '/applications/mailcommands/'.$class.'/'.$key.'/';
|
||||
$item = id(new PhabricatorActionView())
|
||||
->setName($spec['name'])
|
||||
->setHref($href);
|
||||
->setHref($href)
|
||||
->addSigil('help-item')
|
||||
->setOpenInNewWindow(true);
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
if ($items) {
|
||||
$divider = id(new PhabricatorActionView())
|
||||
->addSigil('help-item')
|
||||
->setType(PhabricatorActionView::TYPE_DIVIDER);
|
||||
array_unshift($items, $divider);
|
||||
}
|
||||
|
||||
return array_values($items);
|
||||
}
|
||||
|
||||
public function getHelpDocumentationArticles(PhabricatorUser $viewer) {
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
final class PhabricatorHomeApplication extends PhabricatorApplication {
|
||||
|
||||
private $application;
|
||||
|
||||
const DASHBOARD_DEFAULT = 'dashboard:default';
|
||||
|
||||
public function getBaseURI() {
|
||||
@@ -53,25 +51,40 @@ final class PhabricatorHomeApplication extends PhabricatorApplication {
|
||||
}
|
||||
|
||||
$image = $viewer->getProfileImageURI();
|
||||
if ($controller) {
|
||||
$this->application = $controller->getCurrentApplication();
|
||||
}
|
||||
|
||||
$profile_image = id(new PHUIIconView())
|
||||
->setImage($image)
|
||||
->setHeadSize(PHUIIconView::HEAD_SMALL);
|
||||
|
||||
if ($controller) {
|
||||
$application = $controller->getCurrentApplication();
|
||||
} else {
|
||||
$application = null;
|
||||
}
|
||||
$dropdown_menu = $this->renderUserDropdown($viewer, $application);
|
||||
|
||||
$menu_id = celerity_generate_unique_node_id();
|
||||
|
||||
Javelin::initBehavior(
|
||||
'user-menu',
|
||||
array(
|
||||
'menuID' => $menu_id,
|
||||
'menu' => $dropdown_menu->getDropdownMenuMetadata(),
|
||||
));
|
||||
|
||||
return id(new PHUIButtonView())
|
||||
->setID($menu_id)
|
||||
->setTag('a')
|
||||
->setHref('/p/'.$viewer->getUsername().'/')
|
||||
->setIcon($profile_image)
|
||||
->addClass('phabricator-core-user-menu')
|
||||
->setNoCSS(true)
|
||||
->setDropdown(true)
|
||||
->setDropdownMenu($this->renderUserDropdown($viewer));
|
||||
->setHasCaret(true)
|
||||
->setNoCSS(true);
|
||||
}
|
||||
|
||||
private function renderUserDropdown(PhabricatorUser $viewer) {
|
||||
private function renderUserDropdown(
|
||||
PhabricatorUser $viewer,
|
||||
$application) {
|
||||
|
||||
$view = id(new PhabricatorActionListView())
|
||||
->setViewer($viewer);
|
||||
@@ -98,16 +111,10 @@ final class PhabricatorHomeApplication extends PhabricatorApplication {
|
||||
->setHref('/people/manage/'.$viewer->getID().'/'));
|
||||
|
||||
// Help Menus
|
||||
if ($this->application) {
|
||||
$application = $this->application;
|
||||
if ($application) {
|
||||
$help_links = $application->getHelpMenuItems($viewer);
|
||||
if ($help_links) {
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setType(PhabricatorActionView::TYPE_DIVIDER));
|
||||
|
||||
foreach ($help_links as $link) {
|
||||
$link->setOpenInNewWindow(true);
|
||||
$view->addAction($link);
|
||||
}
|
||||
}
|
||||
@@ -116,11 +123,13 @@ final class PhabricatorHomeApplication extends PhabricatorApplication {
|
||||
// Logout Menu
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->addSigil('logout-item')
|
||||
->setType(PhabricatorActionView::TYPE_DIVIDER));
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Log Out %s', $viewer->getUsername()))
|
||||
->addSigil('logout-item')
|
||||
->setHref('/logout/')
|
||||
->setWorkflow(true));
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ final class PhabricatorActionView extends AphrontView {
|
||||
array($icon, $this->name, $caret));
|
||||
}
|
||||
} else {
|
||||
$item = phutil_tag(
|
||||
$item = javelin_tag(
|
||||
'span',
|
||||
array(
|
||||
'class' => 'phabricator-action-view-item',
|
||||
|
||||
@@ -767,22 +767,6 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView
|
||||
->setViewer($viewer);
|
||||
$dropdown_query->execute();
|
||||
|
||||
$rendered_dropdowns = array();
|
||||
$applications = array(
|
||||
'PhabricatorHomeApplication',
|
||||
);
|
||||
foreach ($applications as $application_class) {
|
||||
if (!PhabricatorApplication::isClassInstalledForViewer(
|
||||
$application_class,
|
||||
$viewer)) {
|
||||
continue;
|
||||
}
|
||||
$application = PhabricatorApplication::getByClass($application_class);
|
||||
$menu = $application->buildMainMenuExtraNodes($viewer, $controller);
|
||||
// TODO: Doesn't work with Quicksand active.
|
||||
$rendered_dropdowns[$application_class] = hsprintf('%s', $menu);
|
||||
}
|
||||
|
||||
$hisec_warning_config = $this->getHighSecurityWarningConfig();
|
||||
|
||||
$console_config = null;
|
||||
@@ -798,6 +782,7 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView
|
||||
|
||||
$application_class = null;
|
||||
$application_search_icon = null;
|
||||
$application_help = null;
|
||||
$controller = $this->getController();
|
||||
if ($controller) {
|
||||
$application = $controller->getCurrentApplication();
|
||||
@@ -806,6 +791,16 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView
|
||||
if ($application->getApplicationSearchDocumentTypes()) {
|
||||
$application_search_icon = $application->getIcon();
|
||||
}
|
||||
|
||||
$help_items = $application->getHelpMenuItems($viewer);
|
||||
if ($help_items) {
|
||||
$help_list = id(new PhabricatorActionListView())
|
||||
->setViewer($viewer);
|
||||
foreach ($help_items as $help_item) {
|
||||
$help_list->addAction($help_item);
|
||||
}
|
||||
$application_help = $help_list->getDropdownMenuMetadata();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -817,11 +812,11 @@ final class PhabricatorStandardPageView extends PhabricatorBarePageView
|
||||
$dropdown_query->getConpherenceData(),
|
||||
),
|
||||
'globalDragAndDrop' => $upload_enabled,
|
||||
'aphlictDropdowns' => $rendered_dropdowns,
|
||||
'hisecWarningConfig' => $hisec_warning_config,
|
||||
'consoleConfig' => $console_config,
|
||||
'applicationClass' => $application_class,
|
||||
'applicationSearchIcon' => $application_search_icon,
|
||||
'helpItems' => $application_help,
|
||||
) + $this->buildAphlictListenConfigData();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ final class PHUIButtonView extends AphrontTagView {
|
||||
private $name;
|
||||
private $tooltip;
|
||||
private $noCSS;
|
||||
private $hasCaret;
|
||||
|
||||
public function setName($name) {
|
||||
$this->name = $name;
|
||||
@@ -93,6 +94,15 @@ final class PHUIButtonView extends AphrontTagView {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHasCaret($has_caret) {
|
||||
$this->hasCaret = $has_caret;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHasCaret() {
|
||||
return $this->hasCaret;
|
||||
}
|
||||
|
||||
public function setIcon($icon, $first = true) {
|
||||
if (!($icon instanceof PHUIIconView)) {
|
||||
$icon = id(new PHUIIconView())
|
||||
@@ -201,7 +211,7 @@ final class PHUIButtonView extends AphrontTagView {
|
||||
}
|
||||
|
||||
$caret = null;
|
||||
if ($this->dropdown) {
|
||||
if ($this->dropdown || $this->getHasCaret()) {
|
||||
$caret = phutil_tag('span', array('class' => 'caret'), '');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user