1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 00:10:57 +01:00

New People Hovercards

Summary: Mimics the Project Hovercards, more custom UI.

Test Plan: Hover over person with and without badges, hover over project.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D15253
This commit is contained in:
Chad Little 2016-02-11 14:55:44 -08:00
parent 8934dee543
commit 6ae0a62f9f
6 changed files with 169 additions and 67 deletions

View file

@ -93,7 +93,7 @@ return array(
'rsrc/css/application/policy/policy-transaction-detail.css' => '82100a43',
'rsrc/css/application/policy/policy.css' => '957ea14c',
'rsrc/css/application/ponder/ponder-view.css' => '7b0df4da',
'rsrc/css/application/project/project-card-view.css' => '9c3631e5',
'rsrc/css/application/project/project-card-view.css' => '9418c97d',
'rsrc/css/application/project/project-view.css' => '4693497c',
'rsrc/css/application/releeph/releeph-core.css' => '9b3c5733',
'rsrc/css/application/releeph/releeph-preview-branch.css' => 'b7a6f4a5',
@ -854,7 +854,7 @@ return array(
'policy-edit-css' => '815c66f7',
'policy-transaction-detail-css' => '82100a43',
'ponder-view-css' => '7b0df4da',
'project-card-view-css' => '9c3631e5',
'project-card-view-css' => '9418c97d',
'project-view-css' => '4693497c',
'releeph-core' => '9b3c5733',
'releeph-preview-branch' => 'b7a6f4a5',

View file

@ -2904,6 +2904,7 @@ phutil_register_library_map(array(
'PhabricatorProjectHeraldAction' => 'applications/project/herald/PhabricatorProjectHeraldAction.php',
'PhabricatorProjectHeraldAdapter' => 'applications/project/herald/PhabricatorProjectHeraldAdapter.php',
'PhabricatorProjectHeraldFieldGroup' => 'applications/project/herald/PhabricatorProjectHeraldFieldGroup.php',
'PhabricatorProjectHovercardEngineExtension' => 'applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php',
'PhabricatorProjectIconSet' => 'applications/project/icon/PhabricatorProjectIconSet.php',
'PhabricatorProjectIconsConfigOptionType' => 'applications/project/config/PhabricatorProjectIconsConfigOptionType.php',
'PhabricatorProjectInterface' => 'applications/project/interface/PhabricatorProjectInterface.php',
@ -3376,6 +3377,7 @@ phutil_register_library_map(array(
'PhabricatorUnsubscribedFromObjectEdgeType' => 'applications/transactions/edges/PhabricatorUnsubscribedFromObjectEdgeType.php',
'PhabricatorUser' => 'applications/people/storage/PhabricatorUser.php',
'PhabricatorUserBlurbField' => 'applications/people/customfield/PhabricatorUserBlurbField.php',
'PhabricatorUserCardView' => 'applications/people/view/PhabricatorUserCardView.php',
'PhabricatorUserConfigOptions' => 'applications/people/config/PhabricatorUserConfigOptions.php',
'PhabricatorUserConfiguredCustomField' => 'applications/people/customfield/PhabricatorUserConfiguredCustomField.php',
'PhabricatorUserConfiguredCustomFieldStorage' => 'applications/people/storage/PhabricatorUserConfiguredCustomFieldStorage.php',
@ -3828,7 +3830,6 @@ phutil_register_library_map(array(
'ProjectDefaultJoinCapability' => 'applications/project/capability/ProjectDefaultJoinCapability.php',
'ProjectDefaultViewCapability' => 'applications/project/capability/ProjectDefaultViewCapability.php',
'ProjectEditConduitAPIMethod' => 'applications/project/conduit/ProjectEditConduitAPIMethod.php',
'ProjectHovercardEngineExtension' => 'applications/project/events/ProjectHovercardEngineExtension.php',
'ProjectQueryConduitAPIMethod' => 'applications/project/conduit/ProjectQueryConduitAPIMethod.php',
'ProjectRemarkupRule' => 'applications/project/remarkup/ProjectRemarkupRule.php',
'ProjectRemarkupRuleTestCase' => 'applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php',
@ -7338,6 +7339,7 @@ phutil_register_library_map(array(
'PhabricatorProjectHeraldAction' => 'HeraldAction',
'PhabricatorProjectHeraldAdapter' => 'HeraldAdapter',
'PhabricatorProjectHeraldFieldGroup' => 'HeraldFieldGroup',
'PhabricatorProjectHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
'PhabricatorProjectIconSet' => 'PhabricatorIconSet',
'PhabricatorProjectIconsConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'PhabricatorProjectListController' => 'PhabricatorProjectController',
@ -7887,6 +7889,7 @@ phutil_register_library_map(array(
'PhabricatorFulltextInterface',
),
'PhabricatorUserBlurbField' => 'PhabricatorUserCustomField',
'PhabricatorUserCardView' => 'AphrontTagView',
'PhabricatorUserConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorUserConfiguredCustomField' => array(
'PhabricatorUserCustomField',
@ -8474,7 +8477,6 @@ phutil_register_library_map(array(
'ProjectDefaultJoinCapability' => 'PhabricatorPolicyCapability',
'ProjectDefaultViewCapability' => 'PhabricatorPolicyCapability',
'ProjectEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'ProjectHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
'ProjectQueryConduitAPIMethod' => 'ProjectConduitAPIMethod',
'ProjectRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'ProjectRemarkupRuleTestCase' => 'PhabricatorTestCase',

View file

@ -25,6 +25,7 @@ final class PeopleHovercardEngineExtension
->setViewer($viewer)
->withPHIDs($phids)
->needAvailability(true)
->needProfileImage(true)
->needProfile(true)
->needBadges(true)
->execute();
@ -47,69 +48,12 @@ final class PeopleHovercardEngineExtension
return;
}
$hovercard->setTitle($user->getUsername());
$user_card = id(new PhabricatorUserCardView())
->setProfile($user)
->setViewer($viewer);
$profile = $user->getUserProfile();
$detail = $user->getRealName();
if ($profile->getTitle()) {
$detail .= ' - '.$profile->getTitle();
}
$hovercard->setDetail($detail);
$hovercard->appendChild($user_card);
if ($user->getIsDisabled()) {
$hovercard->addField(pht('Account'), pht('Disabled'));
} else if (!$user->isUserActivated()) {
$hovercard->addField(pht('Account'), pht('Not Activated'));
} else if (PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorCalendarApplication',
$viewer)) {
$hovercard->addField(
pht('Status'),
$user->getAvailabilityDescription($viewer));
}
$hovercard->addField(
pht('User Since'),
phabricator_date($user->getDateCreated(), $viewer));
if ($profile->getBlurb()) {
$hovercard->addField(pht('Blurb'),
id(new PhutilUTF8StringTruncator())
->setMaximumGlyphs(120)
->truncateString($profile->getBlurb()));
}
$badges = $this->buildBadges($user, $viewer);
foreach ($badges as $badge) {
$hovercard->addBadge($badge);
}
}
private function buildBadges(
PhabricatorUser $user,
$viewer) {
$class = 'PhabricatorBadgesApplication';
$items = array();
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$badge_phids = $user->getBadgePHIDs();
if ($badge_phids) {
$badges = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
->withPHIDs($badge_phids)
->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))
->execute();
foreach ($badges as $badge) {
$items[] = id(new PHUIBadgeMiniView())
->setIcon($badge->getIcon())
->setHeader($badge->getName())
->setQuality($badge->getQuality());
}
}
}
return $items;
}
}

View file

@ -0,0 +1,151 @@
<?php
final class PhabricatorUserCardView extends AphrontTagView {
private $profile;
private $viewer;
private $tag;
public function setProfile(PhabricatorUser $profile) {
$this->profile = $profile;
return $this;
}
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
public function setTag($tag) {
$this->tag = $tag;
return $this;
}
protected function getTagName() {
if ($this->tag) {
return $this->tag;
}
return 'div';
}
protected function getTagAttributes() {
$classes = array();
$classes[] = 'project-card-view';
if ($this->profile->getIsDisabled()) {
$classes[] = 'project-card-grey';
} else {
$classes[] = 'project-card-blue';
}
return array(
'class' => implode($classes, ' '),
);
}
protected function getTagContent() {
$user = $this->profile;
$profile = $user->loadUserProfile();
$picture = $user->getProfileImageURI();
$viewer = $this->viewer;
require_celerity_resource('project-card-view-css');
$profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon());
$profile_title = $profile->getDisplayTitle();
$tag = id(new PHUITagView())
->setIcon($profile_icon)
->setName($profile_title)
->addClass('project-view-header-tag')
->setType(PHUITagView::TYPE_SHADE);
$header = id(new PHUIHeaderView())
->setHeader(array($user->getFullName(), $tag))
->setUser($viewer)
->setImage($picture);
$body = array();
$body[] = $this->addItem(
pht('User Since'),
phabricator_date($profile->getDateCreated(), $viewer));
if (PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorCalendarApplication',
$viewer)) {
$availability = $user->getAvailabilityDescription($viewer);
$body[] = $this->addItem(pht('Status'), $availability);
}
$badges = $this->buildBadges($user, $viewer);
if ($badges) {
$badges = id(new PHUIBadgeBoxView())
->addItems($badges)
->setCollapsed(true);
$body[] = phutil_tag(
'div',
array(
'class' => 'phui-hovercard-body-item hovercard-badges',
),
$badges);
}
$body = phutil_tag(
'div',
array(
'class' => 'project-card-body',
),
$body);
$card = phutil_tag(
'div',
array(
'class' => 'project-card-inner',
),
array(
$header,
$body,
));
return $card;
}
private function addItem($label, $value) {
$item = array(
phutil_tag('strong', array(), $label),
': ',
phutil_tag('span', array(), $value),
);
return phutil_tag_div('project-card-item', $item);
}
private function buildBadges(
PhabricatorUser $user,
$viewer) {
$class = 'PhabricatorBadgesApplication';
$items = array();
if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
$badge_phids = $user->getBadgePHIDs();
if ($badge_phids) {
$badges = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
->withPHIDs($badge_phids)
->withStatuses(array(PhabricatorBadgesBadge::STATUS_ACTIVE))
->execute();
foreach ($badges as $badge) {
$items[] = id(new PHUIBadgeMiniView())
->setIcon($badge->getIcon())
->setHeader($badge->getName())
->setQuality($badge->getQuality());
}
}
}
return $items;
}
}

View file

@ -1,6 +1,6 @@
<?php
final class ProjectHovercardEngineExtension
final class PhabricatorProjectHovercardEngineExtension
extends PhabricatorHovercardEngineExtension {
const EXTENSIONKEY = 'project.card';

View file

@ -14,7 +14,7 @@
.project-card-view .phui-header-shell {
margin: 0;
padding: 12px 12px 16px 12px;
padding: 12px 12px 4px 12px;
border: none;
border-radius: 3px;
}
@ -43,6 +43,7 @@
.project-card-view .phui-header-subheader {
font-size: {$normalfontsize};
margin-top: 12px;
padding-bottom: 12px;
}
.project-card-view .phui-header-header .phui-tag-view {
@ -63,6 +64,10 @@
color: {$bluetext};
}
.project-card-view .project-card-body {
padding: 0 12px 12px 76px;
color: {$darkbluetext};
}
/* Colors */