1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00

Fix UI for choosing a profile picture when user has no picture

Summary: Currently, we always show "current picture" even if you don't have one. In this case, the first available picture becomes the "current picture". Instead, show "current picture" only if there's actually a current picture to show.

Test Plan: {F49875}

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6432
This commit is contained in:
epriestley 2013-07-12 11:20:18 -07:00
parent 620aecb42e
commit d1e25e3d11

View file

@ -102,6 +102,7 @@ final class PhabricatorPeopleProfilePictureController
$images = array(); $images = array();
$current = $user->getProfileImagePHID(); $current = $user->getProfileImagePHID();
$has_current = false;
if ($current) { if ($current) {
$files = id(new PhabricatorFileQuery()) $files = id(new PhabricatorFileQuery())
->setViewer($viewer) ->setViewer($viewer)
@ -110,6 +111,7 @@ final class PhabricatorPeopleProfilePictureController
if ($files) { if ($files) {
$file = head($files); $file = head($files);
if ($file->isTransformableImage()) { if ($file->isTransformableImage()) {
$has_current = true;
$images[$current] = array( $images[$current] = array(
'uri' => $file->getBestURI(), 'uri' => $file->getBestURI(),
'tip' => pht('Current Picture'), 'tip' => pht('Current Picture'),
@ -242,15 +244,17 @@ final class PhabricatorPeopleProfilePictureController
$buttons[] = $button; $buttons[] = $button;
} }
if ($has_current) {
$form->appendChild( $form->appendChild(
id(new AphrontFormMarkupControl()) id(new AphrontFormMarkupControl())
->setLabel(pht('Current Picture')) ->setLabel(pht('Current Picture'))
->setValue(array_slice($buttons, 0, 1))); ->setValue(array_shift($buttons)));
}
$form->appendChild( $form->appendChild(
id(new AphrontFormMarkupControl()) id(new AphrontFormMarkupControl())
->setLabel(pht('Use Picture')) ->setLabel(pht('Use Picture'))
->setValue(array_slice($buttons, 1))); ->setValue($buttons));
$upload_head = id(new PhabricatorHeaderView()) $upload_head = id(new PhabricatorHeaderView())
->setHeader(pht('Upload New Picture')); ->setHeader(pht('Upload New Picture'));