Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14400143
D17662.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D17662.diff
View Options
diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -7,7 +7,7 @@
*/
return array(
'names' => array(
- 'conpherence.pkg.css' => '82aca405',
+ 'conpherence.pkg.css' => 'b5ee2073',
'conpherence.pkg.js' => '281b1a73',
'core.pkg.css' => '476a4ec7',
'core.pkg.js' => 'fbc1c380',
@@ -47,7 +47,7 @@
'rsrc/css/application/config/unhandled-exception.css' => '4c96257a',
'rsrc/css/application/conpherence/durable-column.css' => '292c71f0',
'rsrc/css/application/conpherence/header-pane.css' => '4082233d',
- 'rsrc/css/application/conpherence/menu.css' => '3d8e5c9c',
+ 'rsrc/css/application/conpherence/menu.css' => '5abfb32d',
'rsrc/css/application/conpherence/message-pane.css' => 'd1fc13e1',
'rsrc/css/application/conpherence/notification.css' => '965db05b',
'rsrc/css/application/conpherence/participant-pane.css' => '604a8b02',
@@ -554,7 +554,7 @@
'config-page-css' => 'c1d5121b',
'conpherence-durable-column-view' => '292c71f0',
'conpherence-header-pane-css' => '4082233d',
- 'conpherence-menu-css' => '3d8e5c9c',
+ 'conpherence-menu-css' => '5abfb32d',
'conpherence-message-pane-css' => 'd1fc13e1',
'conpherence-notification-css' => '965db05b',
'conpherence-participant-pane-css' => '604a8b02',
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2387,6 +2387,7 @@
'PhabricatorConpherenceColumnVisibleSetting' => 'applications/settings/setting/PhabricatorConpherenceColumnVisibleSetting.php',
'PhabricatorConpherenceNotificationsSetting' => 'applications/settings/setting/PhabricatorConpherenceNotificationsSetting.php',
'PhabricatorConpherencePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorConpherencePreferencesSettingsPanel.php',
+ 'PhabricatorConpherenceProfileMenuItem' => 'applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php',
'PhabricatorConpherenceThreadPHIDType' => 'applications/conpherence/phid/PhabricatorConpherenceThreadPHIDType.php',
'PhabricatorConpherenceWidgetVisibleSetting' => 'applications/settings/setting/PhabricatorConpherenceWidgetVisibleSetting.php',
'PhabricatorConsoleApplication' => 'applications/console/application/PhabricatorConsoleApplication.php',
@@ -7473,6 +7474,7 @@
'PhabricatorConpherenceColumnVisibleSetting' => 'PhabricatorInternalSetting',
'PhabricatorConpherenceNotificationsSetting' => 'PhabricatorSelectSetting',
'PhabricatorConpherencePreferencesSettingsPanel' => 'PhabricatorEditEngineSettingsPanel',
+ 'PhabricatorConpherenceProfileMenuItem' => 'PhabricatorProfileMenuItem',
'PhabricatorConpherenceThreadPHIDType' => 'PhabricatorPHIDType',
'PhabricatorConpherenceWidgetVisibleSetting' => 'PhabricatorInternalSetting',
'PhabricatorConsoleApplication' => 'PhabricatorApplication',
diff --git a/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
new file mode 100644
--- /dev/null
+++ b/src/applications/search/menuitem/PhabricatorConpherenceProfileMenuItem.php
@@ -0,0 +1,174 @@
+<?php
+
+final class PhabricatorConpherenceProfileMenuItem
+ extends PhabricatorProfileMenuItem {
+
+ const MENUITEMKEY = 'conpherence';
+ const FIELD_CONPHERENCE = 'conpherence';
+
+ private $conpherence;
+
+ public function getMenuItemTypeIcon() {
+ return 'fa-comments';
+ }
+
+ public function getMenuItemTypeName() {
+ return pht('Conpherence');
+ }
+
+ public function canAddToObject($object) {
+ return true;
+ }
+
+ public function attachConpherence($conpherence) {
+ $this->conpherence = $conpherence;
+ return $this;
+ }
+
+ public function getConpherence() {
+ $conpherence = $this->conpherence;
+
+ if (!$conpherence) {
+ return null;
+ }
+
+ return $conpherence;
+ }
+
+ public function willBuildNavigationItems(array $items) {
+ require_celerity_resource('conpherence-menu-css');
+ $viewer = $this->getViewer();
+ $room_phids = array();
+ foreach ($items as $item) {
+ $room_phids[] = $item->getMenuItemProperty('conpherence');
+ }
+
+ $rooms = id(new ConpherenceThreadQuery())
+ ->setViewer($viewer)
+ ->withPHIDs($room_phids)
+ ->needParticipantCache(true)
+ ->needProfileImage(true)
+ ->execute();
+
+ $rooms = mpull($rooms, null, 'getPHID');
+ foreach ($items as $item) {
+ $room_phid = $item->getMenuItemProperty('conpherence');
+ $room = idx($rooms, $room_phid, null);
+ $item->getMenuItem()->attachConpherence($room);
+ }
+ }
+
+ public function getDisplayName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ $room = $this->getConpherence($config);
+ if (!$room) {
+ return pht('(Restricted/Invalid Conpherence)');
+ }
+
+ $name = $this->getName($config);
+ if (strlen($name)) {
+ return $name;
+ }
+
+ return $room->getTitle();
+ }
+
+ public function buildEditEngineFields(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return array(
+ id(new PhabricatorDatasourceEditField())
+ ->setKey(self::FIELD_CONPHERENCE)
+ ->setLabel(pht('Conpherence Room'))
+ ->setDatasource(new ConpherenceThreadDatasource())
+ ->setIsRequired(true)
+ ->setSingleValue($config->getMenuItemProperty('conpherence')),
+ id(new PhabricatorTextEditField())
+ ->setKey('name')
+ ->setLabel(pht('Name'))
+ ->setValue($this->getName($config)),
+ );
+ }
+
+ private function getName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return $config->getMenuItemProperty('name');
+ }
+
+ protected function newNavigationMenuItems(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ $viewer = $this->getViewer();
+ $room = $this->getConpherence($config);
+ if (!$room) {
+ return array();
+ }
+
+ $data = $room->getDisplayData($viewer);
+ $unread_count = $data['unread_count'];
+
+ $count = null;
+ if ($unread_count) {
+ $count = phutil_tag(
+ 'span',
+ array(
+ 'class' => 'conpherence-menu-item-count',
+ ),
+ $unread_count);
+ }
+
+ $item = $this->newItem()
+ ->setHref('/'.$room->getMonogram())
+ ->setName($this->getDisplayName($config))
+ ->setIcon('fa-comments')
+ ->appendChild($count);
+
+ return array(
+ $item,
+ );
+ }
+
+ public function validateTransactions(
+ PhabricatorProfileMenuItemConfiguration $config,
+ $field_key,
+ $value,
+ array $xactions) {
+
+ $viewer = $this->getViewer();
+ $errors = array();
+
+ if ($field_key == self::FIELD_CONPHERENCE) {
+ if ($this->isEmptyTransaction($value, $xactions)) {
+ $errors[] = $this->newRequiredError(
+ pht('You must choose a room.'),
+ $field_key);
+ }
+
+ foreach ($xactions as $xaction) {
+ $new = $xaction['new'];
+
+ if (!$new) {
+ continue;
+ }
+
+ if ($new === $value) {
+ continue;
+ }
+
+ $rooms = id(new ConpherenceThreadQuery())
+ ->setViewer($viewer)
+ ->withPHIDs(array($new))
+ ->execute();
+ if (!$rooms) {
+ $errors[] = $this->newInvalidError(
+ pht(
+ 'Room "%s" is not a valid room which you have '.
+ 'permission to see.',
+ $new),
+ $xaction['xaction']);
+ }
+ }
+ }
+
+ return $errors;
+ }
+
+}
diff --git a/webroot/rsrc/css/application/conpherence/menu.css b/webroot/rsrc/css/application/conpherence/menu.css
--- a/webroot/rsrc/css/application/conpherence/menu.css
+++ b/webroot/rsrc/css/application/conpherence/menu.css
@@ -167,7 +167,8 @@
}
.conpherence-menu .conpherence-menu-item-view
-.conpherence-menu-item-unread-count {
+.conpherence-menu-item-unread-count,
+.conpherence-menu-item-count {
position: absolute;
right: 4px;
top: 10px;
@@ -179,6 +180,11 @@
font-size: {$smallestfontsize};
}
+.phui-list-item-view .conpherence-menu-item-count {
+ right: 7px;
+ top: 7px;
+}
+
.conpherence-menu .hide-unread-count .conpherence-menu-item-unread-count,
.conpherence-menu .conpherence-selected .conpherence-menu-item-unread-count {
display: none;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 6:45 PM (14 h, 15 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6921812
Default Alt Text
D17662.diff (8 KB)
Attached To
Mode
D17662: Add a Conpherence Profile Menu Item
Attached
Detach File
Event Timeline
Log In to Comment