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

Add project list to user profiles

Summary: Adds which Projects a user is a member of to their profile, with a link to more. Build fallback states for no badges or no projects.

Test Plan:
Review a user with projects, without projects, with badges, without badges.

{F1084127}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15150
This commit is contained in:
Chad Little 2016-02-04 02:22:34 +00:00 committed by chad
parent 2bdbd7833d
commit 2f0571923c

View file

@ -54,23 +54,21 @@ final class PhabricatorPeopleProfileViewController
$feed = $this->buildPeopleFeed($user, $viewer);
$feed = phutil_tag_div('project-view-feed', $feed);
$projects = $this->buildProjectsView($user);
$badges = $this->buildBadgesView($user);
if ($badges) {
$columns = id(new PHUITwoColumnView())
->addClass('project-view-badges')
->setMainColumn(
array(
$properties,
$feed,
))
->setSideColumn(
array(
$badges,
));
} else {
$columns = array($properties, $feed);
}
$columns = id(new PHUITwoColumnView())
->addClass('project-view-badges')
->setMainColumn(
array(
$properties,
$feed,
))
->setSideColumn(
array(
$projects,
$badges,
));
$nav = $this->getProfileMenu();
$nav->selectFilter(PhabricatorPeopleProfilePanelEngine::PANEL_PROFILE);
@ -124,12 +122,65 @@ final class PhabricatorPeopleProfileViewController
return $view;
}
private function buildProjectsView(
PhabricatorUser $user) {
$viewer = $this->getViewer();
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withMemberPHIDs(array($user->getPHID()))
->needImages(true)
->withStatus(PhabricatorProjectQuery::STATUS_OPEN)
->execute();
$header = id(new PHUIHeaderView())
->setHeader(pht('Projects'));
if (!empty($projects)) {
$limit = 5;
$render_phids = array_slice($projects, 0, $limit);
$list = id(new PhabricatorProjectListView())
->setUser($viewer)
->setProjects($render_phids);
if (count($projects) > $limit) {
$header_text = pht(
'Projects (%s)',
phutil_count($projects));
$header = id(new PHUIHeaderView())
->setHeader($header_text)
->addActionLink(
id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-list-ul')
->setText(pht('View All'))
->setHref('/project/?member='.$user->getPHID()));
}
} else {
$error = id(new PHUIBoxView())
->addClass('mlb')
->appendChild(pht('User does not belong to any projects.'));
$list = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
->appendChild($error);
}
$box = id(new PHUIObjectBoxView())
->setHeader($header)
->appendChild($list)
->setBackground(PHUIBoxView::GREY);
return $box;
}
private function buildBadgesView(
PhabricatorUser $user) {
$viewer = $this->getViewer();
$class = 'PhabricatorBadgesApplication';
$box = null;
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$badge_phids = $user->getBadgePHIDs();
@ -150,13 +201,21 @@ final class PhabricatorPeopleProfileViewController
$flex->addItem($item);
}
$box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Badges'))
->appendChild($flex)
->setBackground(PHUIBoxView::GREY);
} else {
$error = id(new PHUIBoxView())
->addClass('mlb')
->appendChild(pht('User does not have any badges.'));
$flex = id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
->appendChild($error);
}
}
$box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Badges'))
->appendChild($flex)
->setBackground(PHUIBoxView::GREY);
return $box;
}