Page MenuHomePhabricator

D20358.id48609.diff
No OneTemporary

D20358.id48609.diff

diff --git a/src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php b/src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php
--- a/src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php
+++ b/src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php
@@ -49,7 +49,7 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
@@ -57,12 +57,12 @@
return array();
}
- $href = $this->getItemViewURI($config);
+ $uri = $this->getItemViewURI($config);
$name = $this->getDisplayName($config);
$icon = 'fa-pencil';
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
diff --git a/src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php b/src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php
--- a/src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php
+++ b/src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php
@@ -49,16 +49,16 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$name = $this->getDisplayName($config);
$icon = 'fa-ellipsis-h';
- $href = '/applications/';
+ $uri = '/applications/';
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
diff --git a/src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php b/src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php
--- a/src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php
+++ b/src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php
@@ -52,16 +52,16 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$name = $this->getDisplayName($config);
$icon = 'fa-home';
- $href = $this->getItemViewURI($config);
+ $uri = $this->getItemViewURI($config);
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
diff --git a/src/applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php
--- a/src/applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleBadgesProfileMenuItem.php
@@ -40,14 +40,14 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/badges/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/badges/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-trophy');
diff --git a/src/applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php
--- a/src/applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleCommitsProfileMenuItem.php
@@ -40,14 +40,14 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/commits/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/commits/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-code');
diff --git a/src/applications/people/menuitem/PhabricatorPeopleDetailsProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleDetailsProfileMenuItem.php
--- a/src/applications/people/menuitem/PhabricatorPeopleDetailsProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleDetailsProfileMenuItem.php
@@ -35,16 +35,16 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
- $href = urisprintf(
+ $uri = urisprintf(
'/p/%s/',
$user->getUsername());
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName(pht('Profile'))
->setIcon('fa-user');
diff --git a/src/applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php
--- a/src/applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleManageProfileMenuItem.php
@@ -40,14 +40,14 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/manage/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/manage/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-gears');
diff --git a/src/applications/people/menuitem/PhabricatorPeoplePictureProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeoplePictureProfileMenuItem.php
--- a/src/applications/people/menuitem/PhabricatorPeoplePictureProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeoplePictureProfileMenuItem.php
@@ -28,52 +28,18 @@
return array();
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
- require_celerity_resource('people-picture-menu-item-css');
$picture = $user->getProfileImageURI();
$name = $user->getUsername();
- $classes = array();
- $classes[] = 'people-menu-image';
- if ($user->getIsDisabled()) {
- $classes[] = 'phui-image-disabled';
- }
+ $item = $this->newItemView()
+ ->setDisabled($user->getIsDisabled());
- $href = urisprintf(
- '/p/%s/',
- $user->getUsername());
-
- $photo = phutil_tag(
- 'img',
- array(
- 'src' => $picture,
- 'class' => implode(' ', $classes),
- ));
-
- $can_edit = PhabricatorPolicyFilter::hasCapability(
- $this->getViewer(),
- $user,
- PhabricatorPolicyCapability::CAN_EDIT);
-
- if ($can_edit) {
- $id = $user->getID();
- $href = "/people/picture/{$id}/";
- }
-
- $view = phutil_tag_div('people-menu-image-container', $photo);
- $view = phutil_tag(
- 'a',
- array(
- 'href' => $href,
- ),
- $view);
-
- $item = $this->newItem()
- ->appendChild($view);
+ $item->newProfileImage($picture);
return array(
$item,
diff --git a/src/applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php
--- a/src/applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php
@@ -40,14 +40,14 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/revisions/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/revisions/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-gear');
diff --git a/src/applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php b/src/applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php
--- a/src/applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php
+++ b/src/applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php
@@ -40,14 +40,14 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$user = $config->getProfileObject();
$id = $user->getID();
- $item = $this->newItem()
- ->setHref("/people/tasks/{$id}/")
+ $item = $this->newItemView()
+ ->setURI("/people/tasks/{$id}/")
->setName($this->getDisplayName($config))
->setIcon('fa-anchor');
diff --git a/src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php
--- a/src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php
@@ -49,7 +49,7 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
@@ -58,10 +58,10 @@
$name = $project->getName();
$icon = $project->getDisplayIconIcon();
- $href = "/project/profile/{$id}/";
+ $uri = "/project/profile/{$id}/";
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
diff --git a/src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
--- a/src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php
@@ -49,7 +49,7 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
@@ -58,10 +58,10 @@
$name = $this->getDisplayName($config);
$icon = 'fa-gears';
- $href = "/project/manage/{$id}/";
+ $uri = "/project/manage/{$id}/";
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
diff --git a/src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php
--- a/src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php
@@ -39,7 +39,7 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
@@ -48,10 +48,10 @@
$name = $this->getDisplayName($config);
$icon = 'fa-group';
- $href = "/project/members/{$id}/";
+ $uri = "/project/members/{$id}/";
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
diff --git a/src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php
--- a/src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php
@@ -32,38 +32,16 @@
return array();
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
- require_celerity_resource('people-picture-menu-item-css');
-
$picture = $project->getProfileImageURI();
- $href = $project->getProfileURI();
-
- $classes = array();
- $classes[] = 'people-menu-image';
- if ($project->isArchived()) {
- $classes[] = 'phui-image-disabled';
- }
-
- $photo = phutil_tag(
- 'img',
- array(
- 'src' => $picture,
- 'class' => implode(' ', $classes),
- ));
- $view = phutil_tag_div('people-menu-image-container', $photo);
- $view = phutil_tag(
- 'a',
- array(
- 'href' => $href,
- ),
- $view);
+ $item = $this->newItemView()
+ ->setDisabled($project->isArchived());
- $item = $this->newItem()
- ->appendChild($view);
+ $item->newProfileImage($picture);
return array(
$item,
diff --git a/src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php
--- a/src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectPointsProfileMenuItem.php
@@ -52,7 +52,7 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$project = $config->getProfileObject();
@@ -165,8 +165,8 @@
),
$bar);
- $item = $this->newItem()
- ->appendChild($bar);
+ $item = $this->newItemView()
+ ->newProgressBar($bar);
return array(
$item,
diff --git a/src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
--- a/src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php
@@ -47,7 +47,7 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
@@ -55,10 +55,10 @@
$name = $this->getDisplayName($config);
$icon = 'fa-sitemap';
- $href = "/project/subprojects/{$id}/";
+ $uri = "/project/subprojects/{$id}/";
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
diff --git a/src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php b/src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
--- a/src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
+++ b/src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php
@@ -56,16 +56,16 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $config->getProfileObject();
$id = $project->getID();
- $href = $project->getWorkboardURI();
+ $uri = $project->getWorkboardURI();
$name = $this->getDisplayName($config);
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon('fa-columns');
diff --git a/src/applications/search/engine/PhabricatorProfileMenuItemView.php b/src/applications/search/engine/PhabricatorProfileMenuItemView.php
--- a/src/applications/search/engine/PhabricatorProfileMenuItemView.php
+++ b/src/applications/search/engine/PhabricatorProfileMenuItemView.php
@@ -7,6 +7,7 @@
private $uri;
private $name;
private $icon;
+ private $iconImage;
private $disabled;
private $tooltip;
private $actions = array();
@@ -53,6 +54,15 @@
return $this->icon;
}
+ public function setIconImage($icon_image) {
+ $this->iconImage = $icon_image;
+ return $this;
+ }
+
+ public function getIconImage() {
+ return $this->iconImage;
+ }
+
public function setDisabled($disabled) {
$this->disabled = $disabled;
return $this;
@@ -146,6 +156,11 @@
$view->setIcon($icon);
}
+ $icon_image = $this->getIconImage();
+ if ($icon_image) {
+ $view->setProfileImage($icon_image);
+ }
+
if ($this->getDisabled()) {
$view->setDisabled(true);
}
@@ -160,6 +175,11 @@
->addClass('phui-divider');
}
+ $tooltip = $this->getTooltip();
+ if (strlen($tooltip)) {
+ $view->setTooltip($tooltip);
+ }
+
if ($this->images) {
require_celerity_resource('people-picture-menu-item-css');
foreach ($this->images as $image_src) {
diff --git a/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php
@@ -68,7 +68,7 @@
return head($apps);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$app = $this->getApplication($config);
@@ -83,8 +83,8 @@
return array();
}
- $item = $this->newItem()
- ->setHref($app->getApplicationURI())
+ $item = $this->newItemView()
+ ->setURI($app->getApplicationURI())
->setName($this->getDisplayName($config))
->setIcon($app->getIcon());
diff --git a/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
@@ -41,7 +41,7 @@
return $conpherence;
}
- public function willBuildNavigationItems(array $items) {
+ public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$room_phids = array();
foreach ($items as $item) {
@@ -98,7 +98,7 @@
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
$room = $this->getConpherence($config);
@@ -114,22 +114,15 @@
$unread_count = $data['unread_count'];
}
- $count = null;
+ $item = $this->newItemView()
+ ->setURI('/'.$room->getMonogram())
+ ->setName($this->getDisplayName($config))
+ ->setIcon('fa-comments');
+
if ($unread_count) {
- $count = phutil_tag(
- 'span',
- array(
- 'class' => 'phui-list-item-count',
- ),
- $unread_count);
+ $item->newCount($unread_count);
}
- $item = $this->newItem()
- ->setHref('/'.$room->getMonogram())
- ->setName($this->getDisplayName($config))
- ->setIcon('fa-comments')
- ->appendChild($count);
-
return array(
$item,
);
diff --git a/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
@@ -8,6 +8,7 @@
const FIELD_DASHBOARD = 'dashboardPHID';
private $dashboard;
+ private $dashboardHandle;
public function getMenuItemTypeIcon() {
return 'fa-dashboard';
@@ -26,21 +27,13 @@
return true;
}
- public function attachDashboard($dashboard) {
+ private function attachDashboard(PhabricatorDashboard $dashboard = null) {
$this->dashboard = $dashboard;
return $this;
}
- public function getDashboard() {
- $dashboard = $this->dashboard;
-
- if (!$dashboard) {
- return null;
- } else if ($dashboard->isArchived()) {
- return null;
- }
-
- return $dashboard;
+ private function getDashboard() {
+ return $this->dashboard;
}
public function newPageContent(
@@ -56,7 +49,15 @@
->needPanels(true)
->executeOne();
if (!$dashboard) {
- return null;
+ return $this->newEmptyView(
+ pht('Invalid Dashboard'),
+ pht('This dashboard is invalid and could not be loaded.'));
+ }
+
+ if ($dashboard->isArchived()) {
+ return $this->newEmptyView(
+ pht('Archived Dashboard'),
+ pht('This dashboard has been archived.'));
}
$engine = id(new PhabricatorDashboardRenderingEngine())
@@ -66,7 +67,7 @@
return $engine->renderDashboard();
}
- public function willBuildNavigationItems(array $items) {
+ public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$dashboard_phids = array();
foreach ($items as $item) {
@@ -78,11 +79,18 @@
->withPHIDs($dashboard_phids)
->execute();
+ $handles = $viewer->loadHandles($dashboard_phids);
+
$dashboards = mpull($dashboards, null, 'getPHID');
foreach ($items as $item) {
$dashboard_phid = $item->getMenuItemProperty('dashboardPHID');
$dashboard = idx($dashboards, $dashboard_phid, null);
- $item->getMenuItem()->attachDashboard($dashboard);
+
+ $menu_item = $item->getMenuItem();
+
+ $menu_item
+ ->attachDashboard($dashboard)
+ ->setDashboardHandle($handles[$dashboard_phid]);
}
}
@@ -91,7 +99,15 @@
$dashboard = $this->getDashboard();
if (!$dashboard) {
- return pht('(Restricted/Invalid Dashboard)');
+ if ($this->getDashboardHandle()->getPolicyFiltered()) {
+ return pht('Restricted Dashboard');
+ } else {
+ return pht('Invalid Dashboard');
+ }
+ }
+
+ if ($dashboard->isArchived()) {
+ return pht('Archived Dashboard');
}
if (strlen($this->getName($config))) {
@@ -122,24 +138,43 @@
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
+ $is_disabled = true;
+ $action_uri = null;
+
$dashboard = $this->getDashboard();
- if (!$dashboard) {
- return array();
+ if ($dashboard) {
+ if ($dashboard->isArchived()) {
+ $icon = 'fa-ban';
+ $name = $this->getDisplayName($config);
+ } else {
+ $icon = $dashboard->getIcon();
+ $name = $this->getDisplayName($config);
+ $is_disabled = false;
+ $action_uri = '/dashboard/arrange/'.$dashboard->getID().'/';
+ }
+ } else {
+ $icon = 'fa-ban';
+ if ($this->getDashboardHandle()->getPolicyFiltered()) {
+ $name = pht('Restricted Dashboard');
+ } else {
+ $name = pht('Invalid Dashboard');
+ }
}
- $icon = $dashboard->getIcon();
- $name = $this->getDisplayName($config);
- $href = $this->getItemViewURI($config);
- $action_href = '/dashboard/arrange/'.$dashboard->getID().'/';
+ $uri = $this->getItemViewURI($config);
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon)
- ->setActionIcon('fa-pencil', $action_href);
+ ->setDisabled($is_disabled);
+
+ if ($action_uri) {
+ $item->newAction($action_uri);
+ }
return array(
$item,
@@ -191,4 +226,13 @@
return $errors;
}
+ private function getDashboardHandle() {
+ return $this->dashboardHandle;
+ }
+
+ private function setDashboardHandle(PhabricatorObjectHandle $handle) {
+ $this->dashboardHandle = $handle;
+ return $this;
+ }
+
}
diff --git a/src/applications/search/menuitem/PhabricatorDividerProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorDividerProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorDividerProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorDividerProfileMenuItem.php
@@ -34,12 +34,11 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
- $item = $this->newItem()
- ->setType(PHUIListItemView::TYPE_DIVIDER)
- ->addClass('phui-divider');
+ $item = $this->newItemView()
+ ->setIsDivider(true);
return array(
$item,
diff --git a/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
@@ -34,7 +34,7 @@
return $form;
}
- public function willBuildNavigationItems(array $items) {
+ public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$engines = PhabricatorEditEngine::getAllEditEngines();
$engine_keys = array_keys($engines);
@@ -99,7 +99,7 @@
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$form = $this->getForm();
@@ -110,13 +110,13 @@
$icon = $form->getIcon();
$name = $this->getDisplayName($config);
- $href = $form->getCreateURI();
- if ($href === null) {
+ $uri = $form->getCreateURI();
+ if ($uri === null) {
return array();
}
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
diff --git a/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php
@@ -39,14 +39,14 @@
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$name = $this->getLabelName($config);
- $item = $this->newItem()
+ $item = $this->newItemView()
->setName($name)
- ->setType(PHUIListItemView::TYPE_LABEL);
+ ->setIsLabel(true);
return array(
$item,
diff --git a/src/applications/search/menuitem/PhabricatorLinkProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorLinkProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorLinkProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorLinkProfileMenuItem.php
@@ -71,22 +71,14 @@
return $config->getMenuItemProperty('tooltip');
}
- private function isValidLinkURI($uri) {
- return PhabricatorEnv::isValidURIForLink($uri);
- }
-
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$icon = $this->getLinkIcon($config);
$name = $this->getLinkName($config);
- $href = $this->getLinkURI($config);
+ $uri = $this->getLinkURI($config);
$tooltip = $this->getLinkTooltip($config);
- if (!$this->isValidLinkURI($href)) {
- $href = '#';
- }
-
$icon_object = id(new PhabricatorProfileMenuItemIconSet())
->getIcon($icon);
if ($icon_object) {
@@ -95,12 +87,12 @@
$icon_class = 'fa-link';
}
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon_class)
->setTooltip($tooltip)
- ->setRel('noreferrer');
+ ->setIsExternalLink(true);
return array(
$item,
@@ -142,7 +134,7 @@
continue;
}
- if (!$this->isValidLinkURI($new)) {
+ if (!PhabricatorEnv::isValidURIForLink($new)) {
$errors[] = $this->newInvalidError(
pht(
'URI "%s" is not a valid link URI. It should be a full, valid '.
diff --git a/src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php
@@ -49,7 +49,7 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer();
@@ -58,13 +58,13 @@
}
$engine = $this->getEngine();
- $href = $engine->getItemURI('configure/');
+ $uri = $engine->getItemURI('configure/');
$name = $this->getDisplayName($config);
$icon = 'fa-pencil';
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
->setIcon($icon);
diff --git a/src/applications/search/menuitem/PhabricatorMotivatorProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorMotivatorProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorMotivatorProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorMotivatorProfileMenuItem.php
@@ -50,7 +50,7 @@
);
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$source = $config->getMenuItemProperty('source');
@@ -66,7 +66,7 @@
$fact_text = $this->selectFact($facts);
- $item = $this->newItem()
+ $item = $this->newItemView()
->setName($fact_name)
->setIcon($fact_icon)
->setTooltip($fact_text)
diff --git a/src/applications/search/menuitem/PhabricatorProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorProfileMenuItem.php
@@ -5,15 +5,6 @@
private $viewer;
private $engine;
- final public function buildNavigationMenuItems(
- PhabricatorProfileMenuItemConfiguration $config) {
- return $this->newNavigationMenuItems($config);
- }
-
- abstract protected function newNavigationMenuItems(
- PhabricatorProfileMenuItemConfiguration $config);
-
- public function willBuildNavigationItems(array $items) {}
public function getMenuItemTypeIcon() {
return null;
@@ -76,10 +67,38 @@
->execute();
}
- protected function newItem() {
- return new PHUIListItemView();
+ final protected function newItemView() {
+ return new PhabricatorProfileMenuItemView();
}
+ public function willGetMenuItemViewList(array $items) {}
+
+ final public function getMenuItemViewList(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ $list = $this->newMenuItemViewList($config);
+
+ if (!is_array($list)) {
+ throw new Exception(
+ pht(
+ 'Expected "newMenuItemViewList()" to return a list (in class "%s"), '.
+ 'but it returned something else ("%s").',
+ get_class($this),
+ phutil_describe_type($list)));
+ }
+
+ assert_instances_of($list, 'PhabricatorProfileMenuItemView');
+
+ foreach ($list as $view) {
+ $view->setMenuItemConfiguration($config);
+ }
+
+ return $list;
+ }
+
+ abstract protected function newMenuItemViewList(
+ PhabricatorProfileMenuItemConfiguration $config);
+
+
public function newPageContent(
PhabricatorProfileMenuItemConfiguration $config) {
return null;
@@ -131,4 +150,14 @@
return $this->newError(pht('Invalid'), $message, $xaction);
}
+ final protected function newEmptyView($title, $message) {
+ return id(new PHUIInfoView())
+ ->setTitle($title)
+ ->setSeverity(PHUIInfoView::SEVERITY_NODATA)
+ ->setErrors(
+ array(
+ $message,
+ ));
+ }
+
}
diff --git a/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
--- a/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
+++ b/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php
@@ -35,7 +35,7 @@
return $project;
}
- public function willBuildNavigationItems(array $items) {
+ public function willGetMenuItemViewList(array $items) {
$viewer = $this->getViewer();
$project_phids = array();
foreach ($items as $item) {
@@ -90,7 +90,7 @@
return $config->getMenuItemProperty('name');
}
- protected function newNavigationMenuItems(
+ protected function newMenuItemViewList(
PhabricatorProfileMenuItemConfiguration $config) {
$project = $this->getProject();
@@ -100,12 +100,12 @@
$picture = $project->getProfileImageURI();
$name = $this->getDisplayName($config);
- $href = $project->getURI();
+ $uri = $project->getURI();
- $item = $this->newItem()
- ->setHref($href)
+ $item = $this->newItemView()
+ ->setURI($uri)
->setName($name)
- ->setProfileImage($picture);
+ ->setIconImage($picture);
return array(
$item,

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 13, 10:11 PM (3 d, 1 h ago)
Storage Engine
amazon-s3
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
phabricator/secure/fd/tc/xhq4x5gttrdcbfkg
Default Alt Text
D20358.id48609.diff (33 KB)

Event Timeline