Skip to content

Commit 19f4e86

Browse files
committed
Add an edit link on hover for Project profile images
Summary: Minor point of polish, but feels really nice. Hover over photo and edit a link to change the picture. Test Plan: hover hover, clicky clicky {F1069179} Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D15109
1 parent cb1c342 commit 19f4e86

File tree

4 files changed

+77
-8
lines changed

4 files changed

+77
-8
lines changed

resources/celerity/map.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
return array(
99
'names' => array(
10-
'core.pkg.css' => '92f16374',
10+
'core.pkg.css' => '956d6a9f',
1111
'core.pkg.js' => '573e6664',
1212
'darkconsole.pkg.js' => 'e7393ebb',
1313
'differential.pkg.css' => '2de124c9',
@@ -133,7 +133,7 @@
133133
'rsrc/css/phui/phui-fontkit.css' => '9cda225e',
134134
'rsrc/css/phui/phui-form-view.css' => '4a1a0f5e',
135135
'rsrc/css/phui/phui-form.css' => '0b98e572',
136-
'rsrc/css/phui/phui-header-view.css' => '235f0d7d',
136+
'rsrc/css/phui/phui-header-view.css' => 'd53cc835',
137137
'rsrc/css/phui/phui-icon-set-selector.css' => '1ab67aad',
138138
'rsrc/css/phui/phui-icon.css' => '3f33ab57',
139139
'rsrc/css/phui/phui-image-mask.css' => '5a8b09c8',
@@ -808,7 +808,7 @@
808808
'phui-fontkit-css' => '9cda225e',
809809
'phui-form-css' => '0b98e572',
810810
'phui-form-view-css' => '4a1a0f5e',
811-
'phui-header-view-css' => '235f0d7d',
811+
'phui-header-view-css' => 'd53cc835',
812812
'phui-icon-set-selector-css' => '1ab67aad',
813813
'phui-icon-view-css' => '3f33ab57',
814814
'phui-image-mask-css' => '5a8b09c8',

src/applications/project/controller/PhabricatorProjectProfileController.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ public function handleRequest(AphrontRequest $request) {
3131
$header->setStatus('fa-ban', 'red', pht('Archived'));
3232
}
3333

34+
$can_edit = PhabricatorPolicyFilter::hasCapability(
35+
$viewer,
36+
$project,
37+
PhabricatorPolicyCapability::CAN_EDIT);
38+
39+
if ($can_edit) {
40+
$header->setImageEditURL($this->getApplicationURI("picture/{$id}/"));
41+
}
42+
3443
$properties = $this->buildPropertyListView($project);
3544

3645
$watch_action = $this->renderWatchAction($project);

src/view/phui/PHUIHeaderView.php

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ final class PHUIHeaderView extends AphrontTagView {
88
private $tags = array();
99
private $image;
1010
private $imageURL = null;
11+
private $imageEditURL = null;
1112
private $subheader;
1213
private $headerIcon;
1314
private $noBackground;
@@ -57,6 +58,11 @@ public function setImageURL($url) {
5758
return $this;
5859
}
5960

61+
public function setImageEditURL($url) {
62+
$this->imageEditURL = $url;
63+
return $this;
64+
}
65+
6066
public function setSubheader($subheader) {
6167
$this->subheader = $subheader;
6268
return $this;
@@ -174,16 +180,45 @@ protected function getTagAttributes() {
174180
}
175181

176182
protected function getTagContent() {
183+
177184
$image = null;
178185
if ($this->image) {
186+
$image_href = null;
187+
if ($this->imageURL) {
188+
$image_href = $this->imageURL;
189+
} else if ($this->imageEditURL) {
190+
$image_href = $this->imageEditURL;
191+
}
192+
179193
$image = phutil_tag(
180-
($this->imageURL ? 'a' : 'span'),
194+
'span',
181195
array(
182-
'href' => $this->imageURL,
183196
'class' => 'phui-header-image',
184197
'style' => 'background-image: url('.$this->image.')',
185-
),
186-
' ');
198+
));
199+
200+
if ($image_href) {
201+
$edit_view = null;
202+
if ($this->imageEditURL) {
203+
$edit_view = phutil_tag(
204+
'span',
205+
array(
206+
'class' => 'phui-header-image-edit',
207+
),
208+
pht('Edit'));
209+
}
210+
211+
$image = phutil_tag(
212+
'a',
213+
array(
214+
'href' => $image_href,
215+
'class' => 'phui-header-image-href',
216+
),
217+
array(
218+
$image,
219+
$edit_view,
220+
));
221+
}
187222
}
188223

189224
$viewer = $this->getUser();

webroot/rsrc/css/phui/phui-header-view.css

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,34 @@ body .phui-header-shell.phui-bleed-header
128128
display: inline-block;
129129
background-repeat: no-repeat;
130130
background-size: 100%;
131-
box-shadow: {$borderinset};
132131
width: 50px;
133132
height: 50px;
133+
border-radius: 3px;
134+
}
135+
136+
.phui-header-image-href {
137+
position: relative;
138+
display: block;
139+
}
140+
141+
.phui-header-image-edit {
142+
display: none;
143+
}
144+
145+
.device-desktop .phui-header-image-href:hover .phui-header-image-edit {
146+
display: block;
147+
position: absolute;
148+
left: 0;
149+
background: rgba(0,0,0,0.4);
150+
color: #fff;
151+
font-weight: normal;
152+
bottom: 4px;
153+
padding: 4px 8px;
154+
font-size: 12px;
155+
}
156+
157+
.device-desktop .phui-header-image-edit:hover {
158+
text-decoration: underline;
134159
}
135160

136161
.phui-header-subheader {

0 commit comments

Comments
 (0)