mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +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:
parent
38ae1191de
commit
be47f2141a
13 changed files with 117 additions and 30 deletions
|
@ -7,7 +7,7 @@
|
|||
return array(
|
||||
'names' =>
|
||||
array(
|
||||
'core.pkg.css' => 'c2e44da2',
|
||||
'core.pkg.css' => 'e428441c',
|
||||
'core.pkg.js' => '8c184823',
|
||||
'darkconsole.pkg.js' => 'df001cab',
|
||||
'differential.pkg.css' => '4a93db37',
|
||||
|
@ -142,7 +142,7 @@ return array(
|
|||
'rsrc/css/phui/phui-remarkup-preview.css' => '19ad512b',
|
||||
'rsrc/css/phui/phui-spacing.css' => '042804d6',
|
||||
'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-timeline-view.css' => 'bbd990d0',
|
||||
'rsrc/css/phui/phui-workboard-view.css' => '2bf82d00',
|
||||
|
@ -787,7 +787,7 @@ return array(
|
|||
'phui-remarkup-preview-css' => '19ad512b',
|
||||
'phui-spacing-css' => '042804d6',
|
||||
'phui-status-list-view-css' => '2f562399',
|
||||
'phui-tag-view-css' => '67017012',
|
||||
'phui-tag-view-css' => '8ac14ba8',
|
||||
'phui-text-css' => '23e9b4b7',
|
||||
'phui-timeline-view-css' => 'bbd990d0',
|
||||
'phui-workboard-view-css' => '2bf82d00',
|
||||
|
|
2
resources/sql/autopatches/20140624.projcolor.1.sql
Normal file
2
resources/sql/autopatches/20140624.projcolor.1.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE {$NAMESPACE}_project.project
|
||||
ADD color VARCHAR(32) NOT NULL COLLATE utf8_bin;
|
2
resources/sql/autopatches/20140624.projcolor.2.sql
Normal file
2
resources/sql/autopatches/20140624.projcolor.2.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
UPDATE {$NAMESPACE}_project.project
|
||||
SET color = 'blue' WHERE color = '';
|
|
@ -11,6 +11,7 @@ final class PhabricatorObjectHandle
|
|||
private $title;
|
||||
private $imageURI;
|
||||
private $icon;
|
||||
private $tagColor;
|
||||
private $timestamp;
|
||||
private $status = PhabricatorObjectHandleStatus::STATUS_OPEN;
|
||||
private $complete;
|
||||
|
@ -30,8 +31,24 @@ final class PhabricatorObjectHandle
|
|||
return $this->getTypeIcon();
|
||||
}
|
||||
|
||||
public function getIconColor() {
|
||||
return 'bluegrey';
|
||||
public function setTagColor($color) {
|
||||
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() {
|
||||
|
@ -262,7 +279,8 @@ final class PhabricatorObjectHandle
|
|||
public function renderTag() {
|
||||
return id(new PHUITagView())
|
||||
->setType(PHUITagView::TYPE_OBJECT)
|
||||
->setIcon($this->getIcon().' '.$this->getIconColor())
|
||||
->setShade($this->getTagColor())
|
||||
->setIcon($this->getIcon())
|
||||
->setHref($this->getURI())
|
||||
->setName($this->getLinkName());
|
||||
}
|
||||
|
|
|
@ -30,11 +30,20 @@ final class PhabricatorProjectEditIconController
|
|||
$edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/');
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$xactions = array();
|
||||
|
||||
$v_icon = $request->getStr('icon');
|
||||
$v_icon_color = $request->getStr('color');
|
||||
|
||||
$type_icon = PhabricatorProjectTransaction::TYPE_ICON;
|
||||
$xactions = array(id(new PhabricatorProjectTransaction())
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->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())
|
||||
->setActor($viewer)
|
||||
|
@ -47,6 +56,20 @@ final class PhabricatorProjectEditIconController
|
|||
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');
|
||||
Javelin::initBehavior('phabricator-tooltips');
|
||||
|
||||
|
@ -55,7 +78,7 @@ final class PhabricatorProjectEditIconController
|
|||
$buttons = array();
|
||||
foreach ($project_icons as $icon => $label) {
|
||||
$view = id(new PHUIIconView())
|
||||
->setIconFont($icon.' bluegrey');
|
||||
->setIconFont($icon);
|
||||
|
||||
$aural = javelin_tag(
|
||||
'span',
|
||||
|
@ -66,10 +89,8 @@ final class PhabricatorProjectEditIconController
|
|||
|
||||
if ($icon == $project->getIcon()) {
|
||||
$class_extra = ' selected';
|
||||
$tip = $label.pht(' - selected');
|
||||
} else {
|
||||
$class_extra = null;
|
||||
$tip = $label;
|
||||
}
|
||||
|
||||
$buttons[] = javelin_tag(
|
||||
|
@ -81,7 +102,7 @@ final class PhabricatorProjectEditIconController
|
|||
'type' => 'submit',
|
||||
'sigil' => 'has-tooltip',
|
||||
'meta' => array(
|
||||
'tip' => $tip,
|
||||
'tip' => $label,
|
||||
)
|
||||
),
|
||||
array(
|
||||
|
@ -100,12 +121,14 @@ final class PhabricatorProjectEditIconController
|
|||
),
|
||||
$buttons);
|
||||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($viewer)
|
||||
->setTitle(pht('Choose Project Icon'))
|
||||
->appendChild($buttons)
|
||||
->addCancelButton($edit_uri);
|
||||
$color_form->appendChild(
|
||||
id(new AphrontFormMarkupControl())
|
||||
->setLabel(pht('Icon'))
|
||||
->setValue($buttons));
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
return $this->newDialog()
|
||||
->setTitle(pht('Choose Project Icon'))
|
||||
->appendChild($color_form->buildLayoutView())
|
||||
->addCancelButton($edit_uri);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,6 +145,12 @@ final class PhabricatorProjectEditMainController
|
|||
$viewer,
|
||||
$project);
|
||||
|
||||
$this->loadHandles(array($project->getPHID()));
|
||||
|
||||
$view->addProperty(
|
||||
pht('Looks Like'),
|
||||
$this->getHandle($project->getPHID())->renderTag());
|
||||
|
||||
$view->addProperty(
|
||||
pht('Visible To'),
|
||||
$descriptions[PhabricatorPolicyCapability::CAN_VIEW]);
|
||||
|
|
|
@ -16,6 +16,7 @@ final class PhabricatorProjectTransactionEditor
|
|||
$types[] = PhabricatorProjectTransaction::TYPE_STATUS;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_IMAGE;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_ICON;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_COLOR;
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
@ -38,6 +39,8 @@ final class PhabricatorProjectTransactionEditor
|
|||
return $object->getProfileImagePHID();
|
||||
case PhabricatorProjectTransaction::TYPE_ICON:
|
||||
return $object->getIcon();
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
return $object->getColor();
|
||||
}
|
||||
|
||||
return parent::getCustomTransactionOldValue($object, $xaction);
|
||||
|
@ -53,6 +56,7 @@ final class PhabricatorProjectTransactionEditor
|
|||
case PhabricatorProjectTransaction::TYPE_STATUS:
|
||||
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
||||
case PhabricatorProjectTransaction::TYPE_ICON:
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
return $xaction->getNewValue();
|
||||
}
|
||||
|
||||
|
@ -79,6 +83,9 @@ final class PhabricatorProjectTransactionEditor
|
|||
case PhabricatorProjectTransaction::TYPE_ICON:
|
||||
$object->setIcon($xaction->getNewValue());
|
||||
return;
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
$object->setColor($xaction->getNewValue());
|
||||
return;
|
||||
case PhabricatorTransactions::TYPE_EDGE:
|
||||
return;
|
||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||
|
@ -181,6 +188,7 @@ final class PhabricatorProjectTransactionEditor
|
|||
case PhabricatorProjectTransaction::TYPE_STATUS:
|
||||
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
||||
case PhabricatorProjectTransaction::TYPE_ICON:
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
return;
|
||||
case PhabricatorTransactions::TYPE_EDGE:
|
||||
$edge_type = $xaction->getMetadataValue('edge:type');
|
||||
|
@ -358,6 +366,7 @@ final class PhabricatorProjectTransactionEditor
|
|||
case PhabricatorProjectTransaction::TYPE_STATUS:
|
||||
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
||||
case PhabricatorProjectTransaction::TYPE_ICON:
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
PhabricatorPolicyFilter::requireCapability(
|
||||
$this->requireActor(),
|
||||
$object,
|
||||
|
|
|
@ -50,6 +50,7 @@ final class PhabricatorProjectPHIDTypeProject extends PhabricatorPHIDType {
|
|||
$handle->setURI("/tag/{$slug}/");
|
||||
$handle->setImageURI($project->getProfileImageURI());
|
||||
$handle->setIcon($project->getIcon());
|
||||
$handle->setTagColor($project->getColor());
|
||||
|
||||
if ($project->isArchived()) {
|
||||
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
|
||||
|
|
|
@ -15,6 +15,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
protected $phrictionSlug;
|
||||
protected $profileImagePHID;
|
||||
protected $icon;
|
||||
protected $color;
|
||||
|
||||
protected $viewPolicy;
|
||||
protected $editPolicy;
|
||||
|
@ -29,12 +30,14 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
private $slugs = self::ATTACHABLE;
|
||||
|
||||
const DEFAULT_ICON = 'fa-briefcase';
|
||||
const DEFAULT_COLOR = 'blue';
|
||||
|
||||
public static function initializeNewProject(PhabricatorUser $actor) {
|
||||
return id(new PhabricatorProject())
|
||||
->setName('')
|
||||
->setAuthorPHID($actor->getPHID())
|
||||
->setIcon(self::DEFAULT_ICON)
|
||||
->setColor(self::DEFAULT_COLOR)
|
||||
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
|
||||
->setEditPolicy(PhabricatorPolicies::POLICY_USER)
|
||||
->setJoinPolicy(PhabricatorPolicies::POLICY_USER)
|
||||
|
@ -208,6 +211,14 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
return $this->assertAttached($this->slugs);
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
if ($this->isArchived()) {
|
||||
return PHUITagView::COLOR_DISABLED;
|
||||
}
|
||||
|
||||
return $this->color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
||||
|
|
|
@ -8,6 +8,7 @@ final class PhabricatorProjectTransaction
|
|||
const TYPE_STATUS = 'project:status';
|
||||
const TYPE_IMAGE = 'project:image';
|
||||
const TYPE_ICON = 'project:icon';
|
||||
const TYPE_COLOR = 'project:color';
|
||||
|
||||
// NOTE: This is deprecated, members are just a normal edge now.
|
||||
const TYPE_MEMBERS = 'project:members';
|
||||
|
@ -93,6 +94,12 @@ final class PhabricatorProjectTransaction
|
|||
$author_handle,
|
||||
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:
|
||||
$add = array_diff($new, $old);
|
||||
$rem = array_diff($old, $new);
|
||||
|
|
|
@ -288,7 +288,7 @@ final class PhabricatorTypeaheadCommonDatasourceController
|
|||
->setDisplayType('Project')
|
||||
->setURI('/project/view/'.$proj->getID().'/')
|
||||
->setPHID($proj->getPHID())
|
||||
->setIcon($proj->getIcon().' bluegrey')
|
||||
->setIcon($proj->getIcon().' '.$proj->getColor())
|
||||
->setPriorityType('proj')
|
||||
->setClosed($closed);
|
||||
|
||||
|
|
|
@ -586,5 +586,4 @@ final class PHUIIconView extends AphrontTagView {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -211,20 +211,29 @@ final class PHUITagView extends AphrontView {
|
|||
}
|
||||
|
||||
public static function getShades() {
|
||||
return array_keys(self::getShadeMap());
|
||||
}
|
||||
|
||||
public static function getShadeMap() {
|
||||
return array(
|
||||
self::COLOR_RED,
|
||||
self::COLOR_ORANGE,
|
||||
self::COLOR_YELLOW,
|
||||
self::COLOR_BLUE,
|
||||
self::COLOR_INDIGO,
|
||||
self::COLOR_VIOLET,
|
||||
self::COLOR_GREEN,
|
||||
self::COLOR_GREY,
|
||||
self::COLOR_CHECKERED,
|
||||
self::COLOR_DISABLED,
|
||||
self::COLOR_RED => pht('Red'),
|
||||
self::COLOR_ORANGE => pht('Orange'),
|
||||
self::COLOR_YELLOW => pht('Yellow'),
|
||||
self::COLOR_BLUE => pht('Blue'),
|
||||
self::COLOR_INDIGO => pht('Indigo'),
|
||||
self::COLOR_VIOLET => pht('Violet'),
|
||||
self::COLOR_GREEN => pht('Green'),
|
||||
self::COLOR_GREY => pht('Grey'),
|
||||
self::COLOR_CHECKERED => pht('Checkered'),
|
||||
self::COLOR_DISABLED => pht('Disabled'),
|
||||
);
|
||||
}
|
||||
|
||||
public static function getShadeName($shade) {
|
||||
return idx(self::getShadeMap(), $shade, $shade);
|
||||
}
|
||||
|
||||
|
||||
public function setExternal($external) {
|
||||
$this->external = $external;
|
||||
return $this;
|
||||
|
|
Loading…
Reference in a new issue