1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-29 16:08:22 +01:00

Allow projects icon color to be selected from several fabulous shades

Summary: This further helps differentiate types/roles for projects.

Test Plan: {F169758}

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Differential Revision: https://secure.phabricator.com/D9710
This commit is contained in:
epriestley 2014-06-25 22:01:58 -07:00
parent 38ae1191de
commit be47f2141a
13 changed files with 117 additions and 30 deletions

View file

@ -7,7 +7,7 @@
return array( return array(
'names' => 'names' =>
array( array(
'core.pkg.css' => 'c2e44da2', 'core.pkg.css' => 'e428441c',
'core.pkg.js' => '8c184823', 'core.pkg.js' => '8c184823',
'darkconsole.pkg.js' => 'df001cab', 'darkconsole.pkg.js' => 'df001cab',
'differential.pkg.css' => '4a93db37', 'differential.pkg.css' => '4a93db37',
@ -142,7 +142,7 @@ return array(
'rsrc/css/phui/phui-remarkup-preview.css' => '19ad512b', 'rsrc/css/phui/phui-remarkup-preview.css' => '19ad512b',
'rsrc/css/phui/phui-spacing.css' => '042804d6', 'rsrc/css/phui/phui-spacing.css' => '042804d6',
'rsrc/css/phui/phui-status.css' => '2f562399', 'rsrc/css/phui/phui-status.css' => '2f562399',
'rsrc/css/phui/phui-tag-view.css' => '67017012', 'rsrc/css/phui/phui-tag-view.css' => '8ac14ba8',
'rsrc/css/phui/phui-text.css' => '23e9b4b7', 'rsrc/css/phui/phui-text.css' => '23e9b4b7',
'rsrc/css/phui/phui-timeline-view.css' => 'bbd990d0', 'rsrc/css/phui/phui-timeline-view.css' => 'bbd990d0',
'rsrc/css/phui/phui-workboard-view.css' => '2bf82d00', 'rsrc/css/phui/phui-workboard-view.css' => '2bf82d00',
@ -787,7 +787,7 @@ return array(
'phui-remarkup-preview-css' => '19ad512b', 'phui-remarkup-preview-css' => '19ad512b',
'phui-spacing-css' => '042804d6', 'phui-spacing-css' => '042804d6',
'phui-status-list-view-css' => '2f562399', 'phui-status-list-view-css' => '2f562399',
'phui-tag-view-css' => '67017012', 'phui-tag-view-css' => '8ac14ba8',
'phui-text-css' => '23e9b4b7', 'phui-text-css' => '23e9b4b7',
'phui-timeline-view-css' => 'bbd990d0', 'phui-timeline-view-css' => 'bbd990d0',
'phui-workboard-view-css' => '2bf82d00', 'phui-workboard-view-css' => '2bf82d00',

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_project.project
ADD color VARCHAR(32) NOT NULL COLLATE utf8_bin;

View file

@ -0,0 +1,2 @@
UPDATE {$NAMESPACE}_project.project
SET color = 'blue' WHERE color = '';

View file

@ -11,6 +11,7 @@ final class PhabricatorObjectHandle
private $title; private $title;
private $imageURI; private $imageURI;
private $icon; private $icon;
private $tagColor;
private $timestamp; private $timestamp;
private $status = PhabricatorObjectHandleStatus::STATUS_OPEN; private $status = PhabricatorObjectHandleStatus::STATUS_OPEN;
private $complete; private $complete;
@ -30,8 +31,24 @@ final class PhabricatorObjectHandle
return $this->getTypeIcon(); return $this->getTypeIcon();
} }
public function getIconColor() { public function setTagColor($color) {
return 'bluegrey'; static $colors;
if (!$colors) {
$colors = array_fuse(array_keys(PHUITagView::getShadeMap()));
}
if (isset($colors[$color])) {
$this->tagColor = $color;
}
return $this;
}
public function getTagColor() {
if ($this->tagColor) {
return $this->tagColor;
}
return 'blue';
} }
public function getTypeIcon() { public function getTypeIcon() {
@ -262,7 +279,8 @@ final class PhabricatorObjectHandle
public function renderTag() { public function renderTag() {
return id(new PHUITagView()) return id(new PHUITagView())
->setType(PHUITagView::TYPE_OBJECT) ->setType(PHUITagView::TYPE_OBJECT)
->setIcon($this->getIcon().' '.$this->getIconColor()) ->setShade($this->getTagColor())
->setIcon($this->getIcon())
->setHref($this->getURI()) ->setHref($this->getURI())
->setName($this->getLinkName()); ->setName($this->getLinkName());
} }

View file

@ -30,11 +30,20 @@ final class PhabricatorProjectEditIconController
$edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/'); $edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/');
if ($request->isFormPost()) { if ($request->isFormPost()) {
$xactions = array();
$v_icon = $request->getStr('icon'); $v_icon = $request->getStr('icon');
$v_icon_color = $request->getStr('color');
$type_icon = PhabricatorProjectTransaction::TYPE_ICON; $type_icon = PhabricatorProjectTransaction::TYPE_ICON;
$xactions = array(id(new PhabricatorProjectTransaction()) $xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_icon) ->setTransactionType($type_icon)
->setNewValue($v_icon)); ->setNewValue($v_icon);
$type_icon_color = PhabricatorProjectTransaction::TYPE_COLOR;
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType($type_icon_color)
->setNewValue($v_icon_color);
$editor = id(new PhabricatorProjectTransactionEditor()) $editor = id(new PhabricatorProjectTransactionEditor())
->setActor($viewer) ->setActor($viewer)
@ -47,6 +56,20 @@ final class PhabricatorProjectEditIconController
return id(new AphrontReloadResponse())->setURI($edit_uri); return id(new AphrontReloadResponse())->setURI($edit_uri);
} }
$shades = PHUITagView::getShadeMap();
$shades = array_select_keys(
$shades,
array(PhabricatorProject::DEFAULT_COLOR)) + $shades;
unset($shades[PHUITagView::COLOR_DISABLED]);
$color_form = id(new AphrontFormView())
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Color'))
->setName('color')
->setValue($project->getColor())
->setOptions($shades));
require_celerity_resource('project-icon-css'); require_celerity_resource('project-icon-css');
Javelin::initBehavior('phabricator-tooltips'); Javelin::initBehavior('phabricator-tooltips');
@ -55,7 +78,7 @@ final class PhabricatorProjectEditIconController
$buttons = array(); $buttons = array();
foreach ($project_icons as $icon => $label) { foreach ($project_icons as $icon => $label) {
$view = id(new PHUIIconView()) $view = id(new PHUIIconView())
->setIconFont($icon.' bluegrey'); ->setIconFont($icon);
$aural = javelin_tag( $aural = javelin_tag(
'span', 'span',
@ -66,10 +89,8 @@ final class PhabricatorProjectEditIconController
if ($icon == $project->getIcon()) { if ($icon == $project->getIcon()) {
$class_extra = ' selected'; $class_extra = ' selected';
$tip = $label.pht(' - selected');
} else { } else {
$class_extra = null; $class_extra = null;
$tip = $label;
} }
$buttons[] = javelin_tag( $buttons[] = javelin_tag(
@ -81,7 +102,7 @@ final class PhabricatorProjectEditIconController
'type' => 'submit', 'type' => 'submit',
'sigil' => 'has-tooltip', 'sigil' => 'has-tooltip',
'meta' => array( 'meta' => array(
'tip' => $tip, 'tip' => $label,
) )
), ),
array( array(
@ -100,12 +121,14 @@ final class PhabricatorProjectEditIconController
), ),
$buttons); $buttons);
$dialog = id(new AphrontDialogView()) $color_form->appendChild(
->setUser($viewer) id(new AphrontFormMarkupControl())
->setTitle(pht('Choose Project Icon')) ->setLabel(pht('Icon'))
->appendChild($buttons) ->setValue($buttons));
->addCancelButton($edit_uri);
return id(new AphrontDialogResponse())->setDialog($dialog); return $this->newDialog()
->setTitle(pht('Choose Project Icon'))
->appendChild($color_form->buildLayoutView())
->addCancelButton($edit_uri);
} }
} }

View file

@ -145,6 +145,12 @@ final class PhabricatorProjectEditMainController
$viewer, $viewer,
$project); $project);
$this->loadHandles(array($project->getPHID()));
$view->addProperty(
pht('Looks Like'),
$this->getHandle($project->getPHID())->renderTag());
$view->addProperty( $view->addProperty(
pht('Visible To'), pht('Visible To'),
$descriptions[PhabricatorPolicyCapability::CAN_VIEW]); $descriptions[PhabricatorPolicyCapability::CAN_VIEW]);

View file

@ -16,6 +16,7 @@ final class PhabricatorProjectTransactionEditor
$types[] = PhabricatorProjectTransaction::TYPE_STATUS; $types[] = PhabricatorProjectTransaction::TYPE_STATUS;
$types[] = PhabricatorProjectTransaction::TYPE_IMAGE; $types[] = PhabricatorProjectTransaction::TYPE_IMAGE;
$types[] = PhabricatorProjectTransaction::TYPE_ICON; $types[] = PhabricatorProjectTransaction::TYPE_ICON;
$types[] = PhabricatorProjectTransaction::TYPE_COLOR;
return $types; return $types;
} }
@ -38,6 +39,8 @@ final class PhabricatorProjectTransactionEditor
return $object->getProfileImagePHID(); return $object->getProfileImagePHID();
case PhabricatorProjectTransaction::TYPE_ICON: case PhabricatorProjectTransaction::TYPE_ICON:
return $object->getIcon(); return $object->getIcon();
case PhabricatorProjectTransaction::TYPE_COLOR:
return $object->getColor();
} }
return parent::getCustomTransactionOldValue($object, $xaction); return parent::getCustomTransactionOldValue($object, $xaction);
@ -53,6 +56,7 @@ final class PhabricatorProjectTransactionEditor
case PhabricatorProjectTransaction::TYPE_STATUS: case PhabricatorProjectTransaction::TYPE_STATUS:
case PhabricatorProjectTransaction::TYPE_IMAGE: case PhabricatorProjectTransaction::TYPE_IMAGE:
case PhabricatorProjectTransaction::TYPE_ICON: case PhabricatorProjectTransaction::TYPE_ICON:
case PhabricatorProjectTransaction::TYPE_COLOR:
return $xaction->getNewValue(); return $xaction->getNewValue();
} }
@ -79,6 +83,9 @@ final class PhabricatorProjectTransactionEditor
case PhabricatorProjectTransaction::TYPE_ICON: case PhabricatorProjectTransaction::TYPE_ICON:
$object->setIcon($xaction->getNewValue()); $object->setIcon($xaction->getNewValue());
return; return;
case PhabricatorProjectTransaction::TYPE_COLOR:
$object->setColor($xaction->getNewValue());
return;
case PhabricatorTransactions::TYPE_EDGE: case PhabricatorTransactions::TYPE_EDGE:
return; return;
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
@ -181,6 +188,7 @@ final class PhabricatorProjectTransactionEditor
case PhabricatorProjectTransaction::TYPE_STATUS: case PhabricatorProjectTransaction::TYPE_STATUS:
case PhabricatorProjectTransaction::TYPE_IMAGE: case PhabricatorProjectTransaction::TYPE_IMAGE:
case PhabricatorProjectTransaction::TYPE_ICON: case PhabricatorProjectTransaction::TYPE_ICON:
case PhabricatorProjectTransaction::TYPE_COLOR:
return; return;
case PhabricatorTransactions::TYPE_EDGE: case PhabricatorTransactions::TYPE_EDGE:
$edge_type = $xaction->getMetadataValue('edge:type'); $edge_type = $xaction->getMetadataValue('edge:type');
@ -358,6 +366,7 @@ final class PhabricatorProjectTransactionEditor
case PhabricatorProjectTransaction::TYPE_STATUS: case PhabricatorProjectTransaction::TYPE_STATUS:
case PhabricatorProjectTransaction::TYPE_IMAGE: case PhabricatorProjectTransaction::TYPE_IMAGE:
case PhabricatorProjectTransaction::TYPE_ICON: case PhabricatorProjectTransaction::TYPE_ICON:
case PhabricatorProjectTransaction::TYPE_COLOR:
PhabricatorPolicyFilter::requireCapability( PhabricatorPolicyFilter::requireCapability(
$this->requireActor(), $this->requireActor(),
$object, $object,

View file

@ -50,6 +50,7 @@ final class PhabricatorProjectPHIDTypeProject extends PhabricatorPHIDType {
$handle->setURI("/tag/{$slug}/"); $handle->setURI("/tag/{$slug}/");
$handle->setImageURI($project->getProfileImageURI()); $handle->setImageURI($project->getProfileImageURI());
$handle->setIcon($project->getIcon()); $handle->setIcon($project->getIcon());
$handle->setTagColor($project->getColor());
if ($project->isArchived()) { if ($project->isArchived()) {
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED); $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);

View file

@ -15,6 +15,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO
protected $phrictionSlug; protected $phrictionSlug;
protected $profileImagePHID; protected $profileImagePHID;
protected $icon; protected $icon;
protected $color;
protected $viewPolicy; protected $viewPolicy;
protected $editPolicy; protected $editPolicy;
@ -29,12 +30,14 @@ final class PhabricatorProject extends PhabricatorProjectDAO
private $slugs = self::ATTACHABLE; private $slugs = self::ATTACHABLE;
const DEFAULT_ICON = 'fa-briefcase'; const DEFAULT_ICON = 'fa-briefcase';
const DEFAULT_COLOR = 'blue';
public static function initializeNewProject(PhabricatorUser $actor) { public static function initializeNewProject(PhabricatorUser $actor) {
return id(new PhabricatorProject()) return id(new PhabricatorProject())
->setName('') ->setName('')
->setAuthorPHID($actor->getPHID()) ->setAuthorPHID($actor->getPHID())
->setIcon(self::DEFAULT_ICON) ->setIcon(self::DEFAULT_ICON)
->setColor(self::DEFAULT_COLOR)
->setViewPolicy(PhabricatorPolicies::POLICY_USER) ->setViewPolicy(PhabricatorPolicies::POLICY_USER)
->setEditPolicy(PhabricatorPolicies::POLICY_USER) ->setEditPolicy(PhabricatorPolicies::POLICY_USER)
->setJoinPolicy(PhabricatorPolicies::POLICY_USER) ->setJoinPolicy(PhabricatorPolicies::POLICY_USER)
@ -208,6 +211,14 @@ final class PhabricatorProject extends PhabricatorProjectDAO
return $this->assertAttached($this->slugs); return $this->assertAttached($this->slugs);
} }
public function getColor() {
if ($this->isArchived()) {
return PHUITagView::COLOR_DISABLED;
}
return $this->color;
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */ /* -( PhabricatorSubscribableInterface )----------------------------------- */

View file

@ -8,6 +8,7 @@ final class PhabricatorProjectTransaction
const TYPE_STATUS = 'project:status'; const TYPE_STATUS = 'project:status';
const TYPE_IMAGE = 'project:image'; const TYPE_IMAGE = 'project:image';
const TYPE_ICON = 'project:icon'; const TYPE_ICON = 'project:icon';
const TYPE_COLOR = 'project:color';
// NOTE: This is deprecated, members are just a normal edge now. // NOTE: This is deprecated, members are just a normal edge now.
const TYPE_MEMBERS = 'project:members'; const TYPE_MEMBERS = 'project:members';
@ -93,6 +94,12 @@ final class PhabricatorProjectTransaction
$author_handle, $author_handle,
PhabricatorProjectIcon::getLabel($new)); PhabricatorProjectIcon::getLabel($new));
case PhabricatorProjectTransaction::TYPE_COLOR:
return pht(
'%s set this project\'s color to %s.',
$author_handle,
PHUITagView::getShadeName($new));
case PhabricatorProjectTransaction::TYPE_SLUGS: case PhabricatorProjectTransaction::TYPE_SLUGS:
$add = array_diff($new, $old); $add = array_diff($new, $old);
$rem = array_diff($old, $new); $rem = array_diff($old, $new);

View file

@ -288,7 +288,7 @@ final class PhabricatorTypeaheadCommonDatasourceController
->setDisplayType('Project') ->setDisplayType('Project')
->setURI('/project/view/'.$proj->getID().'/') ->setURI('/project/view/'.$proj->getID().'/')
->setPHID($proj->getPHID()) ->setPHID($proj->getPHID())
->setIcon($proj->getIcon().' bluegrey') ->setIcon($proj->getIcon().' '.$proj->getColor())
->setPriorityType('proj') ->setPriorityType('proj')
->setClosed($closed); ->setClosed($closed);

View file

@ -586,5 +586,4 @@ final class PHUIIconView extends AphrontTagView {
); );
} }
} }

View file

@ -211,20 +211,29 @@ final class PHUITagView extends AphrontView {
} }
public static function getShades() { public static function getShades() {
return array_keys(self::getShadeMap());
}
public static function getShadeMap() {
return array( return array(
self::COLOR_RED, self::COLOR_RED => pht('Red'),
self::COLOR_ORANGE, self::COLOR_ORANGE => pht('Orange'),
self::COLOR_YELLOW, self::COLOR_YELLOW => pht('Yellow'),
self::COLOR_BLUE, self::COLOR_BLUE => pht('Blue'),
self::COLOR_INDIGO, self::COLOR_INDIGO => pht('Indigo'),
self::COLOR_VIOLET, self::COLOR_VIOLET => pht('Violet'),
self::COLOR_GREEN, self::COLOR_GREEN => pht('Green'),
self::COLOR_GREY, self::COLOR_GREY => pht('Grey'),
self::COLOR_CHECKERED, self::COLOR_CHECKERED => pht('Checkered'),
self::COLOR_DISABLED, self::COLOR_DISABLED => pht('Disabled'),
); );
} }
public static function getShadeName($shade) {
return idx(self::getShadeMap(), $shade, $shade);
}
public function setExternal($external) { public function setExternal($external) {
$this->external = $external; $this->external = $external;
return $this; return $this;