3 final class PhabricatorApplicationDetailViewController
4 extends PhabricatorApplicationsController
{
7 public function shouldAllowPublic() {
11 public function handleRequest(AphrontRequest
$request) {
12 $viewer = $this->getViewer();
13 $application = $request->getURIData('application');
15 $selected = id(new PhabricatorApplicationQuery())
17 ->withClasses(array($application))
20 return new Aphront404Response();
23 $title = $selected->getName();
25 $crumbs = $this->buildApplicationCrumbs();
26 $crumbs->addTextCrumb($selected->getName());
27 $crumbs->setBorder(true);
29 $header = id(new PHUIHeaderView())
32 ->setPolicyObject($selected)
33 ->setHeaderIcon($selected->getIcon());
35 if ($selected->isInstalled()) {
36 $header->setStatus('fa-check', 'bluegrey', pht('Installed'));
38 $header->setStatus('fa-ban', 'dark', pht('Uninstalled'));
41 $timeline = $this->buildTransactionTimeline(
43 new PhabricatorApplicationApplicationTransactionQuery());
44 $timeline->setShouldTerminate(true);
46 $curtain = $this->buildCurtain($selected);
47 $details = $this->buildPropertySectionView($selected);
48 $policies = $this->buildPolicyView($selected);
51 PhabricatorApplicationConfigurationPanel
::loadAllPanelsForApplication(
55 foreach ($configs as $config) {
56 $config->setViewer($viewer);
57 $config->setApplication($selected);
58 $panel = $config->buildConfigurationPagePanel();
59 $panel->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
);
63 $view = id(new PHUITwoColumnView())
65 ->setCurtain($curtain)
66 ->setMainColumn(array(
71 ->addPropertySection(pht('Details'), $details);
73 return $this->newPage()
82 private function buildPropertySectionView(
83 PhabricatorApplication
$application) {
85 $viewer = $this->getViewer();
86 $properties = id(new PHUIPropertyListView());
88 $properties->addProperty(
90 $application->getShortDescription());
92 if ($application->getFlavorText()) {
93 $properties->addProperty(
95 phutil_tag('em', array(), $application->getFlavorText()));
98 if ($application->isPrototype()) {
99 $proto_href = PhabricatorEnv
::getDoclink(
100 'User Guide: Prototype Applications');
101 $learn_more = phutil_tag(
104 'href' => $proto_href,
105 'target' => '_blank',
109 $properties->addProperty(
112 'This application is a prototype. %s',
116 $overview = $application->getOverview();
117 if (strlen($overview)) {
118 $overview = new PHUIRemarkupView($viewer, $overview);
119 $properties->addSectionHeader(
120 pht('Overview'), PHUIPropertyListView
::ICON_SUMMARY
);
121 $properties->addTextContent($overview);
127 private function buildPolicyView(
128 PhabricatorApplication
$application) {
130 $viewer = $this->getViewer();
131 $properties = id(new PHUIPropertyListView());
133 $header = id(new PHUIHeaderView())
134 ->setHeader(pht('Policies'));
136 $descriptions = PhabricatorPolicyQuery
::renderPolicyDescriptions(
140 foreach ($application->getCapabilities() as $capability) {
141 $properties->addProperty(
142 $application->getCapabilityLabel($capability),
143 idx($descriptions, $capability));
146 return id(new PHUIObjectBoxView())
148 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
149 ->appendChild($properties);
153 private function buildCurtain(PhabricatorApplication
$application) {
154 $viewer = $this->getViewer();
156 $can_edit = PhabricatorPolicyFilter
::hasCapability(
159 PhabricatorPolicyCapability
::CAN_EDIT
);
161 $key = get_class($application);
162 $edit_uri = $this->getApplicationURI("edit/{$key}/");
163 $install_uri = $this->getApplicationURI("{$key}/install/");
164 $uninstall_uri = $this->getApplicationURI("{$key}/uninstall/");
166 $curtain = $this->newCurtainView($application);
169 id(new PhabricatorActionView())
170 ->setName(pht('Edit Policies'))
171 ->setIcon('fa-pencil')
172 ->setDisabled(!$can_edit)
173 ->setWorkflow(!$can_edit)
174 ->setHref($edit_uri));
176 if ($application->canUninstall()) {
177 if ($application->isInstalled()) {
179 id(new PhabricatorActionView())
180 ->setName(pht('Uninstall'))
181 ->setIcon('fa-times')
182 ->setDisabled(!$can_edit)
184 ->setHref($uninstall_uri));
186 $action = id(new PhabricatorActionView())
187 ->setName(pht('Install'))
189 ->setDisabled(!$can_edit)
191 ->setHref($install_uri);
193 $prototypes_enabled = PhabricatorEnv
::getEnvConfig(
194 'phabricator.show-prototypes');
195 if ($application->isPrototype() && !$prototypes_enabled) {
196 $action->setDisabled(true);
199 $curtain->addAction($action);
203 id(new PhabricatorActionView())
204 ->setName(pht('Uninstall'))
205 ->setIcon('fa-times')
208 ->setHref($uninstall_uri));