Page MenuHomePhabricator

D17042.id40993.diff
No OneTemporary

D17042.id40993.diff

diff --git a/resources/sql/autopatches/20161212.dashboards.01.icon.sql b/resources/sql/autopatches/20161212.dashboards.01.icon.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20161212.dashboards.01.icon.sql
@@ -0,0 +1,5 @@
+ALTER TABLE {$NAMESPACE}_dashboard.dashboard
+ ADD icon VARCHAR(32) NOT NULL;
+
+UPDATE {$NAMESPACE}_dashboard.dashboard
+ SET icon = 'fa-dashboard';
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
@@ -2426,6 +2426,7 @@
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardDashboardHasPanelEdgeType.php',
'PhabricatorDashboardDashboardPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardDashboardPHIDType.php',
'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php',
+ 'PhabricatorDashboardIconSet' => 'applications/dashboard/icon/PhabricatorDashboardIconSet.php',
'PhabricatorDashboardInstall' => 'applications/dashboard/storage/PhabricatorDashboardInstall.php',
'PhabricatorDashboardInstallController' => 'applications/dashboard/controller/PhabricatorDashboardInstallController.php',
'PhabricatorDashboardLayoutConfig' => 'applications/dashboard/layoutconfig/PhabricatorDashboardLayoutConfig.php',
@@ -7364,6 +7365,7 @@
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'PhabricatorEdgeType',
'PhabricatorDashboardDashboardPHIDType' => 'PhabricatorPHIDType',
'PhabricatorDashboardEditController' => 'PhabricatorDashboardController',
+ 'PhabricatorDashboardIconSet' => 'PhabricatorIconSet',
'PhabricatorDashboardInstall' => 'PhabricatorDashboardDAO',
'PhabricatorDashboardInstallController' => 'PhabricatorDashboardController',
'PhabricatorDashboardLayoutConfig' => 'Phobject',
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardEditController.php b/src/applications/dashboard/controller/PhabricatorDashboardEditController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardEditController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardEditController.php
@@ -67,12 +67,14 @@
}
$v_name = $dashboard->getName();
+ $v_icon = $dashboard->getIcon();
$v_layout_mode = $dashboard->getLayoutConfigObject()->getLayoutMode();
$e_name = true;
$validation_exception = null;
if ($request->isFormPost() && $request->getStr('edit')) {
$v_name = $request->getStr('name');
+ $v_icon = $request->getStr('icon');
$v_layout_mode = $request->getStr('layout_mode');
$v_view_policy = $request->getStr('viewPolicy');
$v_edit_policy = $request->getStr('editPolicy');
@@ -81,6 +83,7 @@
$xactions = array();
$type_name = PhabricatorDashboardTransaction::TYPE_NAME;
+ $type_icon = PhabricatorDashboardTransaction::TYPE_ICON;
$type_layout_mode = PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE;
$type_view_policy = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit_policy = PhabricatorTransactions::TYPE_EDIT_POLICY;
@@ -92,6 +95,9 @@
->setTransactionType($type_layout_mode)
->setNewValue($v_layout_mode);
$xactions[] = id(new PhabricatorDashboardTransaction())
+ ->setTransactionType($type_icon)
+ ->setNewValue($v_icon);
+ $xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_view_policy)
->setNewValue($v_view_policy);
$xactions[] = id(new PhabricatorDashboardTransaction())
@@ -147,6 +153,12 @@
->setValue($v_layout_mode)
->setOptions($layout_mode_options))
->appendChild(
+ id(new PHUIFormIconSetControl())
+ ->setLabel(pht('Icon'))
+ ->setName('icon')
+ ->setIconSet(new PhabricatorDashboardIconSet())
+ ->setValue($v_icon))
+ ->appendChild(
id(new AphrontFormPolicyControl())
->setName('viewPolicy')
->setPolicyObject($dashboard)
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardManageController.php b/src/applications/dashboard/controller/PhabricatorDashboardManageController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardManageController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardManageController.php
@@ -109,7 +109,7 @@
->setHeader($dashboard->getName())
->setPolicyObject($dashboard)
->setStatus($status_icon, $status_color, $status_name)
- ->setHeaderIcon('fa-dashboard')
+ ->setHeaderIcon($dashboard->getIcon())
->addActionLink($button);
}
diff --git a/src/applications/dashboard/editor/PhabricatorDashboardTransactionEditor.php b/src/applications/dashboard/editor/PhabricatorDashboardTransactionEditor.php
--- a/src/applications/dashboard/editor/PhabricatorDashboardTransactionEditor.php
+++ b/src/applications/dashboard/editor/PhabricatorDashboardTransactionEditor.php
@@ -51,6 +51,7 @@
$types[] = PhabricatorTransactions::TYPE_EDGE;
$types[] = PhabricatorDashboardTransaction::TYPE_NAME;
+ $types[] = PhabricatorDashboardTransaction::TYPE_ICON;
$types[] = PhabricatorDashboardTransaction::TYPE_STATUS;
$types[] = PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE;
@@ -66,6 +67,11 @@
return null;
}
return $object->getName();
+ case PhabricatorDashboardTransaction::TYPE_ICON:
+ if ($this->getIsNewObject()) {
+ return null;
+ }
+ return $object->getIcon();
case PhabricatorDashboardTransaction::TYPE_STATUS:
if ($this->getIsNewObject()) {
return null;
@@ -87,6 +93,7 @@
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorDashboardTransaction::TYPE_NAME:
+ case PhabricatorDashboardTransaction::TYPE_ICON:
case PhabricatorDashboardTransaction::TYPE_STATUS:
case PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE:
return $xaction->getNewValue();
@@ -101,6 +108,9 @@
case PhabricatorDashboardTransaction::TYPE_NAME:
$object->setName($xaction->getNewValue());
return;
+ case PhabricatorDashboardTransaction::TYPE_ICON:
+ $object->setIcon($xaction->getNewValue());
+ return;
case PhabricatorDashboardTransaction::TYPE_STATUS:
$object->setStatus($xaction->getNewValue());
return;
@@ -130,6 +140,7 @@
switch ($xaction->getTransactionType()) {
case PhabricatorDashboardTransaction::TYPE_NAME:
+ case PhabricatorDashboardTransaction::TYPE_ICON:
case PhabricatorDashboardTransaction::TYPE_STATUS:
case PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE:
return;
diff --git a/src/applications/dashboard/icon/PhabricatorDashboardIconSet.php b/src/applications/dashboard/icon/PhabricatorDashboardIconSet.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/icon/PhabricatorDashboardIconSet.php
@@ -0,0 +1,45 @@
+<?php
+
+final class PhabricatorDashboardIconSet
+ extends PhabricatorIconSet {
+
+ const ICONSETKEY = 'dashboards';
+
+ public function getSelectIconTitleText() {
+ return pht('Choose Dashboard Icon');
+ }
+
+ protected function newIcons() {
+ $map = array(
+ 'fa-home' => pht('Home'),
+ 'fa-th-large' => pht('Blocks'),
+ 'fa-columns' => pht('Columns'),
+ 'fa-bookmark' => pht('Page Saver'),
+
+ 'fa-book' => pht('Knowledge'),
+ 'fa-bomb' => pht('Kaboom'),
+ 'fa-pie-chart' => pht('Apple Blueberry'),
+ 'fa-bar-chart' => pht('Serious Business'),
+
+ 'fa-bell' => pht('Ding Ding'),
+ 'fa-credit-card' => pht('Plastic Debt'),
+ 'fa-code' => pht('PHP is Life'),
+ 'fa-sticky-note' => pht('To Self'),
+
+ 'fa-newspaper-o' => pht('Stay Woke'),
+ 'fa-server' => pht('Metallica'),
+ 'fa-hashtag' => pht('Corned Beef'),
+ 'fa-group' => pht('Triplets'),
+ );
+
+ $icons = array();
+ foreach ($map as $key => $label) {
+ $icons[] = id(new PhabricatorIconSetIcon())
+ ->setKey($key)
+ ->setLabel($label);
+ }
+
+ return $icons;
+ }
+
+}
diff --git a/src/applications/dashboard/storage/PhabricatorDashboard.php b/src/applications/dashboard/storage/PhabricatorDashboard.php
--- a/src/applications/dashboard/storage/PhabricatorDashboard.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboard.php
@@ -16,6 +16,7 @@
protected $viewPolicy;
protected $editPolicy;
protected $status;
+ protected $icon;
protected $layoutConfig = array();
const STATUS_ACTIVE = 'active';
@@ -29,6 +30,7 @@
public static function initializeNewDashboard(PhabricatorUser $actor) {
return id(new PhabricatorDashboard())
->setName('')
+ ->setIcon('fa-dashboard')
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy($actor->getPHID())
->setStatus(self::STATUS_ACTIVE)
@@ -63,6 +65,7 @@
self::CONFIG_COLUMN_SCHEMA => array(
'name' => 'text255',
'status' => 'text32',
+ 'icon' => 'text32',
'authorPHID' => 'phid',
),
) + parent::getConfiguration();
diff --git a/src/applications/dashboard/storage/PhabricatorDashboardTransaction.php b/src/applications/dashboard/storage/PhabricatorDashboardTransaction.php
--- a/src/applications/dashboard/storage/PhabricatorDashboardTransaction.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboardTransaction.php
@@ -4,6 +4,7 @@
extends PhabricatorApplicationTransaction {
const TYPE_NAME = 'dashboard:name';
+ const TYPE_ICON = 'dashboard:icon';
const TYPE_STATUS = 'dashboard:status';
const TYPE_LAYOUT_MODE = 'dashboard:layoutmode';
@@ -39,6 +40,19 @@
$new);
}
break;
+ case self::TYPE_ICON:
+ if (!strlen($old)) {
+ return pht(
+ '%s set the dashboard icon.',
+ $author_link);
+ } else {
+ return pht(
+ '%s changed this dashboard icon from "%s" to "%s".',
+ $author_link,
+ $old,
+ $new);
+ }
+ break;
case self::TYPE_STATUS:
if ($new == PhabricatorDashboard::STATUS_ACTIVE) {
return pht(
@@ -82,6 +96,21 @@
$new);
}
break;
+ case self::TYPE_ICON:
+ if (!strlen($old)) {
+ return pht(
+ '%s set dashboard icon for %s.',
+ $author_link,
+ $object_link);
+ } else {
+ return pht(
+ '%s set the dashboard icon on %s from "%s" to "%s".',
+ $author_link,
+ $object_link,
+ $old,
+ $new);
+ }
+ break;
case self::TYPE_STATUS:
if ($new == PhabricatorDashboard::STATUS_ACTIVE) {
return pht(

File Metadata

Mime Type
text/plain
Expires
Fri, Mar 21, 6:35 AM (2 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7383057
Default Alt Text
D17042.id40993.diff (10 KB)

Event Timeline