mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Add an ApplicationProfilePanel
Summary: Allows applications to be added as profile menu items Test Plan: Add an application to a project, see menu item, click on menu. Uninstall application, see menu without application. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17016
This commit is contained in:
parent
9c72c1b1da
commit
f0b6952391
2 changed files with 81 additions and 0 deletions
|
@ -1787,6 +1787,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationEmailCommandsController' => 'applications/meta/controller/PhabricatorApplicationEmailCommandsController.php',
|
||||
'PhabricatorApplicationLaunchView' => 'applications/meta/view/PhabricatorApplicationLaunchView.php',
|
||||
'PhabricatorApplicationPanelController' => 'applications/meta/controller/PhabricatorApplicationPanelController.php',
|
||||
'PhabricatorApplicationProfilePanel' => 'applications/search/profilepanel/PhabricatorApplicationProfilePanel.php',
|
||||
'PhabricatorApplicationQuery' => 'applications/meta/query/PhabricatorApplicationQuery.php',
|
||||
'PhabricatorApplicationSearchController' => 'applications/search/controller/PhabricatorApplicationSearchController.php',
|
||||
'PhabricatorApplicationSearchEngine' => 'applications/search/engine/PhabricatorApplicationSearchEngine.php',
|
||||
|
@ -6609,6 +6610,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorApplicationEmailCommandsController' => 'PhabricatorApplicationsController',
|
||||
'PhabricatorApplicationLaunchView' => 'AphrontTagView',
|
||||
'PhabricatorApplicationPanelController' => 'PhabricatorApplicationsController',
|
||||
'PhabricatorApplicationProfilePanel' => 'PhabricatorProfilePanel',
|
||||
'PhabricatorApplicationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorApplicationSearchController' => 'PhabricatorSearchBaseController',
|
||||
'PhabricatorApplicationSearchEngine' => 'Phobject',
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorApplicationProfilePanel
|
||||
extends PhabricatorProfilePanel {
|
||||
|
||||
const PANELKEY = 'application';
|
||||
|
||||
public function getPanelTypeIcon() {
|
||||
return 'fa-globe';
|
||||
}
|
||||
|
||||
public function getPanelTypeName() {
|
||||
return pht('Application');
|
||||
}
|
||||
|
||||
public function canAddToObject($object) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getDisplayName(
|
||||
PhabricatorProfilePanelConfiguration $config) {
|
||||
$app = $this->getApplication($config);
|
||||
if ($app) {
|
||||
return $app->getName();
|
||||
} else {
|
||||
return pht('(Uninstalled Application)');
|
||||
}
|
||||
return $app->getName();
|
||||
}
|
||||
|
||||
public function buildEditEngineFields(
|
||||
PhabricatorProfilePanelConfiguration $config) {
|
||||
return array(
|
||||
id(new PhabricatorDatasourceEditField())
|
||||
->setKey('application')
|
||||
->setLabel(pht('Application'))
|
||||
->setDatasource(new PhabricatorApplicationDatasource())
|
||||
->setSingleValue($config->getPanelProperty('application')),
|
||||
);
|
||||
}
|
||||
|
||||
private function getApplication(
|
||||
PhabricatorProfilePanelConfiguration $config) {
|
||||
$viewer = $this->getViewer();
|
||||
$phid = $config->getPanelProperty('application');
|
||||
$app = id(new PhabricatorApplicationQuery())
|
||||
->setViewer($viewer)
|
||||
->withPHIDs(array($phid))
|
||||
->executeOne();
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
protected function newNavigationMenuItems(
|
||||
PhabricatorProfilePanelConfiguration $config) {
|
||||
$viewer = $this->getViewer();
|
||||
$app = $this->getApplication($config);
|
||||
if (!$app) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$is_installed = PhabricatorApplication::isClassInstalledForViewer(
|
||||
get_class($app),
|
||||
$viewer);
|
||||
if (!$is_installed) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$item = $this->newItem()
|
||||
->setHref($app->getApplicationURI())
|
||||
->setName($app->getName())
|
||||
->setIcon($app->getIcon());
|
||||
|
||||
return array(
|
||||
$item,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue