Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15452485
D18174.id43748.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
D18174.id43748.diff
View Options
diff --git a/src/applications/project/config/PhabricatorProjectConfigOptions.php b/src/applications/project/config/PhabricatorProjectConfigOptions.php
--- a/src/applications/project/config/PhabricatorProjectConfigOptions.php
+++ b/src/applications/project/config/PhabricatorProjectConfigOptions.php
@@ -34,6 +34,8 @@
- `key` //Required string.// Internal key identifying the icon.
- `name` //Required string.// Human-readable icon name.
- `icon` //Required string.// Specifies which actual icon image to use.
+ - `image` //Optional string.// Selects a default image. Select an image from
+ `resources/builtins`.
- `default` //Optional bool.// Selects a default icon. Exactly one icon must
be selected as the default.
- `disabled` //Optional bool.// If true, this icon will no longer be
diff --git a/src/applications/project/controller/PhabricatorProjectEditPictureController.php b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
--- a/src/applications/project/controller/PhabricatorProjectEditPictureController.php
+++ b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
@@ -98,7 +98,9 @@
$form = id(new PHUIFormLayoutView())
->setUser($viewer);
- $default_image = PhabricatorFile::loadBuiltin($viewer, 'project.png');
+ $builtin = PhabricatorProjectIconSet::getIconImage(
+ $project->getIcon());
+ $default_image = PhabricatorFile::loadBuiltin($this->getViewer(), $builtin);
$images = array();
diff --git a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
--- a/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
+++ b/src/applications/project/editor/PhabricatorProjectTransactionEditor.php
@@ -296,10 +296,6 @@
}
}
- if ($this->getIsNewObject()) {
- $this->setDefaultProfilePicture($object);
- }
-
// TODO: We should dump an informational transaction onto the parent
// project to show that we created the sub-thing.
@@ -457,34 +453,6 @@
return $results;
}
- private function setDefaultProfilePicture(PhabricatorProject $project) {
- if ($project->isMilestone()) {
- return;
- }
-
- $compose_color = $project->getDisplayIconComposeColor();
- $compose_icon = $project->getDisplayIconComposeIcon();
-
- $builtin = id(new PhabricatorFilesComposeIconBuiltinFile())
- ->setColor($compose_color)
- ->setIcon($compose_icon);
-
- $data = $builtin->loadBuiltinFileData();
-
- $file = PhabricatorFile::newFromFileData(
- $data,
- array(
- 'name' => $builtin->getBuiltinDisplayName(),
- 'profile' => true,
- 'canCDN' => true,
- ));
-
- $project
- ->setProfileImagePHID($file->getPHID())
- ->save();
- }
-
-
protected function shouldApplyHeraldRules(
PhabricatorLiskDAO $object,
array $xactions) {
diff --git a/src/applications/project/icon/PhabricatorProjectIconSet.php b/src/applications/project/icon/PhabricatorProjectIconSet.php
--- a/src/applications/project/icon/PhabricatorProjectIconSet.php
+++ b/src/applications/project/icon/PhabricatorProjectIconSet.php
@@ -18,87 +18,104 @@
'icon' => 'fa-briefcase',
'name' => pht('Project'),
'default' => true,
+ 'image' => 'projects/v3/briefcase.png',
),
array(
'key' => 'tag',
'icon' => 'fa-tags',
'name' => pht('Tag'),
+ 'image' => 'projects/v3/tag.png',
),
array(
'key' => 'policy',
'icon' => 'fa-lock',
'name' => pht('Policy'),
+ 'image' => 'projects/v3/lock.png',
),
array(
'key' => 'group',
'icon' => 'fa-users',
'name' => pht('Group'),
+ 'image' => 'projects/v3/people.png',
),
array(
'key' => 'folder',
'icon' => 'fa-folder',
'name' => pht('Folder'),
+ 'image' => 'projects/v3/folder.png',
),
array(
'key' => 'timeline',
'icon' => 'fa-calendar',
'name' => pht('Timeline'),
+ 'image' => 'projects/v3/calendar.png',
),
array(
'key' => 'goal',
'icon' => 'fa-flag-checkered',
'name' => pht('Goal'),
+ 'image' => 'projects/v3/flag.png',
),
array(
'key' => 'release',
'icon' => 'fa-truck',
'name' => pht('Release'),
+ 'image' => 'projects/v3/truck.png',
),
array(
'key' => 'bugs',
'icon' => 'fa-bug',
'name' => pht('Bugs'),
+ 'image' => 'projects/v3/bug.png',
),
array(
'key' => 'cleanup',
'icon' => 'fa-trash-o',
'name' => pht('Cleanup'),
+ 'image' => 'projects/v3/trash.png',
),
array(
'key' => 'umbrella',
'icon' => 'fa-umbrella',
'name' => pht('Umbrella'),
+ 'image' => 'projects/v3/umbrella.png',
),
array(
'key' => 'communication',
'icon' => 'fa-envelope',
'name' => pht('Communication'),
+ 'image' => 'projects/v3/mail.png',
),
array(
'key' => 'organization',
'icon' => 'fa-building',
'name' => pht('Organization'),
+ 'image' => 'projects/v3/organization.png',
),
array(
'key' => 'infrastructure',
'icon' => 'fa-cloud',
'name' => pht('Infrastructure'),
+ 'image' => 'projects/v3/cloud.png',
),
array(
'key' => 'account',
'icon' => 'fa-credit-card',
'name' => pht('Account'),
+ 'image' => 'projects/v3/creditcard.png',
),
array(
'key' => 'experimental',
'icon' => 'fa-flask',
'name' => pht('Experimental'),
+ 'image' => 'projects/v3/experimental.png',
),
array(
'key' => 'milestone',
'icon' => 'fa-map-marker',
'name' => pht('Milestone'),
'special' => self::SPECIAL_MILESTONE,
+ 'image' => 'projects/v3/briefcase.png',
),
);
}
@@ -149,6 +166,11 @@
return idx($spec, 'name', null);
}
+ public static function getIconImage($key) {
+ $spec = self::getIconSpec($key);
+ return idx($spec, 'image', null);
+ }
+
private static function getIconSpec($key) {
$icons = self::getIconSpecifications();
foreach ($icons as $icon) {
@@ -190,6 +212,7 @@
'key' => 'string',
'name' => 'string',
'icon' => 'string',
+ 'image' => 'optional string',
'special' => 'optional string',
'disabled' => 'optional bool',
'default' => 'optional bool',
@@ -239,6 +262,21 @@
$is_disabled = idx($value, 'disabled');
+ if (idx($value, 'image')) {
+ $builtin = idx($value, 'image');
+ $root = dirname(phutil_get_library_root('phabricator'));
+ $image = $root.'/resources/builtin/'.$builtin;
+
+ if (!file_exists($image)) {
+ throw new Exception(
+ pht(
+ 'The project image ("%s") specified for ("%s") '.
+ 'was not found in the folder "resources/builtin."',
+ $builtin,
+ $key));
+ }
+ }
+
if (idx($value, 'default')) {
if ($default === null) {
if ($is_disabled) {
diff --git a/src/applications/project/query/PhabricatorProjectQuery.php b/src/applications/project/query/PhabricatorProjectQuery.php
--- a/src/applications/project/query/PhabricatorProjectQuery.php
+++ b/src/applications/project/query/PhabricatorProjectQuery.php
@@ -358,8 +358,6 @@
protected function didFilterPage(array $projects) {
if ($this->needImages) {
- $default = null;
-
$file_phids = mpull($projects, 'getProfileImagePHID');
$file_phids = array_filter($file_phids);
if ($file_phids) {
@@ -376,12 +374,9 @@
foreach ($projects as $project) {
$file = idx($files, $project->getProfileImagePHID());
if (!$file) {
- if (!$default) {
- $default = PhabricatorFile::loadBuiltin(
- $this->getViewer(),
- 'project.png');
- }
- $file = $default;
+ $builtin = PhabricatorProjectIconSet::getIconImage(
+ $project->getIcon());
+ $file = PhabricatorFile::loadBuiltin($this->getViewer(), $builtin);
}
$project->attachProfileImageFile($file);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 30, 5:13 AM (1 w, 18 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7716256
Default Alt Text
D18174.id43748.diff (8 KB)
Attached To
Mode
D18174: Choose default project image by icon
Attached
Detach File
Event Timeline
Log In to Comment