3 final class DiffusionIdentityViewController
4 extends DiffusionController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
9 $id = $request->getURIData('id');
10 $identity = id(new PhabricatorRepositoryIdentityQuery())
15 return new Aphront404Response();
18 $title = pht('Identity %d', $identity->getID());
20 $curtain = $this->buildCurtain($identity);
22 $header = id(new PHUIHeaderView())
24 ->setHeader($identity->getIdentityShortName())
25 ->setHeaderIcon('fa-globe');
27 $crumbs = $this->buildApplicationCrumbs();
28 $crumbs->addTextCrumb(
30 $this->getApplicationURI('identity/'));
31 $crumbs->addTextCrumb($identity->getObjectName());
32 $crumbs->setBorder(true);
34 $timeline = $this->buildTransactionTimeline(
36 new PhabricatorRepositoryIdentityTransactionQuery());
37 $timeline->setShouldTerminate(true);
39 $properties = $this->buildPropertyList($identity);
41 $view = id(new PHUITwoColumnView())
43 ->setCurtain($curtain)
44 ->setMainColumn(array(
49 return $this->newPage()
58 private function buildCurtain(PhabricatorRepositoryIdentity
$identity) {
59 $viewer = $this->getViewer();
61 $can_edit = PhabricatorPolicyFilter
::hasCapability(
64 PhabricatorPolicyCapability
::CAN_EDIT
);
66 $id = $identity->getID();
67 $edit_uri = $this->getApplicationURI("identity/edit/{$id}/");
69 $curtain = $this->newCurtainView($identity);
72 id(new PhabricatorActionView())
73 ->setIcon('fa-pencil')
74 ->setName(pht('Edit Identity'))
76 ->setWorkflow(!$can_edit)
77 ->setDisabled(!$can_edit));
82 private function buildPropertyList(
83 PhabricatorRepositoryIdentity
$identity) {
85 $viewer = $this->getViewer();
87 $properties = id(new PHUIPropertyListView())
90 $properties->addProperty(
92 $identity->getEmailAddress());
94 $effective_phid = $identity->getCurrentEffectiveUserPHID();
95 $automatic_phid = $identity->getAutomaticGuessedUserPHID();
96 $manual_phid = $identity->getManuallySetUserPHID();
98 if ($effective_phid) {
99 $tag = id(new PHUITagView())
100 ->setType(PHUITagView
::TYPE_SHADE
)
102 ->setIcon('fa-check')
103 ->setName('Assigned');
105 $tag = id(new PHUITagView())
106 ->setType(PHUITagView
::TYPE_SHADE
)
109 ->setName('Unassigned');
111 $properties->addProperty(
112 pht('Effective User'),
113 $this->buildPropertyValue($effective_phid));
114 $properties->addProperty(
115 pht('Automatically Detected User'),
116 $this->buildPropertyValue($automatic_phid));
117 $properties->addProperty(
119 $this->buildPropertyValue($manual_phid));
121 $header = id(new PHUIHeaderView())
122 ->setHeader(array(pht('Identity Assignments'), $tag));
124 return id(new PHUIObjectBoxView())
126 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
127 ->addPropertyList($properties);
130 private function buildPropertyValue($value) {
131 $viewer = $this->getViewer();
133 if ($value == DiffusionIdentityUnassignedDatasource
::FUNCTION_TOKEN
) {
134 return phutil_tag('em', array(), pht('Explicitly Unassigned'));
135 } else if (!$value) {
136 return phutil_tag('em', array(), pht('None'));
138 return $viewer->renderHandle($value);