1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-22 05:20: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:
epriestley 2014-01-28 20:18:01 -08:00
parent 51c4f697f9
commit 049fb2018b
13 changed files with 159 additions and 18 deletions

View file

@ -1530,6 +1530,7 @@ phutil_register_library_map(array(
'PhabricatorHelpKeyboardShortcutController' => 'applications/help/controller/PhabricatorHelpKeyboardShortcutController.php', 'PhabricatorHelpKeyboardShortcutController' => 'applications/help/controller/PhabricatorHelpKeyboardShortcutController.php',
'PhabricatorHomeController' => 'applications/home/controller/PhabricatorHomeController.php', 'PhabricatorHomeController' => 'applications/home/controller/PhabricatorHomeController.php',
'PhabricatorHomeMainController' => 'applications/home/controller/PhabricatorHomeMainController.php', 'PhabricatorHomeMainController' => 'applications/home/controller/PhabricatorHomeMainController.php',
'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php',
'PhabricatorHovercardExample' => 'applications/uiexample/examples/PhabricatorHovercardExample.php', 'PhabricatorHovercardExample' => 'applications/uiexample/examples/PhabricatorHovercardExample.php',
'PhabricatorHovercardView' => 'view/widget/hovercard/PhabricatorHovercardView.php', 'PhabricatorHovercardView' => 'view/widget/hovercard/PhabricatorHovercardView.php',
'PhabricatorIRCBot' => 'infrastructure/daemon/bot/PhabricatorIRCBot.php', 'PhabricatorIRCBot' => 'infrastructure/daemon/bot/PhabricatorIRCBot.php',
@ -4177,6 +4178,7 @@ phutil_register_library_map(array(
'PhabricatorHelpKeyboardShortcutController' => 'PhabricatorHelpController', 'PhabricatorHelpKeyboardShortcutController' => 'PhabricatorHelpController',
'PhabricatorHomeController' => 'PhabricatorController', 'PhabricatorHomeController' => 'PhabricatorController',
'PhabricatorHomeMainController' => 'PhabricatorHomeController', 'PhabricatorHomeMainController' => 'PhabricatorHomeController',
'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController',
'PhabricatorHovercardExample' => 'PhabricatorUIExample', 'PhabricatorHovercardExample' => 'PhabricatorUIExample',
'PhabricatorHovercardView' => 'AphrontView', 'PhabricatorHovercardView' => 'AphrontView',
'PhabricatorIRCBot' => 'PhabricatorDaemon', 'PhabricatorIRCBot' => 'PhabricatorDaemon',

View file

@ -39,7 +39,8 @@ final class PhabricatorApplicationAuth extends PhabricatorApplication {
->setIcon('power') ->setIcon('power')
->setWorkflow(true) ->setWorkflow(true)
->setHref('/logout/') ->setHref('/logout/')
->setSelected(($controller instanceof PhabricatorLogoutController)); ->setSelected(($controller instanceof PhabricatorLogoutController))
->setOrder(900);
$items[] = $item; $items[] = $item;
} else { } else {
if ($controller instanceof PhabricatorAuthController) { if ($controller instanceof PhabricatorAuthController) {
@ -51,7 +52,8 @@ final class PhabricatorApplicationAuth extends PhabricatorApplication {
->setName(pht('Log In')) ->setName(pht('Log In'))
// TODO: Login icon? // TODO: Login icon?
->setIcon('power') ->setIcon('power')
->setHref('/auth/start/'); ->setHref('/auth/start/')
->setOrder(900);
$items[] = $item; $items[] = $item;
} }
} }

View file

@ -248,7 +248,7 @@ abstract class PhabricatorApplication
* @param PhabricatorUser The viewing user. * @param PhabricatorUser The viewing user.
* @param AphrontController The current controller. May be null for special * @param AphrontController The current controller. May be null for special
* pages like 404, exception handlers, etc. * pages like 404, exception handlers, etc.
* @return list<PhabricatorMainMenuIconView> List of menu items. * @return list<PHUIListItemView> List of menu items.
* @task ui * @task ui
*/ */
public function buildMainMenuItems( 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 )--------------------------------------------- */ /* -( Application Management )--------------------------------------------- */
public static function getByClass($class_name) { public static function getByClass($class_name) {

View file

@ -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;
}
} }

View file

@ -58,11 +58,12 @@ final class PhabricatorApplicationDiviner extends PhabricatorApplication {
} }
if ($application && $application->getHelpURI()) { if ($application && $application->getHelpURI()) {
$item = new PHUIListItemView(); $item = id(new PHUIListItemView())
$item->setName(pht('%s Help', $application->getName())); ->setName(pht('%s Help', $application->getName()))
$item->addClass('core-menu-item'); ->addClass('core-menu-item')
$item->setIcon('help'); ->setIcon('help')
$item->setHref($application->getHelpURI()); ->setOrder(100)
->setHref($application->getHelpURI());
$items[] = $item; $items[] = $item;
} }

View file

@ -17,6 +17,9 @@ final class PhabricatorApplicationHome extends PhabricatorApplication {
public function getRoutes() { public function getRoutes() {
return array( return array(
'/(?:(?P<filter>(?:jump))/)?' => 'PhabricatorHomeMainController', '/(?:(?P<filter>(?:jump))/)?' => 'PhabricatorHomeMainController',
'/home/' => array(
'create/' => 'PhabricatorHomeQuickCreateController',
),
); );
} }
@ -28,4 +31,27 @@ final class PhabricatorApplicationHome extends PhabricatorApplication {
return false; 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;
}
} }

View file

@ -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'),
));
}
}

View file

@ -90,6 +90,18 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
return $status; 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() { protected function getCustomCapabilities() {
return array( return array(
ManiphestCapabilityDefaultView::CAPABILITY => array( ManiphestCapabilityDefaultView::CAPABILITY => array(

View file

@ -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;
}
} }

View file

@ -97,10 +97,11 @@ final class PhabricatorApplicationPeople extends PhabricatorApplication {
if ($user->isLoggedIn() && $user->isUserActivated()) { if ($user->isLoggedIn() && $user->isUserActivated()) {
$image = $user->loadProfileImageURI(); $image = $user->loadProfileImageURI();
$item = new PHUIListItemView(); $item = id(new PHUIListItemView())
$item->setName($user->getUsername()); ->setName($user->getUsername())
$item->setHref('/p/'.$user->getUsername().'/'); ->setHref('/p/'.$user->getUsername().'/')
$item->addClass('core-menu-item'); ->addClass('core-menu-item')
->setOrder(200);
$classes = array( $classes = array(
'phabricator-core-menu-icon', 'phabricator-core-menu-icon',

View file

@ -39,12 +39,13 @@ final class PhabricatorApplicationSettings extends PhabricatorApplication {
if ($user->isLoggedIn() && $user->isUserActivated()) { if ($user->isLoggedIn() && $user->isUserActivated()) {
$selected = ($controller instanceof PhabricatorSettingsMainController); $selected = ($controller instanceof PhabricatorSettingsMainController);
$item = new PHUIListItemView(); $item = id(new PHUIListItemView())
$item->setName(pht('Settings')); ->setName(pht('Settings'))
$item->setIcon('settings'); ->setIcon('settings')
$item->addClass('core-menu-item'); ->addClass('core-menu-item')
$item->setSelected($selected); ->setSelected($selected)
$item->setHref('/settings/'); ->setHref('/settings/')
->setOrder(400);
$items[] = $item; $items[] = $item;
} }

View file

@ -163,6 +163,8 @@ final class PhabricatorMainMenuView extends AphrontView {
} }
} }
$actions = msort($actions, 'getOrder');
$view = $this->getApplicationMenu(); $view = $this->getApplicationMenu();
if (!$view) { if (!$view) {

View file

@ -23,6 +23,16 @@ final class PHUIListItemView extends AphrontTagView {
private $disabled; private $disabled;
private $renderNameAsTooltip; private $renderNameAsTooltip;
private $statusColor; 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) { public function setRenderNameAsTooltip($render_name_as_tooltip) {
$this->renderNameAsTooltip = $render_name_as_tooltip; $this->renderNameAsTooltip = $render_name_as_tooltip;