@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Chad Little and committed by
chad
2f057192 2bdbd783

+79 -20
+79 -20
src/applications/people/controller/PhabricatorPeopleProfileViewController.php
··· 54 54 $feed = $this->buildPeopleFeed($user, $viewer); 55 55 $feed = phutil_tag_div('project-view-feed', $feed); 56 56 57 + $projects = $this->buildProjectsView($user); 57 58 $badges = $this->buildBadgesView($user); 58 59 59 - if ($badges) { 60 - $columns = id(new PHUITwoColumnView()) 61 - ->addClass('project-view-badges') 62 - ->setMainColumn( 63 - array( 64 - $properties, 65 - $feed, 66 - )) 67 - ->setSideColumn( 68 - array( 69 - $badges, 70 - )); 71 - } else { 72 - $columns = array($properties, $feed); 73 - } 60 + $columns = id(new PHUITwoColumnView()) 61 + ->addClass('project-view-badges') 62 + ->setMainColumn( 63 + array( 64 + $properties, 65 + $feed, 66 + )) 67 + ->setSideColumn( 68 + array( 69 + $projects, 70 + $badges, 71 + )); 74 72 75 73 $nav = $this->getProfileMenu(); 76 74 $nav->selectFilter(PhabricatorPeopleProfilePanelEngine::PANEL_PROFILE); ··· 124 122 return $view; 125 123 } 126 124 125 + private function buildProjectsView( 126 + PhabricatorUser $user) { 127 + 128 + $viewer = $this->getViewer(); 129 + $projects = id(new PhabricatorProjectQuery()) 130 + ->setViewer($viewer) 131 + ->withMemberPHIDs(array($user->getPHID())) 132 + ->needImages(true) 133 + ->withStatus(PhabricatorProjectQuery::STATUS_OPEN) 134 + ->execute(); 135 + 136 + $header = id(new PHUIHeaderView()) 137 + ->setHeader(pht('Projects')); 138 + 139 + if (!empty($projects)) { 140 + $limit = 5; 141 + $render_phids = array_slice($projects, 0, $limit); 142 + $list = id(new PhabricatorProjectListView()) 143 + ->setUser($viewer) 144 + ->setProjects($render_phids); 145 + 146 + if (count($projects) > $limit) { 147 + $header_text = pht( 148 + 'Projects (%s)', 149 + phutil_count($projects)); 150 + 151 + $header = id(new PHUIHeaderView()) 152 + ->setHeader($header_text) 153 + ->addActionLink( 154 + id(new PHUIButtonView()) 155 + ->setTag('a') 156 + ->setIcon('fa-list-ul') 157 + ->setText(pht('View All')) 158 + ->setHref('/project/?member='.$user->getPHID())); 159 + 160 + } 161 + 162 + } else { 163 + $error = id(new PHUIBoxView()) 164 + ->addClass('mlb') 165 + ->appendChild(pht('User does not belong to any projects.')); 166 + $list = id(new PHUIInfoView()) 167 + ->setSeverity(PHUIInfoView::SEVERITY_NODATA) 168 + ->appendChild($error); 169 + } 170 + 171 + $box = id(new PHUIObjectBoxView()) 172 + ->setHeader($header) 173 + ->appendChild($list) 174 + ->setBackground(PHUIBoxView::GREY); 175 + 176 + return $box; 177 + } 178 + 127 179 private function buildBadgesView( 128 180 PhabricatorUser $user) { 129 181 130 182 $viewer = $this->getViewer(); 131 183 $class = 'PhabricatorBadgesApplication'; 132 - $box = null; 133 184 134 185 if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { 135 186 $badge_phids = $user->getBadgePHIDs(); ··· 150 201 $flex->addItem($item); 151 202 } 152 203 153 - $box = id(new PHUIObjectBoxView()) 154 - ->setHeaderText(pht('Badges')) 155 - ->appendChild($flex) 156 - ->setBackground(PHUIBoxView::GREY); 204 + } else { 205 + $error = id(new PHUIBoxView()) 206 + ->addClass('mlb') 207 + ->appendChild(pht('User does not have any badges.')); 208 + $flex = id(new PHUIInfoView()) 209 + ->setSeverity(PHUIInfoView::SEVERITY_NODATA) 210 + ->appendChild($error); 157 211 } 158 212 } 213 + 214 + $box = id(new PHUIObjectBoxView()) 215 + ->setHeaderText(pht('Badges')) 216 + ->appendChild($flex) 217 + ->setBackground(PHUIBoxView::GREY); 159 218 160 219 return $box; 161 220 }