mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-12 04:15:00 +01:00
Convert user profile to be more useful and use the new Project profile style
layout Summary: - Use new less-horrible layout. - Organize information more completely and sensibly. Test Plan: Looked at some profiles. Reviewers: btrahan, jungejason Reviewed By: jungejason CC: aran, jungejason Differential Revision: https://secure.phabricator.com/D1281
This commit is contained in:
parent
46439ee8a4
commit
2e6ab9b9a6
2 changed files with 80 additions and 57 deletions
|
@ -37,6 +37,8 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
require_celerity_resource('phabricator-profile-css');
|
||||||
|
|
||||||
$profile = id(new PhabricatorUserProfile())->loadOneWhere(
|
$profile = id(new PhabricatorUserProfile())->loadOneWhere(
|
||||||
'userPHID = %s',
|
'userPHID = %s',
|
||||||
$user->getPHID());
|
$user->getPHID());
|
||||||
|
@ -44,16 +46,29 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
|
||||||
$profile = new PhabricatorUserProfile();
|
$profile = new PhabricatorUserProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
$links = array();
|
$nav = new AphrontSideNavFilterView();
|
||||||
|
$nav->setBaseURI(new PhutilURI('/p/'.$user->getUserName().'/'));
|
||||||
|
$nav->addFilter('feed', 'Feed');
|
||||||
|
$nav->addFilter('about', 'About');
|
||||||
|
|
||||||
if ($user->getPHID() == $viewer->getPHID()) {
|
$nav->addSpacer();
|
||||||
$links[] = phutil_render_tag(
|
$nav->addLabel('Activity');
|
||||||
'a',
|
|
||||||
array(
|
$external_arrow = "\xE2\x86\x97";
|
||||||
'href' => '/settings/page/profile/',
|
$nav->addFilter(
|
||||||
),
|
null,
|
||||||
'Edit Profile');
|
"Revisions {$external_arrow}",
|
||||||
}
|
'/differential/filter/revisions/?phid='.$user->getPHID());
|
||||||
|
|
||||||
|
$nav->addFilter(
|
||||||
|
null,
|
||||||
|
"Tasks {$external_arrow}",
|
||||||
|
'/maniphest/view/action/?users='.$user->getPHID());
|
||||||
|
|
||||||
|
$nav->addFilter(
|
||||||
|
null,
|
||||||
|
"Commits {$external_arrow}",
|
||||||
|
'/diffusion/author/'.$user->getUserName().'/');
|
||||||
|
|
||||||
$oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere(
|
$oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere(
|
||||||
'userID = %d',
|
'userID = %d',
|
||||||
|
@ -61,6 +76,7 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
|
||||||
$oauths = mpull($oauths, null, 'getOAuthProvider');
|
$oauths = mpull($oauths, null, 'getOAuthProvider');
|
||||||
|
|
||||||
$providers = PhabricatorOAuthProvider::getAllProviders();
|
$providers = PhabricatorOAuthProvider::getAllProviders();
|
||||||
|
$added_spacer = false;
|
||||||
foreach ($providers as $provider) {
|
foreach ($providers as $provider) {
|
||||||
if (!$provider->isProviderEnabled()) {
|
if (!$provider->isProviderEnabled()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -76,28 +92,26 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
|
||||||
$href = $oauths[$provider_key]->getAccountURI();
|
$href = $oauths[$provider_key]->getAccountURI();
|
||||||
|
|
||||||
if ($href) {
|
if ($href) {
|
||||||
$links[] = phutil_render_tag(
|
if (!$added_spacer) {
|
||||||
'a',
|
$nav->addSpacer();
|
||||||
array(
|
$nav->addLabel('Linked Accounts');
|
||||||
'href' => $href,
|
$added_spacer = true;
|
||||||
),
|
}
|
||||||
phutil_escape_html($name));
|
$nav->addFilter(null, $name.' '.$external_arrow, $href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: perhaps, if someone wants to add to the profile of the user the
|
$this->page = $nav->selectFilter($this->page, 'feed');
|
||||||
// ability to show the task/revisions where he is working/commenting
|
|
||||||
// on, this has to be changed to something like
|
|
||||||
// |$this->page = key($pages)|, since the "page" regexp was added to
|
|
||||||
// the aphrontconfiguration.
|
|
||||||
if (empty($links[$this->page])) {
|
|
||||||
$this->page = 'action';
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($this->page) {
|
switch ($this->page) {
|
||||||
default:
|
case 'feed':
|
||||||
|
$content = $this->renderUserFeed($user);
|
||||||
|
break;
|
||||||
|
case 'about':
|
||||||
$content = $this->renderBasicInformation($user, $profile);
|
$content = $this->renderBasicInformation($user, $profile);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw new Exception("Unknown page '{$this->page}'!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$src_phid = $profile->getProfileImagePHID();
|
$src_phid = $profile->getProfileImagePHID();
|
||||||
|
@ -105,36 +119,31 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
|
||||||
$src_phid = $user->getProfileImagePHID();
|
$src_phid = $user->getProfileImagePHID();
|
||||||
}
|
}
|
||||||
$picture = PhabricatorFileURI::getViewURIForPHID($src_phid);
|
$picture = PhabricatorFileURI::getViewURIForPHID($src_phid);
|
||||||
$title = nonempty($profile->getTitle(), 'Untitled Document');
|
|
||||||
$realname = '('.$user->getRealName().')';
|
|
||||||
|
|
||||||
$profile = new PhabricatorProfileView();
|
$header = new PhabricatorProfileHeaderView();
|
||||||
$profile->setProfilePicture($picture);
|
$header
|
||||||
$profile->setProfileNames(
|
->setProfilePicture($picture)
|
||||||
$user->getUserName(),
|
->setName($user->getUserName().' ('.$user->getRealName().')')
|
||||||
$realname,
|
->setDescription($profile->getTitle());
|
||||||
$title);
|
|
||||||
foreach ($links as $page => $name) {
|
$header->appendChild($nav);
|
||||||
if (is_integer($page)) {
|
$nav->appendChild(
|
||||||
$profile->addProfileItem(
|
'<div style="padding: 1em;">'.$content.'</div>');
|
||||||
phutil_render_tag(
|
|
||||||
'span',
|
if ($user->getPHID() == $viewer->getPHID()) {
|
||||||
array(),
|
$nav->addSpacer();
|
||||||
$name));
|
$nav->addFilter(null, 'Edit Profile...', '/settings/page/profile/');
|
||||||
} else {
|
|
||||||
$profile->addProfileItem($page);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile->appendChild($content);
|
|
||||||
return $this->buildStandardPageResponse(
|
return $this->buildStandardPageResponse(
|
||||||
$profile,
|
$header,
|
||||||
array(
|
array(
|
||||||
'title' => $user->getUsername(),
|
'title' => $user->getUsername(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderBasicInformation($user, $profile) {
|
private function renderBasicInformation($user, $profile) {
|
||||||
|
|
||||||
$blurb = nonempty(
|
$blurb = nonempty(
|
||||||
$profile->getBlurb(),
|
$profile->getBlurb(),
|
||||||
'//Nothing is known about this rare specimen.//');
|
'//Nothing is known about this rare specimen.//');
|
||||||
|
@ -182,19 +191,28 @@ class PhabricatorPeopleProfileController extends PhabricatorPeopleController {
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
$content .=
|
|
||||||
'<div class="phabricator-profile-info-group">
|
|
||||||
<h1 class="phabricator-profile-info-header">Recent Activities</h1>
|
|
||||||
<div class="phabricator-profile-info-pane">
|
|
||||||
<table class="phabricator-profile-info-table">
|
|
||||||
<tr>
|
|
||||||
<th>Commits</th>
|
|
||||||
<td>'.$commit_list.'</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>';
|
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function renderUserFeed(PhabricatorUser $user) {
|
||||||
|
$query = new PhabricatorFeedQuery();
|
||||||
|
$query->setFilterPHIDs(
|
||||||
|
array(
|
||||||
|
$user->getPHID(),
|
||||||
|
));
|
||||||
|
$stories = $query->execute();
|
||||||
|
|
||||||
|
$builder = new PhabricatorFeedBuilder($stories);
|
||||||
|
$builder->setUser($this->getRequest()->getUser());
|
||||||
|
$view = $builder->buildView();
|
||||||
|
|
||||||
|
return
|
||||||
|
'<div class="phabricator-profile-info-group">
|
||||||
|
<h1 class="phabricator-profile-info-header">Activity Feed</h1>
|
||||||
|
<div class="phabricator-profile-info-pane">
|
||||||
|
'.$view->render().'
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,16 +8,21 @@
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/response/404');
|
phutil_require_module('phabricator', 'aphront/response/404');
|
||||||
phutil_require_module('phabricator', 'applications/auth/oauth/provider/base');
|
phutil_require_module('phabricator', 'applications/auth/oauth/provider/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/feed/builder/feed');
|
||||||
|
phutil_require_module('phabricator', 'applications/feed/query');
|
||||||
phutil_require_module('phabricator', 'applications/files/uri');
|
phutil_require_module('phabricator', 'applications/files/uri');
|
||||||
phutil_require_module('phabricator', 'applications/markup/engine');
|
phutil_require_module('phabricator', 'applications/markup/engine');
|
||||||
phutil_require_module('phabricator', 'applications/people/controller/base');
|
phutil_require_module('phabricator', 'applications/people/controller/base');
|
||||||
phutil_require_module('phabricator', 'applications/people/storage/profile');
|
phutil_require_module('phabricator', 'applications/people/storage/profile');
|
||||||
phutil_require_module('phabricator', 'applications/people/storage/user');
|
phutil_require_module('phabricator', 'applications/people/storage/user');
|
||||||
phutil_require_module('phabricator', 'applications/people/storage/useroauthinfo');
|
phutil_require_module('phabricator', 'applications/people/storage/useroauthinfo');
|
||||||
phutil_require_module('phabricator', 'view/layout/profile');
|
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||||
|
phutil_require_module('phabricator', 'view/layout/profileheader');
|
||||||
|
phutil_require_module('phabricator', 'view/layout/sidenavfilter');
|
||||||
phutil_require_module('phabricator', 'view/utils');
|
phutil_require_module('phabricator', 'view/utils');
|
||||||
|
|
||||||
phutil_require_module('phutil', 'markup');
|
phutil_require_module('phutil', 'markup');
|
||||||
|
phutil_require_module('phutil', 'parser/uri');
|
||||||
phutil_require_module('phutil', 'utils');
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue