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-09-17 09:12:37 -07:00
|
|
|
$header = id(new PHUIHeaderView())
|
2013-01-31 06:22:06 -08:00
|
|
|
->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);
|
|
|
|
|
2013-09-28 15:55:38 -07:00
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeader($header)
|
Provide more structure to PHUIObjectBoxView
Summary:
Three changes here.
- Add `setActionList()`, and use that to set the action list.
- Add `setPropertyList()`, and use that to set the property list.
These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors.
- Replace `addContent()` with `appendChild()`.
This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing.
Test Plan:
- Viewed "All Config".
- Viewed a countdown.
- Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history).
- Viewed Diffusion (browse, change, history, repository, lint).
- Viewed Drydock (resource, lease).
- Viewed Files.
- Viewed Herald.
- Viewed Legalpad.
- Viewed macro (edit, edit audio, view).
- Viewed Maniphest.
- Viewed Applications.
- Viewed Paste.
- Viewed People.
- Viewed Phulux.
- Viewed Pholio.
- Viewed Phame (blog, post).
- Viewed Phortune (account, product).
- Viewed Ponder (questions, answers, comments).
- Viewed Releeph.
- Viewed Projects.
- Viewed Slowvote.
NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose?
NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff.
Reviewers: chad
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D7174
2013-09-30 09:36:04 -07:00
|
|
|
->setActionList($actions)
|
|
|
|
->setPropertyList($properties);
|
2013-09-28 15:55:38 -07:00
|
|
|
|
2013-01-31 06:22:06 -08:00
|
|
|
return $this->buildApplicationPage(
|
|
|
|
array(
|
|
|
|
$crumbs,
|
2013-09-28 15:55:38 -07:00
|
|
|
$object_box,
|
2013-01-31 06:22:06 -08:00
|
|
|
),
|
|
|
|
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())
|
2013-07-12 11:39:47 -07:00
|
|
|
->setUser($user)
|
|
|
|
->setObjectURI($this->getRequest()->getRequestURI());
|
2013-01-30 13:32:32 -08:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
}
|