2013-04-02 18:15:33 +02:00
|
|
|
<?php
|
|
|
|
|
2016-02-03 17:26:30 +01:00
|
|
|
final class PHUIHovercardUIExample extends PhabricatorUIExample {
|
2013-04-02 18:15:33 +02:00
|
|
|
|
|
|
|
public function getName() {
|
2015-05-22 09:27:56 +02:00
|
|
|
return pht('Hovercard');
|
2013-04-02 18:15:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getDescription() {
|
2015-05-22 09:27:56 +02:00
|
|
|
return pht(
|
2016-02-03 17:26:30 +01:00
|
|
|
'Use %s to render hovercards.',
|
|
|
|
phutil_tag('tt', array(), 'PHUIHovercardView'));
|
2013-04-02 18:15:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function renderExample() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$elements = array();
|
|
|
|
|
|
|
|
$diff_handle = $this->createBasicDummyHandle(
|
2014-06-09 20:36:49 +02:00
|
|
|
'D123',
|
2014-07-24 00:05:46 +02:00
|
|
|
DifferentialRevisionPHIDType::TYPECONST,
|
2015-05-22 09:27:56 +02:00
|
|
|
pht('Introduce cooler Differential Revisions'));
|
2013-04-02 18:15:33 +02:00
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
$panel = $this->createPanel(pht('Differential Hovercard'));
|
2016-02-03 17:26:30 +01:00
|
|
|
$panel->appendChild(id(new PHUIHovercardView())
|
2013-04-02 18:15:33 +02:00
|
|
|
->setObjectHandle($diff_handle)
|
|
|
|
->addField(pht('Author'), $user->getUsername())
|
|
|
|
->addField(pht('Updated'), phabricator_datetime(time(), $user))
|
|
|
|
->addAction(pht('Subscribe'), '/dev/random')
|
|
|
|
->setUser($user));
|
|
|
|
$elements[] = $panel;
|
|
|
|
|
|
|
|
$task_handle = $this->createBasicDummyHandle(
|
2014-06-09 20:36:49 +02:00
|
|
|
'T123',
|
2014-07-24 00:05:46 +02:00
|
|
|
ManiphestTaskPHIDType::TYPECONST,
|
2015-05-22 09:27:56 +02:00
|
|
|
pht('Improve Mobile Experience for Phabricator'));
|
2013-04-02 18:15:33 +02:00
|
|
|
|
2014-01-14 23:09:52 +01:00
|
|
|
$tag = id(new PHUITagView())
|
|
|
|
->setType(PHUITagView::TYPE_STATE)
|
2015-05-22 09:27:56 +02:00
|
|
|
->setName(pht('Closed, Resolved'));
|
|
|
|
$panel = $this->createPanel(pht('Maniphest Hovercard'));
|
2016-02-03 17:26:30 +01:00
|
|
|
$panel->appendChild(id(new PHUIHovercardView())
|
2013-04-02 18:15:33 +02:00
|
|
|
->setObjectHandle($task_handle)
|
|
|
|
->setUser($user)
|
|
|
|
->addField(pht('Assigned to'), $user->getUsername())
|
|
|
|
->addField(pht('Dependent Tasks'), 'T123, T124, T125')
|
|
|
|
->addAction(pht('Subscribe'), '/dev/random')
|
|
|
|
->addAction(pht('Create Subtask'), '/dev/urandom')
|
|
|
|
->addTag($tag));
|
|
|
|
$elements[] = $panel;
|
|
|
|
|
2015-07-17 02:17:21 +02:00
|
|
|
$badge1 = id(new PHUIBadgeMiniView())
|
|
|
|
->setIcon('fa-book')
|
|
|
|
->setHeader(pht('Documenter'));
|
|
|
|
|
|
|
|
$badge2 = id(new PHUIBadgeMiniView())
|
|
|
|
->setIcon('fa-star')
|
|
|
|
->setHeader(pht('Contributor'));
|
|
|
|
|
2013-04-02 18:15:33 +02:00
|
|
|
$user_handle = $this->createBasicDummyHandle(
|
|
|
|
'gwashington',
|
2014-07-24 00:05:46 +02:00
|
|
|
PhabricatorPeopleUserPHIDType::TYPECONST,
|
2013-04-02 18:15:33 +02:00
|
|
|
'George Washington');
|
|
|
|
$user_handle->setImageURI(
|
|
|
|
celerity_get_resource_uri('/rsrc/image/people/washington.png'));
|
2015-05-22 09:27:56 +02:00
|
|
|
$panel = $this->createPanel(pht('Whatevery Hovercard'));
|
2016-02-03 17:26:30 +01:00
|
|
|
$panel->appendChild(id(new PHUIHovercardView())
|
2013-04-02 18:15:33 +02:00
|
|
|
->setObjectHandle($user_handle)
|
2015-05-22 09:27:56 +02:00
|
|
|
->addField(pht('Status'), pht('Available'))
|
2013-04-02 18:15:33 +02:00
|
|
|
->addField(pht('Member since'), '30. February 1750')
|
2013-04-16 23:56:30 +02:00
|
|
|
->addAction(pht('Send a Message'), '/dev/null')
|
2015-07-17 02:17:21 +02:00
|
|
|
->addBadge($badge1)
|
|
|
|
->addBadge($badge2)
|
2013-04-02 18:15:33 +02:00
|
|
|
->setUser($user));
|
|
|
|
$elements[] = $panel;
|
|
|
|
|
2014-06-09 20:36:49 +02:00
|
|
|
return phutil_implode_html('', $elements);
|
2013-04-02 18:15:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private function createPanel($header) {
|
2014-06-02 20:45:30 +02:00
|
|
|
$panel = new PHUIBoxView();
|
|
|
|
$panel->addClass('grouped');
|
|
|
|
$panel->addClass('ml');
|
2013-04-02 18:15:33 +02:00
|
|
|
return $panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|