diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 099bafaee6..31aa572174 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -7,7 +7,7 @@ */ return array( 'names' => array( - 'core.pkg.css' => '6d8c526d', + 'core.pkg.css' => '8378907a', 'core.pkg.js' => 'c60f35d8', 'darkconsole.pkg.js' => 'e7393ebb', 'differential.pkg.css' => '2de124c9', @@ -131,7 +131,7 @@ return array( 'rsrc/css/phui/phui-document.css' => 'a4a1c3b9', 'rsrc/css/phui/phui-feed-story.css' => 'b7b26d23', 'rsrc/css/phui/phui-fontkit.css' => '9cda225e', - 'rsrc/css/phui/phui-form-view.css' => 'c1d2ef29', + 'rsrc/css/phui/phui-form-view.css' => 'cf7da606', 'rsrc/css/phui/phui-form.css' => 'afdb2c6e', 'rsrc/css/phui/phui-header-view.css' => '55bb32dd', 'rsrc/css/phui/phui-icon.css' => 'b0a6b1b6', @@ -464,7 +464,7 @@ return array( 'rsrc/js/core/behavior-active-nav.js' => 'e379b58e', 'rsrc/js/core/behavior-audio-source.js' => '59b251eb', 'rsrc/js/core/behavior-autofocus.js' => '7319e029', - 'rsrc/js/core/behavior-choose-control.js' => '6153c708', + 'rsrc/js/core/behavior-choose-control.js' => 'dfaafb14', 'rsrc/js/core/behavior-crop.js' => 'fa0f4fc2', 'rsrc/js/core/behavior-dark-console.js' => 'f411b6ae', 'rsrc/js/core/behavior-device.js' => 'a205cf28', @@ -570,7 +570,7 @@ return array( 'javelin-behavior-audio-source' => '59b251eb', 'javelin-behavior-audit-preview' => 'd835b03a', 'javelin-behavior-bulk-job-reload' => 'edf8a145', - 'javelin-behavior-choose-control' => '6153c708', + 'javelin-behavior-choose-control' => 'dfaafb14', 'javelin-behavior-comment-actions' => 'bb0d2d0c', 'javelin-behavior-config-reorder-fields' => 'b6993408', 'javelin-behavior-conpherence-drag-and-drop-photo' => 'cf86d16a', @@ -805,7 +805,7 @@ return array( 'phui-font-icon-base-css' => 'ecbbb4c2', 'phui-fontkit-css' => '9cda225e', 'phui-form-css' => 'afdb2c6e', - 'phui-form-view-css' => 'c1d2ef29', + 'phui-form-view-css' => 'cf7da606', 'phui-header-view-css' => '55bb32dd', 'phui-icon-view-css' => 'b0a6b1b6', 'phui-image-mask-css' => '5a8b09c8', @@ -1266,12 +1266,6 @@ return array( 'javelin-stratcom', 'javelin-dom', ), - '6153c708' => array( - 'javelin-behavior', - 'javelin-stratcom', - 'javelin-dom', - 'javelin-workflow', - ), '61cbc29a' => array( 'javelin-magical-init', 'javelin-util', @@ -1890,6 +1884,12 @@ return array( 'df5e11d2' => array( 'javelin-install', ), + 'dfaafb14' => array( + 'javelin-behavior', + 'javelin-stratcom', + 'javelin-dom', + 'javelin-workflow', + ), 'e10f8e18' => array( 'javelin-behavior', 'javelin-dom', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ad5f8f8c3e..6ea90408e9 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -114,7 +114,6 @@ phutil_register_library_map(array( 'AphrontException' => 'aphront/exception/AphrontException.php', 'AphrontFileResponse' => 'aphront/response/AphrontFileResponse.php', 'AphrontFormCheckboxControl' => 'view/form/control/AphrontFormCheckboxControl.php', - 'AphrontFormChooseButtonControl' => 'view/form/control/AphrontFormChooseButtonControl.php', 'AphrontFormControl' => 'view/form/control/AphrontFormControl.php', 'AphrontFormDateControl' => 'view/form/control/AphrontFormDateControl.php', 'AphrontFormDateControlValue' => 'view/form/control/AphrontFormDateControlValue.php', @@ -1474,6 +1473,7 @@ phutil_register_library_map(array( 'PHUIFeedStoryView' => 'view/phui/PHUIFeedStoryView.php', 'PHUIFormDividerControl' => 'view/form/control/PHUIFormDividerControl.php', 'PHUIFormFreeformDateControl' => 'view/form/control/PHUIFormFreeformDateControl.php', + 'PHUIFormIconSetControl' => 'view/form/control/PHUIFormIconSetControl.php', 'PHUIFormInsetView' => 'view/form/PHUIFormInsetView.php', 'PHUIFormLayoutView' => 'view/form/PHUIFormLayoutView.php', 'PHUIFormMultiSubmitControl' => 'view/form/control/PHUIFormMultiSubmitControl.php', @@ -1774,10 +1774,9 @@ phutil_register_library_map(array( 'PhabricatorBadgesDAO' => 'applications/badges/storage/PhabricatorBadgesDAO.php', 'PhabricatorBadgesDefaultEditCapability' => 'applications/badges/capability/PhabricatorBadgesDefaultEditCapability.php', 'PhabricatorBadgesEditController' => 'applications/badges/controller/PhabricatorBadgesEditController.php', - 'PhabricatorBadgesEditIconController' => 'applications/badges/controller/PhabricatorBadgesEditIconController.php', 'PhabricatorBadgesEditRecipientsController' => 'applications/badges/controller/PhabricatorBadgesEditRecipientsController.php', 'PhabricatorBadgesEditor' => 'applications/badges/editor/PhabricatorBadgesEditor.php', - 'PhabricatorBadgesIcon' => 'applications/badges/icon/PhabricatorBadgesIcon.php', + 'PhabricatorBadgesIconSet' => 'applications/badges/icon/PhabricatorBadgesIconSet.php', 'PhabricatorBadgesListController' => 'applications/badges/controller/PhabricatorBadgesListController.php', 'PhabricatorBadgesMailReceiver' => 'applications/badges/mail/PhabricatorBadgesMailReceiver.php', 'PhabricatorBadgesPHIDType' => 'applications/badges/phid/PhabricatorBadgesPHIDType.php', @@ -1833,7 +1832,6 @@ phutil_register_library_map(array( 'PhabricatorCalendarEventCommentController' => 'applications/calendar/controller/PhabricatorCalendarEventCommentController.php', 'PhabricatorCalendarEventDragController' => 'applications/calendar/controller/PhabricatorCalendarEventDragController.php', 'PhabricatorCalendarEventEditController' => 'applications/calendar/controller/PhabricatorCalendarEventEditController.php', - 'PhabricatorCalendarEventEditIconController' => 'applications/calendar/controller/PhabricatorCalendarEventEditIconController.php', 'PhabricatorCalendarEventEditor' => 'applications/calendar/editor/PhabricatorCalendarEventEditor.php', 'PhabricatorCalendarEventEmailCommand' => 'applications/calendar/command/PhabricatorCalendarEventEmailCommand.php', 'PhabricatorCalendarEventInvitee' => 'applications/calendar/storage/PhabricatorCalendarEventInvitee.php', @@ -1852,7 +1850,7 @@ phutil_register_library_map(array( 'PhabricatorCalendarEventViewController' => 'applications/calendar/controller/PhabricatorCalendarEventViewController.php', 'PhabricatorCalendarHoliday' => 'applications/calendar/storage/PhabricatorCalendarHoliday.php', 'PhabricatorCalendarHolidayTestCase' => 'applications/calendar/storage/__tests__/PhabricatorCalendarHolidayTestCase.php', - 'PhabricatorCalendarIcon' => 'applications/calendar/icon/PhabricatorCalendarIcon.php', + 'PhabricatorCalendarIconSet' => 'applications/calendar/icon/PhabricatorCalendarIconSet.php', 'PhabricatorCalendarRemarkupRule' => 'applications/calendar/remarkup/PhabricatorCalendarRemarkupRule.php', 'PhabricatorCalendarReplyHandler' => 'applications/calendar/mail/PhabricatorCalendarReplyHandler.php', 'PhabricatorCalendarSchemaSpec' => 'applications/calendar/storage/PhabricatorCalendarSchemaSpec.php', @@ -2263,6 +2261,7 @@ phutil_register_library_map(array( 'PhabricatorFileEditor' => 'applications/files/editor/PhabricatorFileEditor.php', 'PhabricatorFileFilePHIDType' => 'applications/files/phid/PhabricatorFileFilePHIDType.php', 'PhabricatorFileHasObjectEdgeType' => 'applications/files/edge/PhabricatorFileHasObjectEdgeType.php', + 'PhabricatorFileIconSetSelectController' => 'applications/files/controller/PhabricatorFileIconSetSelectController.php', 'PhabricatorFileImageMacro' => 'applications/macro/storage/PhabricatorFileImageMacro.php', 'PhabricatorFileImageTransform' => 'applications/files/transform/PhabricatorFileImageTransform.php', 'PhabricatorFileInfoController' => 'applications/files/controller/PhabricatorFileInfoController.php', @@ -2359,6 +2358,8 @@ phutil_register_library_map(array( 'PhabricatorIDsSearchField' => 'applications/search/field/PhabricatorIDsSearchField.php', 'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php', 'PhabricatorIconRemarkupRule' => 'applications/macro/markup/PhabricatorIconRemarkupRule.php', + 'PhabricatorIconSet' => 'applications/files/iconset/PhabricatorIconSet.php', + 'PhabricatorIconSetIcon' => 'applications/files/iconset/PhabricatorIconSetIcon.php', 'PhabricatorImageMacroRemarkupRule' => 'applications/macro/markup/PhabricatorImageMacroRemarkupRule.php', 'PhabricatorImageTransformer' => 'applications/files/PhabricatorImageTransformer.php', 'PhabricatorImagemagickSetupCheck' => 'applications/config/check/PhabricatorImagemagickSetupCheck.php', @@ -2809,12 +2810,11 @@ phutil_register_library_map(array( 'PhabricatorProjectDatasource' => 'applications/project/typeahead/PhabricatorProjectDatasource.php', 'PhabricatorProjectDescriptionField' => 'applications/project/customfield/PhabricatorProjectDescriptionField.php', 'PhabricatorProjectEditDetailsController' => 'applications/project/controller/PhabricatorProjectEditDetailsController.php', - 'PhabricatorProjectEditIconController' => 'applications/project/controller/PhabricatorProjectEditIconController.php', 'PhabricatorProjectEditPictureController' => 'applications/project/controller/PhabricatorProjectEditPictureController.php', 'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php', 'PhabricatorProjectFeedController' => 'applications/project/controller/PhabricatorProjectFeedController.php', 'PhabricatorProjectHeraldAction' => 'applications/project/herald/PhabricatorProjectHeraldAction.php', - 'PhabricatorProjectIcon' => 'applications/project/icon/PhabricatorProjectIcon.php', + 'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php', 'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php', 'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php', 'PhabricatorProjectLogicalAndDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalAndDatasource.php', @@ -3973,7 +3973,6 @@ phutil_register_library_map(array( 'AphrontException' => 'Exception', 'AphrontFileResponse' => 'AphrontResponse', 'AphrontFormCheckboxControl' => 'AphrontFormControl', - 'AphrontFormChooseButtonControl' => 'AphrontFormControl', 'AphrontFormControl' => 'AphrontView', 'AphrontFormDateControl' => 'AphrontFormControl', 'AphrontFormDateControlValue' => 'Phobject', @@ -5527,6 +5526,7 @@ phutil_register_library_map(array( 'PHUIFeedStoryView' => 'AphrontView', 'PHUIFormDividerControl' => 'AphrontFormControl', 'PHUIFormFreeformDateControl' => 'AphrontFormControl', + 'PHUIFormIconSetControl' => 'AphrontFormControl', 'PHUIFormInsetView' => 'AphrontView', 'PHUIFormLayoutView' => 'AphrontView', 'PHUIFormMultiSubmitControl' => 'AphrontFormControl', @@ -5873,10 +5873,9 @@ phutil_register_library_map(array( 'PhabricatorBadgesDAO' => 'PhabricatorLiskDAO', 'PhabricatorBadgesDefaultEditCapability' => 'PhabricatorPolicyCapability', 'PhabricatorBadgesEditController' => 'PhabricatorBadgesController', - 'PhabricatorBadgesEditIconController' => 'PhabricatorBadgesController', 'PhabricatorBadgesEditRecipientsController' => 'PhabricatorBadgesController', 'PhabricatorBadgesEditor' => 'PhabricatorApplicationTransactionEditor', - 'PhabricatorBadgesIcon' => 'Phobject', + 'PhabricatorBadgesIconSet' => 'PhabricatorIconSet', 'PhabricatorBadgesListController' => 'PhabricatorBadgesController', 'PhabricatorBadgesMailReceiver' => 'PhabricatorObjectMailReceiver', 'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType', @@ -5944,7 +5943,6 @@ phutil_register_library_map(array( 'PhabricatorCalendarEventCommentController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventDragController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventEditController' => 'PhabricatorCalendarController', - 'PhabricatorCalendarEventEditIconController' => 'PhabricatorCalendarController', 'PhabricatorCalendarEventEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorCalendarEventEmailCommand' => 'MetaMTAEmailTransactionCommand', 'PhabricatorCalendarEventInvitee' => array( @@ -5966,7 +5964,7 @@ phutil_register_library_map(array( 'PhabricatorCalendarEventViewController' => 'PhabricatorCalendarController', 'PhabricatorCalendarHoliday' => 'PhabricatorCalendarDAO', 'PhabricatorCalendarHolidayTestCase' => 'PhabricatorTestCase', - 'PhabricatorCalendarIcon' => 'Phobject', + 'PhabricatorCalendarIconSet' => 'PhabricatorIconSet', 'PhabricatorCalendarRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'PhabricatorCalendarReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 'PhabricatorCalendarSchemaSpec' => 'PhabricatorConfigSchemaSpec', @@ -6452,6 +6450,7 @@ phutil_register_library_map(array( 'PhabricatorFileEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorFileFilePHIDType' => 'PhabricatorPHIDType', 'PhabricatorFileHasObjectEdgeType' => 'PhabricatorEdgeType', + 'PhabricatorFileIconSetSelectController' => 'PhabricatorFileController', 'PhabricatorFileImageMacro' => array( 'PhabricatorFileDAO', 'PhabricatorSubscribableInterface', @@ -6563,6 +6562,8 @@ phutil_register_library_map(array( 'PhabricatorIDsSearchField' => 'PhabricatorSearchField', 'PhabricatorIRCProtocolAdapter' => 'PhabricatorProtocolAdapter', 'PhabricatorIconRemarkupRule' => 'PhutilRemarkupRule', + 'PhabricatorIconSet' => 'Phobject', + 'PhabricatorIconSetIcon' => 'Phobject', 'PhabricatorImageMacroRemarkupRule' => 'PhutilRemarkupRule', 'PhabricatorImageTransformer' => 'Phobject', 'PhabricatorImagemagickSetupCheck' => 'PhabricatorSetupCheck', @@ -7095,12 +7096,11 @@ phutil_register_library_map(array( 'PhabricatorProjectDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorProjectDescriptionField' => 'PhabricatorProjectStandardCustomField', 'PhabricatorProjectEditDetailsController' => 'PhabricatorProjectController', - 'PhabricatorProjectEditIconController' => 'PhabricatorProjectController', 'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController', 'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase', 'PhabricatorProjectFeedController' => 'PhabricatorProjectController', 'PhabricatorProjectHeraldAction' => 'HeraldAction', - 'PhabricatorProjectIcon' => 'Phobject', + 'PhabricatorProjectIconSet' => 'PhabricatorIconSet', 'PhabricatorProjectListController' => 'PhabricatorProjectController', 'PhabricatorProjectLogicalAndDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'PhabricatorProjectLogicalDatasource' => 'PhabricatorTypeaheadCompositeDatasource', diff --git a/src/applications/badges/application/PhabricatorBadgesApplication.php b/src/applications/badges/application/PhabricatorBadgesApplication.php index 3573af2419..dea41ac244 100644 --- a/src/applications/badges/application/PhabricatorBadgesApplication.php +++ b/src/applications/badges/application/PhabricatorBadgesApplication.php @@ -49,10 +49,6 @@ final class PhabricatorBadgesApplication extends PhabricatorApplication { => 'PhabricatorBadgesArchiveController', 'view/(?:(?P\d+)/)?' => 'PhabricatorBadgesViewController', - 'icon/(?P[1-9]\d*)/' - => 'PhabricatorBadgesEditIconController', - 'icon/' - => 'PhabricatorBadgesEditIconController', 'recipients/(?P[1-9]\d*)/' => 'PhabricatorBadgesEditRecipientsController', 'recipients/(?P[1-9]\d*)/remove/' diff --git a/src/applications/badges/controller/PhabricatorBadgesEditController.php b/src/applications/badges/controller/PhabricatorBadgesEditController.php index 9a82940aad..b1a4fb1030 100644 --- a/src/applications/badges/controller/PhabricatorBadgesEditController.php +++ b/src/applications/badges/controller/PhabricatorBadgesEditController.php @@ -111,13 +111,6 @@ final class PhabricatorBadgesEditController } } - if ($is_new) { - $icon_uri = $this->getApplicationURI('icon/'); - } else { - $icon_uri = $this->getApplicationURI('icon/'.$badge->getID().'/'); - } - $icon_display = PhabricatorBadgesIcon::renderIconForChooser($v_icon); - $policies = id(new PhabricatorPolicyQuery()) ->setViewer($viewer) ->setObject($badge) @@ -137,12 +130,10 @@ final class PhabricatorBadgesEditController ->setLabel(pht('Flavor Text')) ->setValue($v_flav)) ->appendChild( - id(new AphrontFormChooseButtonControl()) + id(new PHUIFormIconSetControl()) ->setLabel(pht('Icon')) ->setName('icon') - ->setDisplayValue($icon_display) - ->setButtonText(pht('Choose Icon...')) - ->setChooseURI($icon_uri) + ->setIconSet(new PhabricatorBadgesIconSet()) ->setValue($v_icon)) ->appendChild( id(new AphrontFormSelectControl()) diff --git a/src/applications/badges/controller/PhabricatorBadgesEditIconController.php b/src/applications/badges/controller/PhabricatorBadgesEditIconController.php deleted file mode 100644 index 3ac6bfb024..0000000000 --- a/src/applications/badges/controller/PhabricatorBadgesEditIconController.php +++ /dev/null @@ -1,101 +0,0 @@ -getViewer(); - $id = $request->getURIData('id'); - - if ($id) { - $badge = id(new PhabricatorBadgesQuery()) - ->setViewer($viewer) - ->withIDs(array($id)) - ->requireCapabilities( - array( - PhabricatorPolicyCapability::CAN_VIEW, - PhabricatorPolicyCapability::CAN_EDIT, - )) - ->executeOne(); - if (!$badge) { - return new Aphront404Response(); - } - $cancel_uri = - $this->getApplicationURI('view/'.$badge->getID().'/'); - $badge_icon = $badge->getIcon(); - } else { - $this->requireApplicationCapability( - PhabricatorBadgesCreateCapability::CAPABILITY); - - $cancel_uri = '/badges/'; - $badge_icon = $request->getStr('value'); - } - - require_celerity_resource('project-icon-css'); - Javelin::initBehavior('phabricator-tooltips'); - - $badge_icons = PhabricatorBadgesIcon::getIconMap(); - - if ($request->isFormPost()) { - $v_icon = $request->getStr('icon'); - - return id(new AphrontAjaxResponse())->setContent( - array( - 'value' => $v_icon, - 'display' => PhabricatorBadgesIcon::renderIconForChooser($v_icon), - )); - } - - $ii = 0; - $buttons = array(); - foreach ($badge_icons as $icon => $label) { - $view = id(new PHUIIconView()) - ->setIconFont($icon); - - $aural = javelin_tag( - 'span', - array( - 'aural' => true, - ), - pht('Choose "%s" Icon', $label)); - - if ($icon == $badge_icon) { - $class_extra = ' selected'; - } else { - $class_extra = null; - } - - $buttons[] = javelin_tag( - 'button', - array( - 'class' => 'icon-button'.$class_extra, - 'name' => 'icon', - 'value' => $icon, - 'type' => 'submit', - 'sigil' => 'has-tooltip', - 'meta' => array( - 'tip' => $label, - ), - ), - array( - $aural, - $view, - )); - if ((++$ii % 4) == 0) { - $buttons[] = phutil_tag('br'); - } - } - - $buttons = phutil_tag( - 'div', - array( - 'class' => 'icon-grid', - ), - $buttons); - - return $this->newDialog() - ->setTitle(pht('Choose Badge Icon')) - ->appendChild($buttons) - ->addCancelButton($cancel_uri); - } -} diff --git a/src/applications/badges/controller/PhabricatorBadgesViewController.php b/src/applications/badges/controller/PhabricatorBadgesViewController.php index 11dbcfda8b..81241edd9f 100644 --- a/src/applications/badges/controller/PhabricatorBadgesViewController.php +++ b/src/applications/badges/controller/PhabricatorBadgesViewController.php @@ -85,7 +85,6 @@ final class PhabricatorBadgesViewController ->setObject($badge); $quality = idx($badge->getQualityNameMap(), $badge->getQuality()); - $icon = idx($badge->getIconNameMap(), $badge->getIcon()); $view->addProperty( pht('Quality'), @@ -93,7 +92,8 @@ final class PhabricatorBadgesViewController $view->addProperty( pht('Icon'), - $icon); + id(new PhabricatorBadgesIconSet()) + ->getIconLabel($badge->getIcon())); $view->addProperty( pht('Flavor'), diff --git a/src/applications/badges/icon/PhabricatorBadgesIcon.php b/src/applications/badges/icon/PhabricatorBadgesIcon.php deleted file mode 100644 index 9f47c782e5..0000000000 --- a/src/applications/badges/icon/PhabricatorBadgesIcon.php +++ /dev/null @@ -1,53 +0,0 @@ - pht('Superstar'), - 'fa-user' => pht('Average Person'), - 'fa-bug' => pht('Ladybug'), - 'fa-users' => pht('Triplets'), - - 'fa-book' => pht('Nominomicon'), - 'fa-rocket' => pht('Escape Route'), - 'fa-life-ring' => pht('Foam Circle'), - 'fa-birthday-cake' => pht('Cake Day'), - - 'fa-camera-retro' => pht('Leica Enthusiast'), - 'fa-beer' => pht('Liquid Lunch'), - 'fa-gift' => pht('Free Stuff'), - 'fa-eye' => pht('Eye See You'), - - 'fa-heart' => pht('Love is Love'), - 'fa-trophy' => pht('Winner at Things'), - 'fa-umbrella' => pht('Rain Defender'), - 'fa-graduation-cap' => pht('In Debt'), - - ); - } - - public static function getLabel($key) { - $map = self::getIconMap(); - return $map[$key]; - } - - public static function getAPIName($key) { - return substr($key, 3); - } - - public static function renderIconForChooser($icon) { - $badge_icons = self::getIconMap(); - - return phutil_tag( - 'span', - array(), - array( - id(new PHUIIconView())->setIconFont($icon), - ' ', - idx($badge_icons, $icon, pht('Unknown Icon')), - )); - } - -} diff --git a/src/applications/badges/icon/PhabricatorBadgesIconSet.php b/src/applications/badges/icon/PhabricatorBadgesIconSet.php new file mode 100644 index 0000000000..2c6742a135 --- /dev/null +++ b/src/applications/badges/icon/PhabricatorBadgesIconSet.php @@ -0,0 +1,45 @@ + pht('Superstar'), + 'fa-user' => pht('Average Person'), + 'fa-bug' => pht('Ladybug'), + 'fa-users' => pht('Triplets'), + + 'fa-book' => pht('Nominomicon'), + 'fa-rocket' => pht('Escape Route'), + 'fa-life-ring' => pht('Foam Circle'), + 'fa-birthday-cake' => pht('Cake Day'), + + 'fa-camera-retro' => pht('Leica Enthusiast'), + 'fa-beer' => pht('Liquid Lunch'), + 'fa-gift' => pht('Free Stuff'), + 'fa-eye' => pht('Eye See You'), + + 'fa-heart' => pht('Love is Love'), + 'fa-trophy' => pht('Winner at Things'), + 'fa-umbrella' => pht('Rain Defender'), + 'fa-graduation-cap' => pht('In Debt'), + ); + + $icons = array(); + foreach ($map as $key => $label) { + $icons[] = id(new PhabricatorIconSetIcon()) + ->setKey($key) + ->setLabel($label); + } + + return $icons; + } + +} diff --git a/src/applications/badges/storage/PhabricatorBadgesBadge.php b/src/applications/badges/storage/PhabricatorBadgesBadge.php index 9f789782b3..f6ff495a6e 100644 --- a/src/applications/badges/storage/PhabricatorBadgesBadge.php +++ b/src/applications/badges/storage/PhabricatorBadgesBadge.php @@ -54,10 +54,6 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO ); } - public static function getIconNameMap() { - return PhabricatorBadgesIcon::getIconMap(); - } - public static function initializeNewBadge(PhabricatorUser $actor) { $app = id(new PhabricatorApplicationQuery()) ->setViewer($actor) diff --git a/src/applications/badges/storage/PhabricatorBadgesTransaction.php b/src/applications/badges/storage/PhabricatorBadgesTransaction.php index 0c7bb5183a..c2e934390d 100644 --- a/src/applications/badges/storage/PhabricatorBadgesTransaction.php +++ b/src/applications/badges/storage/PhabricatorBadgesTransaction.php @@ -78,9 +78,11 @@ final class PhabricatorBadgesTransaction $this->renderHandleLink($author_phid), $new); } else { - $icon_map = PhabricatorBadgesBadge::getIconNameMap(); - $icon_new = idx($icon_map, $new, $new); - $icon_old = idx($icon_map, $old, $old); + $set = new PhabricatorBadgesIconSet(); + + $icon_old = $set->getIconLabel($old); + $icon_new = $set->getIconLabel($new); + return pht( '%s updated the icon for this badge from "%s" to "%s".', $this->renderHandleLink($author_phid), diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php index 0197ec8f02..1f8ea57383 100644 --- a/src/applications/calendar/application/PhabricatorCalendarApplication.php +++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php @@ -46,10 +46,6 @@ final class PhabricatorCalendarApplication extends PhabricatorApplication { '(?:query/(?P[^/]+)/(?:(?P\d+)/'. '(?P\d+)/)?(?:(?P\d+)/)?)?' => 'PhabricatorCalendarEventListController', - 'icon/(?P[1-9]\d*)/' - => 'PhabricatorCalendarEventEditIconController', - 'icon/' - => 'PhabricatorCalendarEventEditIconController', 'event/' => array( 'create/' => 'PhabricatorCalendarEventEditController', diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php index e55b0debaa..389d7b7358 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventEditController.php @@ -499,18 +499,11 @@ final class PhabricatorCalendarEventEditController ->setUser($viewer) ->setDatasource(new PhabricatorMetaMTAMailableDatasource()); - if ($this->isCreate()) { - $icon_uri = $this->getApplicationURI('icon/'); - } else { - $icon_uri = $this->getApplicationURI('icon/'.$event->getID().'/'); - } - $icon_display = PhabricatorCalendarIcon::renderIconForChooser($icon); - $icon = id(new AphrontFormChooseButtonControl()) + + $icon = id(new PHUIFormIconSetControl()) ->setLabel(pht('Icon')) ->setName('icon') - ->setDisplayValue($icon_display) - ->setButtonText(pht('Choose Icon...')) - ->setChooseURI($icon_uri) + ->setIconSet(new PhabricatorCalendarIconSet()) ->setValue($icon); $form = id(new AphrontFormView()) diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventEditIconController.php b/src/applications/calendar/controller/PhabricatorCalendarEventEditIconController.php deleted file mode 100644 index e93baa52bd..0000000000 --- a/src/applications/calendar/controller/PhabricatorCalendarEventEditIconController.php +++ /dev/null @@ -1,97 +0,0 @@ -getUser(); - $id = $request->getURIData('id'); - - if ($id) { - $event = id(new PhabricatorCalendarEventQuery()) - ->setViewer($viewer) - ->withIDs(array($id)) - ->requireCapabilities( - array( - PhabricatorPolicyCapability::CAN_VIEW, - PhabricatorPolicyCapability::CAN_EDIT, - )) - ->executeOne(); - if (!$event) { - return new Aphront404Response(); - } - $cancel_uri = $this->getApplicationURI('/E'.$event->getID()); - $event_icon = $event->getIcon(); - } else { - $cancel_uri = '/calendar/'; - $event_icon = $request->getStr('value'); - } - - require_celerity_resource('calendar-icon-css'); - Javelin::initBehavior('phabricator-tooltips'); - - $calendar_icons = PhabricatorCalendarIcon::getIconMap(); - - if ($request->isFormPost()) { - $v_icon = $request->getStr('icon'); - - return id(new AphrontAjaxResponse())->setContent( - array( - 'value' => $v_icon, - 'display' => PhabricatorCalendarIcon::renderIconForChooser($v_icon), - )); - } - - $ii = 0; - $buttons = array(); - foreach ($calendar_icons as $icon => $label) { - $view = id(new PHUIIconView()) - ->setIconFont($icon); - - $aural = javelin_tag( - 'span', - array( - 'aural' => true, - ), - pht('Choose "%s" Icon', $label)); - - if ($icon == $event_icon) { - $class_extra = ' selected'; - } else { - $class_extra = null; - } - - $buttons[] = javelin_tag( - 'button', - array( - 'class' => 'icon-button'.$class_extra, - 'name' => 'icon', - 'value' => $icon, - 'type' => 'submit', - 'sigil' => 'has-tooltip', - 'meta' => array( - 'tip' => $label, - ), - ), - array( - $aural, - $view, - )); - if ((++$ii % 4) == 0) { - $buttons[] = phutil_tag('br'); - } - } - - $buttons = phutil_tag( - 'div', - array( - 'class' => 'icon-grid', - ), - $buttons); - - return $this->newDialog() - ->setTitle(pht('Choose Calendar Event Icon')) - ->appendChild($buttons) - ->addCancelButton($cancel_uri); - } -} diff --git a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php index a0d5be4e4d..d6a37651e6 100644 --- a/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php +++ b/src/applications/calendar/controller/PhabricatorCalendarEventViewController.php @@ -360,11 +360,10 @@ final class PhabricatorCalendarEventViewController $properties->invokeWillRenderEvent(); - $icon_display = PhabricatorCalendarIcon::renderIconForChooser( - $event->getIcon()); $properties->addProperty( pht('Icon'), - $icon_display); + id(new PhabricatorCalendarIconSet()) + ->getIconLabel($event->getIcon())); if (strlen($event->getDescription())) { $description = PhabricatorMarkupEngine::renderOneObject( diff --git a/src/applications/calendar/icon/PhabricatorCalendarIcon.php b/src/applications/calendar/icon/PhabricatorCalendarIcon.php deleted file mode 100644 index 9ba4b00c01..0000000000 --- a/src/applications/calendar/icon/PhabricatorCalendarIcon.php +++ /dev/null @@ -1,49 +0,0 @@ - pht('Default'), - 'fa-glass' => pht('Party'), - 'fa-plane' => pht('Travel'), - 'fa-plus-square' => pht('Health / Appointment'), - 'fa-rocket' => pht('Sabatical / Leave'), - 'fa-home' => pht('Working From Home'), - 'fa-tree' => pht('Holiday'), - 'fa-gamepad' => pht('Staycation'), - 'fa-coffee' => pht('Coffee Meeting'), - 'fa-film' => pht('Movie'), - 'fa-users' => pht('Meeting'), - 'fa-cutlery' => pht('Meal'), - 'fa-paw' => pht('Pet Activity'), - 'fa-institution' => pht('Official Business'), - 'fa-bus' => pht('Field Trip'), - 'fa-microphone' => pht('Conference'), - ); - } - - public static function getLabel($key) { - $map = self::getIconMap(); - return $map[$key]; - } - - public static function getAPIName($key) { - return substr($key, 3); - } - - public static function renderIconForChooser($icon) { - $calendar_icons = self::getIconMap(); - - return phutil_tag( - 'span', - array(), - array( - id(new PHUIIconView())->setIconFont($icon), - ' ', - idx($calendar_icons, $icon, pht('Unknown Icon')), - )); - } - -} diff --git a/src/applications/calendar/icon/PhabricatorCalendarIconSet.php b/src/applications/calendar/icon/PhabricatorCalendarIconSet.php new file mode 100644 index 0000000000..22d5b0e4f5 --- /dev/null +++ b/src/applications/calendar/icon/PhabricatorCalendarIconSet.php @@ -0,0 +1,45 @@ + pht('Default'), + 'fa-glass' => pht('Party'), + 'fa-plane' => pht('Travel'), + 'fa-plus-square' => pht('Health / Appointment'), + + 'fa-rocket' => pht('Sabatical / Leave'), + 'fa-home' => pht('Working From Home'), + 'fa-tree' => pht('Holiday'), + 'fa-gamepad' => pht('Staycation'), + + 'fa-coffee' => pht('Coffee Meeting'), + 'fa-film' => pht('Movie'), + 'fa-users' => pht('Meeting'), + 'fa-cutlery' => pht('Meal'), + + 'fa-paw' => pht('Pet Activity'), + 'fa-institution' => pht('Official Business'), + 'fa-bus' => pht('Field Trip'), + 'fa-microphone' => pht('Conference'), + ); + + $icons = array(); + foreach ($map as $key => $label) { + $icons[] = id(new PhabricatorIconSetIcon()) + ->setKey($key) + ->setLabel($label); + } + + return $icons; + } + +} diff --git a/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php b/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php index c6ee1c4c37..f9c9e79409 100644 --- a/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php +++ b/src/applications/calendar/storage/PhabricatorCalendarEventTransaction.php @@ -156,10 +156,11 @@ final class PhabricatorCalendarEventTransaction $this->renderHandleLink($author_phid)); } case self::TYPE_ICON: + $set = new PhabricatorCalendarIconSet(); return pht( '%s set this event\'s icon to %s.', $this->renderHandleLink($author_phid), - PhabricatorCalendarIcon::getLabel($new)); + $set->getIconLabel($new)); break; case self::TYPE_CANCEL: if ($new) { @@ -356,11 +357,12 @@ final class PhabricatorCalendarEventTransaction $this->renderHandleLink($object_phid)); } case self::TYPE_ICON: + $set = new PhabricatorCalendarIconSet(); return pht( '%s set the icon for %s to %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid), - PhabricatorCalendarIcon::getLabel($new)); + $set->getIconLabel($new)); case self::TYPE_CANCEL: if ($new) { return pht( diff --git a/src/applications/files/application/PhabricatorFilesApplication.php b/src/applications/files/application/PhabricatorFilesApplication.php index 7ad7b8f52c..c22b7f1edd 100644 --- a/src/applications/files/application/PhabricatorFilesApplication.php +++ b/src/applications/files/application/PhabricatorFilesApplication.php @@ -83,6 +83,9 @@ final class PhabricatorFilesApplication extends PhabricatorApplication { 'PhabricatorFileTransformListController', 'uploaddialog/' => 'PhabricatorFileUploadDialogController', 'download/(?P[^/]+)/' => 'PhabricatorFileDialogController', + 'iconset/(?P[^/]+)/' => array( + 'select/' => 'PhabricatorFileIconSetSelectController', + ), ) + $this->getResourceSubroutes(), ); } diff --git a/src/applications/files/controller/PhabricatorFileIconSetSelectController.php b/src/applications/files/controller/PhabricatorFileIconSetSelectController.php new file mode 100644 index 0000000000..af46e2d66e --- /dev/null +++ b/src/applications/files/controller/PhabricatorFileIconSetSelectController.php @@ -0,0 +1,91 @@ +getURIData('key'); + + $set = PhabricatorIconSet::getIconSetByKey($key); + if (!$set) { + return new Aphront404Response(); + } + + $v_icon = $request->getStr('icon'); + if ($request->isFormPost()) { + $icon = $set->getIcon($v_icon); + + if ($icon) { + $payload = array( + 'value' => $icon->getKey(), + 'display' => $set->renderIconForControl($icon), + ); + + return id(new AphrontAjaxResponse()) + ->setContent($payload); + } + } + + require_celerity_resource('project-icon-css'); + Javelin::initBehavior('phabricator-tooltips'); + + $ii = 0; + $buttons = array(); + foreach ($set->getIcons() as $icon) { + $label = $icon->getLabel(); + + $view = id(new PHUIIconView()) + ->setIconFont($icon->getIcon()); + + $aural = javelin_tag( + 'span', + array( + 'aural' => true, + ), + pht('Choose "%s" Icon', $label)); + + $classes = array(); + $classes[] = 'icon-button'; + + if ($icon->getKey() == $v_icon) { + $classes[] = 'selected'; + } + + $buttons[] = javelin_tag( + 'button', + array( + 'class' => implode(' ', $classes), + 'name' => 'icon', + 'value' => $icon->getKey(), + 'type' => 'submit', + 'sigil' => 'has-tooltip', + 'meta' => array( + 'tip' => $label, + ), + ), + array( + $aural, + $view, + )); + + if ((++$ii % 4) == 0) { + $buttons[] = phutil_tag('br'); + } + } + + $buttons = phutil_tag( + 'div', + array( + 'class' => 'icon-grid', + ), + $buttons); + + $dialog_title = $set->getSelectIconTitleText(); + + return $this->newDialog() + ->setTitle($dialog_title) + ->appendChild($buttons) + ->addCancelButton('/'); + } + +} diff --git a/src/applications/files/iconset/PhabricatorIconSet.php b/src/applications/files/iconset/PhabricatorIconSet.php new file mode 100644 index 0000000000..ad8ac4b381 --- /dev/null +++ b/src/applications/files/iconset/PhabricatorIconSet.php @@ -0,0 +1,70 @@ +getPhobjectClassConstant('ICONSETKEY'); + } + + public function getChooseButtonText() { + return pht('Choose Icon...'); + } + + public function getSelectIconTitleText() { + return pht('Choose Icon'); + } + + public function getSelectURI() { + $key = $this->getIconSetKey(); + return "/file/iconset/{$key}/select/"; + } + + final public function getIcons() { + $icons = $this->newIcons(); + + // TODO: Validate icons. + $icons = mpull($icons, null, 'getKey'); + + return $icons; + } + + final public function getIcon($key) { + $icons = $this->getIcons(); + return idx($icons, $key); + } + + final public function getIconLabel($key) { + $icon = $this->getIcon($key); + + if ($icon) { + return $icon->getLabel(); + } + + return $key; + } + + final public function renderIconForControl(PhabricatorIconSetIcon $icon) { + return phutil_tag( + 'span', + array(), + array( + id(new PHUIIconView())->setIconFont($icon->getIcon()), + ' ', + $icon->getLabel(), + )); + } + + final public static function getIconSetByKey($key) { + $sets = self::getAllIconSets(); + return idx($sets, $key); + } + + final public static function getAllIconSets() { + return id(new PhutilClassMapQuery()) + ->setAncestorClass(__CLASS__) + ->setUniqueMethod('getIconSetKey') + ->execute(); + } + +} diff --git a/src/applications/files/iconset/PhabricatorIconSetIcon.php b/src/applications/files/iconset/PhabricatorIconSetIcon.php new file mode 100644 index 0000000000..1e1773aa16 --- /dev/null +++ b/src/applications/files/iconset/PhabricatorIconSetIcon.php @@ -0,0 +1,40 @@ +key = $key; + return $this; + } + + public function getKey() { + return $this->key; + } + + public function setIcon($icon) { + $this->icon = $icon; + return $this; + } + + public function getIcon() { + if ($this->icon === null) { + return $this->getKey(); + } + return $this->icon; + } + + public function setLabel($label) { + $this->label = $label; + return $this; + } + + public function getLabel() { + return $this->label; + } + +} diff --git a/src/applications/project/application/PhabricatorProjectApplication.php b/src/applications/project/application/PhabricatorProjectApplication.php index 0a2ae190d9..4a4778cde5 100644 --- a/src/applications/project/application/PhabricatorProjectApplication.php +++ b/src/applications/project/application/PhabricatorProjectApplication.php @@ -59,10 +59,6 @@ final class PhabricatorProjectApplication extends PhabricatorApplication { => 'PhabricatorProjectViewController', 'picture/(?P[1-9]\d*)/' => 'PhabricatorProjectEditPictureController', - 'icon/(?P[1-9]\d*)/' - => 'PhabricatorProjectEditIconController', - 'icon/' - => 'PhabricatorProjectEditIconController', 'create/' => 'PhabricatorProjectEditDetailsController', 'board/(?P[1-9]\d*)/'. '(?Pfilter/)?'. diff --git a/src/applications/project/conduit/ProjectConduitAPIMethod.php b/src/applications/project/conduit/ProjectConduitAPIMethod.php index 419adc2c36..6acf320daf 100644 --- a/src/applications/project/conduit/ProjectConduitAPIMethod.php +++ b/src/applications/project/conduit/ProjectConduitAPIMethod.php @@ -26,7 +26,7 @@ abstract class ProjectConduitAPIMethod extends ConduitAPIMethod { $project_slugs = $project->getSlugs(); $project_slugs = array_values(mpull($project_slugs, 'getSlug')); - $project_icon = PhabricatorProjectIcon::getAPIName($project->getIcon()); + $project_icon = substr($project->getIcon(), 3); $result[$project->getPHID()] = array( 'id' => $project->getID(), diff --git a/src/applications/project/controller/PhabricatorProjectEditDetailsController.php b/src/applications/project/controller/PhabricatorProjectEditDetailsController.php index 48016845a8..d3a3fb6374 100644 --- a/src/applications/project/controller/PhabricatorProjectEditDetailsController.php +++ b/src/applications/project/controller/PhabricatorProjectEditDetailsController.php @@ -188,14 +188,8 @@ final class PhabricatorProjectEditDetailsController ->setError($e_name)); $field_list->appendFieldsToForm($form); - $shades = PhabricatorProjectIcon::getColorMap(); + $shades = PhabricatorProjectIconSet::getColorMap(); - if ($is_new) { - $icon_uri = $this->getApplicationURI('icon/'); - } else { - $icon_uri = $this->getApplicationURI('icon/'.$project->getID().'/'); - } - $icon_display = PhabricatorProjectIcon::renderIconForChooser($v_icon); list($can_lock, $lock_message) = $this->explainApplicationCapability( ProjectCanLockProjectsCapability::CAPABILITY, pht('You can update the Lock Project setting.'), @@ -203,12 +197,10 @@ final class PhabricatorProjectEditDetailsController $form ->appendChild( - id(new AphrontFormChooseButtonControl()) + id(new PHUIFormIconSetControl()) ->setLabel(pht('Icon')) ->setName('icon') - ->setDisplayValue($icon_display) - ->setButtonText(pht('Choose Icon...')) - ->setChooseURI($icon_uri) + ->setIconSet(new PhabricatorProjectIconSet()) ->setValue($v_icon)) ->appendChild( id(new AphrontFormSelectControl()) diff --git a/src/applications/project/controller/PhabricatorProjectEditIconController.php b/src/applications/project/controller/PhabricatorProjectEditIconController.php deleted file mode 100644 index fe7e28b4c2..0000000000 --- a/src/applications/project/controller/PhabricatorProjectEditIconController.php +++ /dev/null @@ -1,100 +0,0 @@ -getViewer(); - $id = $request->getURIData('id'); - - if ($id) { - $project = id(new PhabricatorProjectQuery()) - ->setViewer($viewer) - ->withIDs(array($id)) - ->requireCapabilities( - array( - PhabricatorPolicyCapability::CAN_VIEW, - PhabricatorPolicyCapability::CAN_EDIT, - )) - ->executeOne(); - if (!$project) { - return new Aphront404Response(); - } - $cancel_uri = $this->getApplicationURI('profile/'.$project->getID().'/'); - $project_icon = $project->getIcon(); - } else { - $this->requireApplicationCapability( - ProjectCreateProjectsCapability::CAPABILITY); - - $cancel_uri = '/project/'; - $project_icon = $request->getStr('value'); - } - - require_celerity_resource('project-icon-css'); - Javelin::initBehavior('phabricator-tooltips'); - - $project_icons = PhabricatorProjectIcon::getIconMap(); - - if ($request->isFormPost()) { - $v_icon = $request->getStr('icon'); - - return id(new AphrontAjaxResponse())->setContent( - array( - 'value' => $v_icon, - 'display' => PhabricatorProjectIcon::renderIconForChooser($v_icon), - )); - } - - $ii = 0; - $buttons = array(); - foreach ($project_icons as $icon => $label) { - $view = id(new PHUIIconView()) - ->setIconFont($icon); - - $aural = javelin_tag( - 'span', - array( - 'aural' => true, - ), - pht('Choose "%s" Icon', $label)); - - if ($icon == $project_icon) { - $class_extra = ' selected'; - } else { - $class_extra = null; - } - - $buttons[] = javelin_tag( - 'button', - array( - 'class' => 'icon-button'.$class_extra, - 'name' => 'icon', - 'value' => $icon, - 'type' => 'submit', - 'sigil' => 'has-tooltip', - 'meta' => array( - 'tip' => $label, - ), - ), - array( - $aural, - $view, - )); - if ((++$ii % 4) == 0) { - $buttons[] = phutil_tag('br'); - } - } - - $buttons = phutil_tag( - 'div', - array( - 'class' => 'icon-grid', - ), - $buttons); - - return $this->newDialog() - ->setTitle(pht('Choose Project Icon')) - ->appendChild($buttons) - ->addCancelButton($cancel_uri); - } -} diff --git a/src/applications/project/icon/PhabricatorProjectIcon.php b/src/applications/project/icon/PhabricatorProjectIcon.php deleted file mode 100644 index 9411baa6a9..0000000000 --- a/src/applications/project/icon/PhabricatorProjectIcon.php +++ /dev/null @@ -1,59 +0,0 @@ - pht('Briefcase'), - 'fa-tags' => pht('Tag'), - 'fa-folder' => pht('Folder'), - 'fa-users' => pht('Team'), - 'fa-bug' => pht('Bug'), - 'fa-trash-o' => pht('Garbage'), - 'fa-calendar' => pht('Deadline'), - 'fa-flag-checkered' => pht('Goal'), - 'fa-envelope' => pht('Communication'), - 'fa-truck' => pht('Release'), - 'fa-lock' => pht('Policy'), - 'fa-umbrella' => pht('An Umbrella'), - 'fa-cloud' => pht('The Cloud'), - 'fa-building' => pht('Company'), - 'fa-credit-card' => pht('Accounting'), - 'fa-flask' => pht('Experimental'), - ); - } - - public static function getColorMap() { - $shades = PHUITagView::getShadeMap(); - $shades = array_select_keys( - $shades, - array(PhabricatorProject::DEFAULT_COLOR)) + $shades; - unset($shades[PHUITagView::COLOR_DISABLED]); - - return $shades; - } - - public static function getLabel($key) { - $map = self::getIconMap(); - return $map[$key]; - } - - public static function getAPIName($key) { - return substr($key, 3); - } - - public static function renderIconForChooser($icon) { - $project_icons = self::getIconMap(); - - return phutil_tag( - 'span', - array(), - array( - id(new PHUIIconView())->setIconFont($icon), - ' ', - idx($project_icons, $icon, pht('Unknown Icon')), - )); - } - -} diff --git a/src/applications/project/icon/PhabricatorProjectIconSet.php b/src/applications/project/icon/PhabricatorProjectIconSet.php new file mode 100644 index 0000000000..470e871096 --- /dev/null +++ b/src/applications/project/icon/PhabricatorProjectIconSet.php @@ -0,0 +1,55 @@ + pht('Briefcase'), + 'fa-tags' => pht('Tag'), + 'fa-folder' => pht('Folder'), + 'fa-users' => pht('Team'), + + 'fa-bug' => pht('Bug'), + 'fa-trash-o' => pht('Garbage'), + 'fa-calendar' => pht('Deadline'), + 'fa-flag-checkered' => pht('Goal'), + + 'fa-envelope' => pht('Communication'), + 'fa-truck' => pht('Release'), + 'fa-lock' => pht('Policy'), + 'fa-umbrella' => pht('An Umbrella'), + + 'fa-cloud' => pht('The Cloud'), + 'fa-building' => pht('Company'), + 'fa-credit-card' => pht('Accounting'), + 'fa-flask' => pht('Experimental'), + ); + + $icons = array(); + foreach ($map as $key => $label) { + $icons[] = id(new PhabricatorIconSetIcon()) + ->setKey($key) + ->setLabel($label); + } + + return $icons; + } + + public static function getColorMap() { + $shades = PHUITagView::getShadeMap(); + $shades = array_select_keys( + $shades, + array(PhabricatorProject::DEFAULT_COLOR)) + $shades; + unset($shades[PHUITagView::COLOR_DISABLED]); + + return $shades; + } + +} diff --git a/src/applications/project/query/PhabricatorProjectSearchEngine.php b/src/applications/project/query/PhabricatorProjectSearchEngine.php index e63a0940c3..89cbb9163e 100644 --- a/src/applications/project/query/PhabricatorProjectSearchEngine.php +++ b/src/applications/project/query/PhabricatorProjectSearchEngine.php @@ -128,12 +128,13 @@ protected function buildQueryFromParameters(array $map) { private function getIconOptions() { $options = array(); - foreach (PhabricatorProjectIcon::getIconMap() as $icon => $name) { - $options[$icon] = array( + $set = new PhabricatorProjectIconSet(); + foreach ($set->getIcons() as $icon) { + $options[$icon->getKey()] = array( id(new PHUIIconView()) - ->setIconFont($icon), + ->setIconFont($icon->getIcon()), ' ', - $name, + $icon->getLabel(), ); } @@ -143,7 +144,7 @@ protected function buildQueryFromParameters(array $map) { private function getColorOptions() { $options = array(); - foreach (PhabricatorProjectIcon::getColorMap() as $color => $name) { + foreach (PhabricatorProjectIconSet::getColorMap() as $color => $name) { $options[$color] = array( id(new PHUITagView()) ->setType(PHUITagView::TYPE_SHADE) diff --git a/src/applications/project/storage/PhabricatorProjectTransaction.php b/src/applications/project/storage/PhabricatorProjectTransaction.php index 01a458dee2..6529c99d59 100644 --- a/src/applications/project/storage/PhabricatorProjectTransaction.php +++ b/src/applications/project/storage/PhabricatorProjectTransaction.php @@ -147,10 +147,12 @@ final class PhabricatorProjectTransaction break; case self::TYPE_ICON: + $set = new PhabricatorProjectIconSet(); + return pht( "%s set this project's icon to %s.", $author_handle, - PhabricatorProjectIcon::getLabel($new)); + $set->getIconLabel($new)); break; case self::TYPE_COLOR: @@ -301,11 +303,13 @@ final class PhabricatorProjectTransaction } case self::TYPE_ICON: + $set = new PhabricatorProjectIconSet(); + return pht( '%s set the icon for %s to %s.', $author_handle, $object_handle, - PhabricatorProjectIcon::getLabel($new)); + $set->getIconLabel($new)); case self::TYPE_COLOR: return pht( diff --git a/src/view/form/control/AphrontFormChooseButtonControl.php b/src/view/form/control/PHUIFormIconSetControl.php similarity index 54% rename from src/view/form/control/AphrontFormChooseButtonControl.php rename to src/view/form/control/PHUIFormIconSetControl.php index d48f01fc3b..913402d8ea 100644 --- a/src/view/form/control/AphrontFormChooseButtonControl.php +++ b/src/view/form/control/PHUIFormIconSetControl.php @@ -1,62 +1,59 @@ displayValue = $display_value; + public function setIconSet(PhabricatorIconSet $icon_set) { + $this->iconSet = $icon_set; return $this; } - public function getDisplayValue() { - return $this->displayValue; - } - - public function setButtonText($text) { - $this->buttonText = $text; - return $this; - } - - public function setChooseURI($choose_uri) { - $this->chooseURI = $choose_uri; - return $this; + public function getIconSet() { + return $this->iconSet; } protected function getCustomControlClass() { - return 'aphront-form-control-choose-button'; + return 'phui-form-iconset-control'; } protected function renderInput() { Javelin::initBehavior('choose-control'); + $set = $this->getIconSet(); + $input_id = celerity_generate_unique_node_id(); $display_id = celerity_generate_unique_node_id(); - $display_value = $this->displayValue; $button = javelin_tag( 'a', array( 'href' => '#', 'class' => 'button grey', - 'sigil' => 'aphront-form-choose-button', + 'sigil' => 'phui-form-iconset-button', ), - nonempty($this->buttonText, pht('Choose...'))); + $set->getChooseButtonText()); + + $icon = $set->getIcon($this->getValue()); + if ($icon) { + $display = $set->renderIconForControl($icon); + } else { + $display = null; + } $display_cell = phutil_tag( 'td', array( - 'class' => 'aphront-form-choose-display-cell', + 'class' => 'phui-form-iconset-display-cell', 'id' => $display_id, ), - $display_value); + $display); $button_cell = phutil_tag( 'td', array( - 'class' => 'aphront-form-choose-button-cell', + 'class' => 'phui-form-iconset-button-cell', ), $button); @@ -68,10 +65,10 @@ final class AphrontFormChooseButtonControl extends AphrontFormControl { $layout = javelin_tag( 'table', array( - 'class' => 'aphront-form-choose-table', - 'sigil' => 'aphront-form-choose', + 'class' => 'phui-form-iconset-table', + 'sigil' => 'phui-form-iconset', 'meta' => array( - 'uri' => $this->chooseURI, + 'uri' => $set->getSelectURI(), 'inputID' => $input_id, 'displayID' => $display_id, ), diff --git a/webroot/rsrc/css/phui/phui-form-view.css b/webroot/rsrc/css/phui/phui-form-view.css index 8368177cad..eea874e381 100644 --- a/webroot/rsrc/css/phui/phui-form-view.css +++ b/webroot/rsrc/css/phui/phui-form-view.css @@ -519,12 +519,12 @@ properly, and submit values. */ width: 180px; } -.aphront-form-choose-table td { +.phui-form-iconset-table td { vertical-align: middle; padding: 4px 0; } -.aphront-form-choose-table .aphront-form-choose-button-cell { +.phui-form-iconset-table .phui-form-iconset-button-cell { padding: 4px 8px; } diff --git a/webroot/rsrc/js/core/behavior-choose-control.js b/webroot/rsrc/js/core/behavior-choose-control.js index 3652e1305b..8a33ac4eb3 100644 --- a/webroot/rsrc/js/core/behavior-choose-control.js +++ b/webroot/rsrc/js/core/behavior-choose-control.js @@ -10,11 +10,11 @@ JX.behavior('choose-control', function() { JX.Stratcom.listen( 'click', - 'aphront-form-choose-button', + 'phui-form-iconset-button', function(e) { e.kill(); - var data = e.getNodeData('aphront-form-choose'); + var data = e.getNodeData('phui-form-iconset'); var params = { value: JX.$(data.inputID).value