Skip to content

Commit 47bf382

Browse files
author
epriestley
committed
Allow profile menu items to be locked to the top or bottom of the menu
Summary: Depends on D20353. Ref T13275. This is just some small quality-of-life fixes: - When you add items to menus, they currently go below the "Edit Menu/Manage Menu" links by default. This isn't a very good place for them. Instead, lock "edit" items to the bottom of the menu. - Lock profile pictures to the top of the menu. This just simplifies things a little. - Show more iconography hints on the "edit menu items" UI. - Add a "drag stuff to do things" hint if some stuff can be dragged. Test Plan: - Added new items to a Portal, they didn't go to the very bottom. Instead, they went above the "Edit/Manage" links; a sensible place for them. - Viewed the "edit menu items" screen, saw more hints and visual richness. - Viewed/edited Home, Projects, Portals, Favorites Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13275 Differential Revision: https://secure.phabricator.com/D20355
1 parent 36a8b4e commit 47bf382

18 files changed

+129
-22
lines changed

resources/celerity/map.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'names' => array(
1010
'conpherence.pkg.css' => '3c8a0668',
1111
'conpherence.pkg.js' => '020aebcf',
12-
'core.pkg.css' => '7e6e954b',
12+
'core.pkg.css' => 'a1c2d49b',
1313
'core.pkg.js' => 'a747b035',
1414
'differential.pkg.css' => '8d8360fb',
1515
'differential.pkg.js' => '67e02996',
@@ -132,7 +132,7 @@
132132
'rsrc/css/phui/object-item/phui-oi-color.css' => 'b517bfa0',
133133
'rsrc/css/phui/object-item/phui-oi-drag-ui.css' => 'da15d3dc',
134134
'rsrc/css/phui/object-item/phui-oi-flush-ui.css' => '490e2e2e',
135-
'rsrc/css/phui/object-item/phui-oi-list-view.css' => 'a65865a7',
135+
'rsrc/css/phui/object-item/phui-oi-list-view.css' => 'f14f2422',
136136
'rsrc/css/phui/object-item/phui-oi-simple-ui.css' => '6a30fa46',
137137
'rsrc/css/phui/phui-action-list.css' => 'c4972757',
138138
'rsrc/css/phui/phui-action-panel.css' => '6c386cbf',
@@ -853,7 +853,7 @@
853853
'phui-oi-color-css' => 'b517bfa0',
854854
'phui-oi-drag-ui-css' => 'da15d3dc',
855855
'phui-oi-flush-ui-css' => '490e2e2e',
856-
'phui-oi-list-view-css' => 'a65865a7',
856+
'phui-oi-list-view-css' => 'f14f2422',
857857
'phui-oi-simple-ui-css' => '6a30fa46',
858858
'phui-pager-css' => 'd022c7ad',
859859
'phui-pinboard-view-css' => '1f08f5d8',

src/applications/dashboard/engine/PhabricatorDashboardPortalProfileMenuEngine.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ protected function getBuiltinProfileItems($object) {
2424

2525
$items[] = $this->newItem()
2626
->setMenuItemKey(PhabricatorDashboardPortalMenuItem::MENUITEMKEY)
27-
->setBuiltinKey('manage');
27+
->setBuiltinKey('manage')
28+
->setIsTailItem(true);
2829

2930
return $items;
3031
}

src/applications/dashboard/menuitem/PhabricatorDashboardPortalMenuItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ final class PhabricatorDashboardPortalMenuItem
66
const MENUITEMKEY = 'portal';
77

88
public function getMenuItemTypeIcon() {
9-
return 'fa-compass';
9+
return 'fa-pencil';
1010
}
1111

1212
public function getDefaultName() {

src/applications/home/menuitem/PhabricatorHomeLauncherProfileMenuItem.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ private function getDefaultName() {
1313
return pht('More Applications');
1414
}
1515

16+
public function getMenuItemTypeIcon() {
17+
return 'fa-ellipsis-h';
18+
}
19+
1620
public function canHideMenuItem(
1721
PhabricatorProfileMenuItemConfiguration $config) {
1822
return false;
@@ -50,7 +54,7 @@ protected function newNavigationMenuItems(
5054
$viewer = $this->getViewer();
5155

5256
$name = $this->getDisplayName($config);
53-
$icon = 'fa-globe';
57+
$icon = 'fa-ellipsis-h';
5458
$href = '/applications/';
5559

5660
$item = $this->newItem()

src/applications/home/menuitem/PhabricatorHomeProfileMenuItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ private function getDefaultName() {
1313
return pht('Home');
1414
}
1515

16+
public function getMenuItemTypeIcon() {
17+
return 'fa-home';
18+
}
19+
1620
public function canMakeDefault(
1721
PhabricatorProfileMenuItemConfiguration $config) {
1822
return true;

src/applications/project/engine/PhabricatorProjectProfileMenuEngine.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ protected function getBuiltinProfileItems($object) {
2222

2323
$items[] = $this->newItem()
2424
->setBuiltinKey(PhabricatorProject::ITEM_PICTURE)
25-
->setMenuItemKey(PhabricatorProjectPictureProfileMenuItem::MENUITEMKEY);
25+
->setMenuItemKey(PhabricatorProjectPictureProfileMenuItem::MENUITEMKEY)
26+
->setIsHeadItem(true);
2627

2728
$items[] = $this->newItem()
2829
->setBuiltinKey(PhabricatorProject::ITEM_PROFILE)
@@ -47,7 +48,8 @@ protected function getBuiltinProfileItems($object) {
4748

4849
$items[] = $this->newItem()
4950
->setBuiltinKey(PhabricatorProject::ITEM_MANAGE)
50-
->setMenuItemKey(PhabricatorProjectManageProfileMenuItem::MENUITEMKEY);
51+
->setMenuItemKey(PhabricatorProjectManageProfileMenuItem::MENUITEMKEY)
52+
->setIsTailItem(true);
5153

5254
return $items;
5355
}

src/applications/project/menuitem/PhabricatorProjectDetailsProfileMenuItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ private function getDefaultName() {
1313
return pht('Project Details');
1414
}
1515

16+
public function getMenuItemTypeIcon() {
17+
return 'fa-file-text-o';
18+
}
19+
1620
public function canHideMenuItem(
1721
PhabricatorProfileMenuItemConfiguration $config) {
1822
return false;

src/applications/project/menuitem/PhabricatorProjectManageProfileMenuItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ private function getDefaultName() {
1313
return pht('Manage');
1414
}
1515

16+
public function getMenuItemTypeIcon() {
17+
return 'fa-cog';
18+
}
19+
1620
public function canHideMenuItem(
1721
PhabricatorProfileMenuItemConfiguration $config) {
1822
return false;

src/applications/project/menuitem/PhabricatorProjectMembersProfileMenuItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ private function getDefaultName() {
1313
return pht('Members');
1414
}
1515

16+
public function getMenuItemTypeIcon() {
17+
return 'fa-users';
18+
}
19+
1620
public function getDisplayName(
1721
PhabricatorProfileMenuItemConfiguration $config) {
1822
$name = $config->getMenuItemProperty('name');

src/applications/project/menuitem/PhabricatorProjectPictureProfileMenuItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ private function getDefaultName() {
1313
return pht('Project Picture');
1414
}
1515

16+
public function getMenuItemTypeIcon() {
17+
return 'fa-image';
18+
}
19+
1620
public function canHideMenuItem(
1721
PhabricatorProfileMenuItemConfiguration $config) {
1822
return false;

src/applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ private function getDefaultName() {
1313
return pht('Subprojects');
1414
}
1515

16+
public function getMenuItemTypeIcon() {
17+
return 'fa-sitemap';
18+
}
19+
1620
public function shouldEnableForObject($object) {
1721
if ($object->isMilestone()) {
1822
return false;

src/applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ private function getDefaultName() {
1313
return pht('Workboard');
1414
}
1515

16+
public function getMenuItemTypeIcon() {
17+
return 'fa-columns';
18+
}
19+
1620
public function canMakeDefault(
1721
PhabricatorProfileMenuItemConfiguration $config) {
1822
return true;

src/applications/search/engine/PhabricatorProfileMenuEngine.php

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,12 @@ private function loadItems($mode) {
460460
// stored config: it corresponds to an out-of-date or uninstalled
461461
// item.
462462
if (isset($items[$builtin_key])) {
463+
$builtin_item = $items[$builtin_key];
464+
465+
// Copy runtime properties from the builtin item to the stored item.
466+
$stored_item->setIsHeadItem($builtin_item->getIsHeadItem());
467+
$stored_item->setIsTailItem($builtin_item->getIsTailItem());
468+
463469
$items[$builtin_key] = $stored_item;
464470
} else {
465471
continue;
@@ -802,6 +808,7 @@ private function buildItemConfigureContent(array $items) {
802808
->setID($list_id)
803809
->setNoDataString(pht('This menu currently has no items.'));
804810

811+
$any_draggable = false;
805812
foreach ($items as $item) {
806813
$id = $item->getID();
807814
$builtin_key = $item->getBuiltinKey();
@@ -822,14 +829,25 @@ private function buildItemConfigureContent(array $items) {
822829
$view->setHeader($name);
823830
$view->addAttribute($type);
824831

832+
$icon = $item->getMenuItem()->getMenuItemTypeIcon();
833+
if ($icon !== null) {
834+
$view->setStatusIcon($icon);
835+
}
836+
825837
if ($can_edit) {
826-
$view
827-
->setGrippable(true)
828-
->addSigil('profile-menu-item')
829-
->setMetadata(
830-
array(
831-
'key' => nonempty($id, $builtin_key),
832-
));
838+
$can_move = (!$item->getIsHeadItem() && !$item->getIsTailItem());
839+
if ($can_move) {
840+
$view
841+
->setGrippable(true)
842+
->addSigil('profile-menu-item')
843+
->setMetadata(
844+
array(
845+
'key' => nonempty($id, $builtin_key),
846+
));
847+
$any_draggable = true;
848+
} else {
849+
$view->setGrippable(false);
850+
}
833851

834852
if ($id) {
835853
$default_uri = $this->getItemURI("default/{$id}/");
@@ -944,8 +962,16 @@ private function buildItemConfigureContent(array $items) {
944962
->setHeader(pht('Menu Items'))
945963
->setHeaderIcon('fa-list');
946964

965+
$list_header = id(new PHUIHeaderView())
966+
->setHeader(pht('Current Menu Items'));
967+
968+
if ($any_draggable) {
969+
$list_header->setSubheader(
970+
pht('Drag items in this list to reorder them.'));
971+
}
972+
947973
$box = id(new PHUIObjectBoxView())
948-
->setHeaderText(pht('Current Menu Items'))
974+
->setHeader($list_header)
949975
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
950976
->setObjectList($list);
951977

@@ -1190,7 +1216,8 @@ protected function newItem() {
11901216
protected function newManageItem() {
11911217
return $this->newItem()
11921218
->setBuiltinKey(self::ITEM_MANAGE)
1193-
->setMenuItemKey(PhabricatorManageProfileMenuItem::MENUITEMKEY);
1219+
->setMenuItemKey(PhabricatorManageProfileMenuItem::MENUITEMKEY)
1220+
->setIsTailItem(true);
11941221
}
11951222

11961223
public function adjustDefault($key) {

src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ final class PhabricatorLabelProfileMenuItem
77
const FIELD_NAME = 'name';
88

99
public function getMenuItemTypeIcon() {
10-
return 'fa-map-signs';
10+
return 'fa-tag';
1111
}
1212

1313
public function getMenuItemTypeName() {

src/applications/search/menuitem/PhabricatorManageProfileMenuItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ private function getDefaultName() {
1313
return pht('Edit Menu');
1414
}
1515

16+
public function getMenuItemTypeIcon() {
17+
return 'fa-pencil';
18+
}
19+
1620
public function canHideMenuItem(
1721
PhabricatorProfileMenuItemConfiguration $config) {
1822
return false;

src/applications/search/storage/PhabricatorProfileMenuItemConfiguration.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ final class PhabricatorProfileMenuItemConfiguration
1717

1818
private $profileObject = self::ATTACHABLE;
1919
private $menuItem = self::ATTACHABLE;
20+
private $isHeadItem = false;
21+
private $isTailItem = false;
2022

2123
const VISIBILITY_DEFAULT = 'default';
2224
const VISIBILITY_VISIBLE = 'visible';
@@ -158,6 +160,15 @@ public function getSortVector() {
158160
$is_global = 1;
159161
}
160162

163+
// Sort "head" items above other items and "tail" items after other items.
164+
if ($this->getIsHeadItem()) {
165+
$force_position = 0;
166+
} else if ($this->getIsTailItem()) {
167+
$force_position = 2;
168+
} else {
169+
$force_position = 1;
170+
}
171+
161172
// Sort items with an explicit order above items without an explicit order,
162173
// so any newly created builtins go to the bottom.
163174
$order = $this->getMenuItemOrder();
@@ -169,6 +180,7 @@ public function getSortVector() {
169180

170181
return id(new PhutilSortVector())
171182
->addInt($is_global)
183+
->addInt($force_position)
172184
->addInt($has_order)
173185
->addInt((int)$order)
174186
->addInt((int)$this->getID());
@@ -207,6 +219,25 @@ public function newPageContent() {
207219
return $this->getMenuItem()->newPageContent($this);
208220
}
209221

222+
public function setIsHeadItem($is_head_item) {
223+
$this->isHeadItem = $is_head_item;
224+
return $this;
225+
}
226+
227+
public function getIsHeadItem() {
228+
return $this->isHeadItem;
229+
}
230+
231+
public function setIsTailItem($is_tail_item) {
232+
$this->isTailItem = $is_tail_item;
233+
return $this;
234+
}
235+
236+
public function getIsTailItem() {
237+
return $this->isTailItem;
238+
}
239+
240+
210241
/* -( PhabricatorPolicyInterface )----------------------------------------- */
211242

212243

src/view/phui/PHUIObjectItemView.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,14 @@ protected function getTagAttributes() {
330330
Javelin::initBehavior('phui-selectable-list');
331331
}
332332

333-
if ($this->getGrippable()) {
334-
$item_classes[] = 'phui-oi-grippable';
333+
$is_grippable = $this->getGrippable();
334+
if ($is_grippable !== null) {
335+
$item_classes[] = 'phui-oi-has-grip';
336+
if ($is_grippable) {
337+
$item_classes[] = 'phui-oi-grippable';
338+
} else {
339+
$item_classes[] = 'phui-oi-ungrippable';
340+
}
335341
}
336342

337343
if ($this->getImageURI()) {
@@ -580,7 +586,7 @@ protected function getTagContent() {
580586
}
581587

582588
$grippable = null;
583-
if ($this->getGrippable()) {
589+
if ($this->getGrippable() !== null) {
584590
$grippable = phutil_tag(
585591
'div',
586592
array(

webroot/rsrc/css/phui/object-item/phui-oi-list-view.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,15 @@ ul.phui-oi-list-view {
132132
background: url('/rsrc/image/texture/grip.png') center center no-repeat;
133133
}
134134

135+
.phui-oi-ungrippable .phui-oi-grip {
136+
opacity: 0.25;
137+
}
138+
135139
.device .phui-oi-grip {
136140
display: none;
137141
}
138142

139-
.phui-oi-grippable .phui-oi-frame {
143+
.phui-oi-has-grip .phui-oi-frame {
140144
padding-left: 16px;
141145
}
142146

0 commit comments

Comments
 (0)