Commit 452f5bce authored by Chad Little's avatar Chad Little
Browse files

Make some defaults for Quick Create / Favorites

Summary: Add in some basic defaults, Tasks, Projects, Repositories... anything else? Also switches "manage" context if you are an admin or user. Hides link if you are not logged in.

Test Plan: Review Global/Personal in Favorites app, click on each link.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D17174
parent 1e1a0182
......@@ -3,6 +3,9 @@
final class PhabricatorFavoritesConstants
extends PhabricatorFavoritesController {
const ITEM_TASK = 'favorites.task';
const ITEM_PROJECT = 'favorites.project';
const ITEM_REPOSITORY = 'favorites.repository';
const ITEM_MANAGE = 'favorites.manage';
}
......@@ -20,16 +20,50 @@ final class PhabricatorFavoritesProfileMenuEngine
protected function getBuiltinProfileItems($object) {
$items = array();
$custom_phid = $this->getCustomPHID();
$custom = $this->getCustomPHID();
// Built-in Global Defaults
if (!$custom_phid) {
$create_task = array(
'name' => null,
'formKey' =>
id(new ManiphestEditEngine())->getProfileMenuItemDefault(),
);
$create_project = array(
'name' => null,
'formKey' =>
id(new PhabricatorProjectEditEngine())->getProfileMenuItemDefault(),
);
$create_repository = array(
'name' => null,
'formKey' =>
id(new DiffusionRepositoryEditEngine())->getProfileMenuItemDefault(),
);
if ($custom) {
$items[] = $this->newItem()
->setBuiltinKey(PhabricatorFavoritesConstants::ITEM_MANAGE)
->setMenuItemKey(
PhabricatorFavoritesManageProfileMenuItem::MENUITEMKEY);
->setBuiltinKey(PhabricatorFavoritesConstants::ITEM_TASK)
->setMenuItemKey(PhabricatorEditEngineProfileMenuItem::MENUITEMKEY)
->setMenuItemProperties($create_task);
$items[] = $this->newItem()
->setBuiltinKey(PhabricatorFavoritesConstants::ITEM_PROJECT)
->setMenuItemKey(PhabricatorEditEngineProfileMenuItem::MENUITEMKEY)
->setMenuItemProperties($create_project);
$items[] = $this->newItem()
->setBuiltinKey(PhabricatorFavoritesConstants::ITEM_REPOSITORY)
->setMenuItemKey(PhabricatorEditEngineProfileMenuItem::MENUITEMKEY)
->setMenuItemProperties($create_repository);
}
// Single Manage Item, switches URI based on admin/user
$items[] = $this->newItem()
->setBuiltinKey(PhabricatorFavoritesConstants::ITEM_MANAGE)
->setMenuItemKey(
PhabricatorFavoritesManageProfileMenuItem::MENUITEMKEY);
return $items;
}
......
......@@ -47,15 +47,22 @@ final class PhabricatorFavoritesManageProfileMenuItem
protected function newNavigationMenuItems(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$name = $this->getDisplayName($config);
$icon = 'fa-pencil';
$href = '/favorites/personal/item/configure/';
if ($viewer->isLoggedIn()) {
$admin = $viewer->getIsAdmin();
$name = $this->getDisplayName($config);
$icon = 'fa-pencil';
$href = '/favorites/personal/item/configure/';
if ($admin) {
$href = '/favorites/';
}
$item = $this->newItem()
->setHref($href)
->setName($name)
->setIcon($icon);
$item = $this->newItem()
->setHref($href)
->setName($name)
->setIcon($icon);
}
return array(
$item,
......
......@@ -107,6 +107,10 @@ abstract class PhabricatorEditEngine
return $this->hideHeader;
}
public function getProfileMenuItemDefault() {
return $this->getEngineKey().'/'.self::EDITENGINECONFIG_DEFAULT;
}
/* -( Managing Fields )---------------------------------------------------- */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment