mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +01:00
Add very basic "quick create" menu
Summary: Ref T3623. This is like a pre-v0, in that it doesn't have a dropdown yet. Clicking the button takes you to a page which can serve as a right click / mobile / edit target in the long run, but is obviously not great for desktop use. I'll add the dropdown in the next iteration. Test Plan: {F105631} Reviewers: chad, btrahan Reviewed By: chad CC: aran Maniphest Tasks: T3623 Differential Revision: https://secure.phabricator.com/D8088
This commit is contained in:
parent
51c4f697f9
commit
049fb2018b
13 changed files with 159 additions and 18 deletions
|
@ -1530,6 +1530,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorHelpKeyboardShortcutController' => 'applications/help/controller/PhabricatorHelpKeyboardShortcutController.php',
|
||||
'PhabricatorHomeController' => 'applications/home/controller/PhabricatorHomeController.php',
|
||||
'PhabricatorHomeMainController' => 'applications/home/controller/PhabricatorHomeMainController.php',
|
||||
'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php',
|
||||
'PhabricatorHovercardExample' => 'applications/uiexample/examples/PhabricatorHovercardExample.php',
|
||||
'PhabricatorHovercardView' => 'view/widget/hovercard/PhabricatorHovercardView.php',
|
||||
'PhabricatorIRCBot' => 'infrastructure/daemon/bot/PhabricatorIRCBot.php',
|
||||
|
@ -4177,6 +4178,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorHelpKeyboardShortcutController' => 'PhabricatorHelpController',
|
||||
'PhabricatorHomeController' => 'PhabricatorController',
|
||||
'PhabricatorHomeMainController' => 'PhabricatorHomeController',
|
||||
'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController',
|
||||
'PhabricatorHovercardExample' => 'PhabricatorUIExample',
|
||||
'PhabricatorHovercardView' => 'AphrontView',
|
||||
'PhabricatorIRCBot' => 'PhabricatorDaemon',
|
||||
|
|
|
@ -39,7 +39,8 @@ final class PhabricatorApplicationAuth extends PhabricatorApplication {
|
|||
->setIcon('power')
|
||||
->setWorkflow(true)
|
||||
->setHref('/logout/')
|
||||
->setSelected(($controller instanceof PhabricatorLogoutController));
|
||||
->setSelected(($controller instanceof PhabricatorLogoutController))
|
||||
->setOrder(900);
|
||||
$items[] = $item;
|
||||
} else {
|
||||
if ($controller instanceof PhabricatorAuthController) {
|
||||
|
@ -51,7 +52,8 @@ final class PhabricatorApplicationAuth extends PhabricatorApplication {
|
|||
->setName(pht('Log In'))
|
||||
// TODO: Login icon?
|
||||
->setIcon('power')
|
||||
->setHref('/auth/start/');
|
||||
->setHref('/auth/start/')
|
||||
->setOrder(900);
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ abstract class PhabricatorApplication
|
|||
* @param PhabricatorUser The viewing user.
|
||||
* @param AphrontController The current controller. May be null for special
|
||||
* pages like 404, exception handlers, etc.
|
||||
* @return list<PhabricatorMainMenuIconView> List of menu items.
|
||||
* @return list<PHUIListItemView> List of menu items.
|
||||
* @task ui
|
||||
*/
|
||||
public function buildMainMenuItems(
|
||||
|
@ -270,6 +270,17 @@ abstract class PhabricatorApplication
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build items for the "quick create" menu.
|
||||
*
|
||||
* @param PhabricatorUser The viewing user.
|
||||
* @return list<PHUIListItemView> List of menu items.
|
||||
*/
|
||||
public function getQuickCreateItems(PhabricatorUser $viewer) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
/* -( Application Management )--------------------------------------------- */
|
||||
|
||||
public static function getByClass($class_name) {
|
||||
|
|
|
@ -50,4 +50,18 @@ final class PhabricatorApplicationConpherence extends PhabricatorApplication {
|
|||
);
|
||||
}
|
||||
|
||||
public function getQuickCreateItems(PhabricatorUser $viewer) {
|
||||
$items = array();
|
||||
|
||||
$item = id(new PHUIListItemView())
|
||||
->setName(pht('New Conpherence Thread'))
|
||||
->setIcon('new')
|
||||
->setWorkflow(true)
|
||||
->setHref($this->getBaseURI().'new/');
|
||||
$items[] = $item;
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -58,11 +58,12 @@ final class PhabricatorApplicationDiviner extends PhabricatorApplication {
|
|||
}
|
||||
|
||||
if ($application && $application->getHelpURI()) {
|
||||
$item = new PHUIListItemView();
|
||||
$item->setName(pht('%s Help', $application->getName()));
|
||||
$item->addClass('core-menu-item');
|
||||
$item->setIcon('help');
|
||||
$item->setHref($application->getHelpURI());
|
||||
$item = id(new PHUIListItemView())
|
||||
->setName(pht('%s Help', $application->getName()))
|
||||
->addClass('core-menu-item')
|
||||
->setIcon('help')
|
||||
->setOrder(100)
|
||||
->setHref($application->getHelpURI());
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,9 @@ final class PhabricatorApplicationHome extends PhabricatorApplication {
|
|||
public function getRoutes() {
|
||||
return array(
|
||||
'/(?:(?P<filter>(?:jump))/)?' => 'PhabricatorHomeMainController',
|
||||
'/home/' => array(
|
||||
'create/' => 'PhabricatorHomeQuickCreateController',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -28,4 +31,27 @@ final class PhabricatorApplicationHome extends PhabricatorApplication {
|
|||
return false;
|
||||
}
|
||||
|
||||
public function getApplicationOrder() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
public function buildMainMenuItems(
|
||||
PhabricatorUser $user,
|
||||
PhabricatorController $controller = null) {
|
||||
|
||||
$items = array();
|
||||
|
||||
if ($user->isLoggedIn() && $user->isUserActivated()) {
|
||||
$item = id(new PHUIListItemView())
|
||||
->setName(pht('Create New...'))
|
||||
->setIcon('new')
|
||||
->addClass('core-menu-item')
|
||||
->setHref('/home/create/')
|
||||
->setOrder(300);
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorHomeQuickCreateController
|
||||
extends PhabricatorHomeController {
|
||||
|
||||
public function processRequest() {
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$applications = id(new PhabricatorApplicationQuery())
|
||||
->setViewer($viewer)
|
||||
->withInstalled(true)
|
||||
->execute();
|
||||
|
||||
$items = array();
|
||||
foreach ($applications as $application) {
|
||||
$app_items = $application->getQuickCreateItems($viewer);
|
||||
foreach ($app_items as $app_item) {
|
||||
$items[] = $app_item;
|
||||
}
|
||||
}
|
||||
|
||||
$list = id(new PHUIObjectItemListView())
|
||||
->setUser($viewer);
|
||||
|
||||
foreach ($items as $item) {
|
||||
$list->addItem(
|
||||
id(new PHUIObjectItemView())
|
||||
->setHeader($item->getName())
|
||||
->setWorkflow($item->getWorkflow())
|
||||
->setHref($item->getHref()));
|
||||
}
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(pht('Quick Create'));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$list,
|
||||
),
|
||||
array(
|
||||
'title' => pht('Quick Create'),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -90,6 +90,18 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
|
|||
return $status;
|
||||
}
|
||||
|
||||
public function getQuickCreateItems(PhabricatorUser $viewer) {
|
||||
$items = array();
|
||||
|
||||
$item = id(new PHUIListItemView())
|
||||
->setName(pht('New Maniphest Task'))
|
||||
->setIcon('new')
|
||||
->setHref($this->getBaseURI().'task/create/');
|
||||
$items[] = $item;
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
protected function getCustomCapabilities() {
|
||||
return array(
|
||||
ManiphestCapabilityDefaultView::CAPABILITY => array(
|
||||
|
|
|
@ -50,4 +50,16 @@ final class PhabricatorApplicationPaste extends PhabricatorApplication {
|
|||
);
|
||||
}
|
||||
|
||||
public function getQuickCreateItems(PhabricatorUser $viewer) {
|
||||
$items = array();
|
||||
|
||||
$item = id(new PHUIListItemView())
|
||||
->setName(pht('New Paste'))
|
||||
->setIcon('new')
|
||||
->setHref($this->getBaseURI().'create/');
|
||||
$items[] = $item;
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -97,10 +97,11 @@ final class PhabricatorApplicationPeople extends PhabricatorApplication {
|
|||
if ($user->isLoggedIn() && $user->isUserActivated()) {
|
||||
$image = $user->loadProfileImageURI();
|
||||
|
||||
$item = new PHUIListItemView();
|
||||
$item->setName($user->getUsername());
|
||||
$item->setHref('/p/'.$user->getUsername().'/');
|
||||
$item->addClass('core-menu-item');
|
||||
$item = id(new PHUIListItemView())
|
||||
->setName($user->getUsername())
|
||||
->setHref('/p/'.$user->getUsername().'/')
|
||||
->addClass('core-menu-item')
|
||||
->setOrder(200);
|
||||
|
||||
$classes = array(
|
||||
'phabricator-core-menu-icon',
|
||||
|
|
|
@ -39,12 +39,13 @@ final class PhabricatorApplicationSettings extends PhabricatorApplication {
|
|||
|
||||
if ($user->isLoggedIn() && $user->isUserActivated()) {
|
||||
$selected = ($controller instanceof PhabricatorSettingsMainController);
|
||||
$item = new PHUIListItemView();
|
||||
$item->setName(pht('Settings'));
|
||||
$item->setIcon('settings');
|
||||
$item->addClass('core-menu-item');
|
||||
$item->setSelected($selected);
|
||||
$item->setHref('/settings/');
|
||||
$item = id(new PHUIListItemView())
|
||||
->setName(pht('Settings'))
|
||||
->setIcon('settings')
|
||||
->addClass('core-menu-item')
|
||||
->setSelected($selected)
|
||||
->setHref('/settings/')
|
||||
->setOrder(400);
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,8 @@ final class PhabricatorMainMenuView extends AphrontView {
|
|||
}
|
||||
}
|
||||
|
||||
$actions = msort($actions, 'getOrder');
|
||||
|
||||
$view = $this->getApplicationMenu();
|
||||
|
||||
if (!$view) {
|
||||
|
|
|
@ -23,6 +23,16 @@ final class PHUIListItemView extends AphrontTagView {
|
|||
private $disabled;
|
||||
private $renderNameAsTooltip;
|
||||
private $statusColor;
|
||||
private $order;
|
||||
|
||||
public function setOrder($order) {
|
||||
$this->order = $order;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrder() {
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
public function setRenderNameAsTooltip($render_name_as_tooltip) {
|
||||
$this->renderNameAsTooltip = $render_name_as_tooltip;
|
||||
|
|
Loading…
Reference in a new issue