2013-01-24 12:13:31 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorApplicationDetailViewController
|
|
|
|
extends PhabricatorApplicationsController{
|
|
|
|
|
|
|
|
private $application;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->application = $data['application'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2013-01-30 10:53:43 -08:00
|
|
|
$selected = PhabricatorApplication::getByClass($this->application);
|
2013-01-24 12:13:31 -08:00
|
|
|
|
|
|
|
if (!$selected) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$title = $selected->getName();
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName(pht('Applications'))
|
|
|
|
->setHref($this->getApplicationURI()));
|
|
|
|
|
2013-01-31 06:22:06 -08:00
|
|
|
$header = id(new PhabricatorHeaderView())
|
|
|
|
->setHeader($title);
|
2013-01-24 12:13:31 -08:00
|
|
|
|
2013-01-31 06:22:06 -08:00
|
|
|
$status_tag = id(new PhabricatorTagView())
|
|
|
|
->setType(PhabricatorTagView::TYPE_STATE);
|
2013-01-24 12:13:31 -08:00
|
|
|
|
2013-01-29 09:14:03 -08:00
|
|
|
if ($selected->isInstalled()) {
|
2013-01-31 06:22:06 -08:00
|
|
|
$status_tag->setName(pht('Installed'));
|
|
|
|
$status_tag->setBackgroundColor(PhabricatorTagView::COLOR_GREEN);
|
2013-01-29 09:14:03 -08:00
|
|
|
} else {
|
2013-01-31 06:22:06 -08:00
|
|
|
$status_tag->setName(pht('Uninstalled'));
|
|
|
|
$status_tag->setBackgroundColor(PhabricatorTagView::COLOR_RED);
|
2013-01-29 09:14:03 -08:00
|
|
|
}
|
2013-01-24 12:13:31 -08:00
|
|
|
|
2013-01-31 06:22:06 -08:00
|
|
|
if ($selected->isBeta()) {
|
|
|
|
$beta_tag = id(new PhabricatorTagView())
|
|
|
|
->setType(PhabricatorTagView::TYPE_STATE)
|
|
|
|
->setName(pht('Beta'))
|
|
|
|
->setBackgroundColor(PhabricatorTagView::COLOR_GREY);
|
|
|
|
$header->addTag($beta_tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
$header->addTag($status_tag);
|
|
|
|
|
|
|
|
$properties = $this->buildPropertyView($selected);
|
|
|
|
$actions = $this->buildActionView($user, $selected);
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
|
|
|
$header,
|
|
|
|
$actions,
|
|
|
|
$properties,
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'title' => $title,
|
|
|
|
'device' => true,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildPropertyView(PhabricatorApplication $selected) {
|
|
|
|
$properties = id(new PhabricatorPropertyListView())
|
|
|
|
->addProperty(
|
2013-02-19 13:33:10 -08:00
|
|
|
pht('Description'), $selected->getShortDescription());
|
2013-01-24 12:13:31 -08:00
|
|
|
|
|
|
|
return $properties;
|
|
|
|
}
|
|
|
|
|
2013-01-29 09:14:03 -08:00
|
|
|
private function buildActionView(
|
|
|
|
PhabricatorUser $user, PhabricatorApplication $selected) {
|
|
|
|
|
2013-01-30 13:32:32 -08:00
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($user);
|
|
|
|
|
2013-01-29 09:14:03 -08:00
|
|
|
if ($selected->canUninstall()) {
|
|
|
|
if ($selected->isInstalled()) {
|
2013-01-30 13:32:32 -08:00
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Uninstall'))
|
|
|
|
->setIcon('delete')
|
2013-01-31 11:49:52 -08:00
|
|
|
->setWorkflow(true)
|
2013-01-30 13:32:32 -08:00
|
|
|
->setHref(
|
2013-02-19 13:33:10 -08:00
|
|
|
$this->getApplicationURI(get_class($selected).'/uninstall/')));
|
2013-01-29 09:14:03 -08:00
|
|
|
} else {
|
2013-04-10 14:52:20 -07:00
|
|
|
$action = id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Install'))
|
|
|
|
->setIcon('new')
|
|
|
|
->setWorkflow(true)
|
|
|
|
->setHref(
|
|
|
|
$this->getApplicationURI(get_class($selected).'/install/'));
|
|
|
|
|
|
|
|
$beta_enabled = PhabricatorEnv::getEnvConfig(
|
|
|
|
'phabricator.show-beta-applications');
|
|
|
|
if ($selected->isBeta() && !$beta_enabled) {
|
|
|
|
$action->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
$view->addAction($action);
|
2013-01-29 09:14:03 -08:00
|
|
|
}
|
2013-01-30 13:32:32 -08:00
|
|
|
} else {
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Uninstall'))
|
|
|
|
->setIcon('delete')
|
2013-01-31 11:49:52 -08:00
|
|
|
->setWorkflow(true)
|
2013-01-30 13:32:32 -08:00
|
|
|
->setDisabled(true)
|
|
|
|
->setHref(
|
2013-02-19 13:33:10 -08:00
|
|
|
$this->getApplicationURI(get_class($selected).'/uninstall/')));
|
2013-01-29 09:14:03 -08:00
|
|
|
}
|
2013-01-30 13:32:32 -08:00
|
|
|
return $view;
|
2013-01-24 12:13:31 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|