mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Prepare Profile Panels for adoption in other applications
Summary: Ref T10054. Take specialization off the objects and put it on Engine subclasses instead. One reason for this is that certain objects (like users) might have multiple different sets of panels in the future (e.g., their user profile and their home page). Test Plan: - No user-visible changes. - PanelEngine no longer has any hardcoded "project" stuff. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10054 Differential Revision: https://secure.phabricator.com/D15018
This commit is contained in:
parent
c019f76283
commit
2a6b2dbbfd
11 changed files with 71 additions and 76 deletions
|
@ -2836,7 +2836,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProfilePanelEditor' => 'applications/search/editor/PhabricatorProfilePanelEditor.php',
|
||||
'PhabricatorProfilePanelEngine' => 'applications/search/engine/PhabricatorProfilePanelEngine.php',
|
||||
'PhabricatorProfilePanelIconSet' => 'applications/search/profilepanel/PhabricatorProfilePanelIconSet.php',
|
||||
'PhabricatorProfilePanelInterface' => 'applications/search/interface/PhabricatorProfilePanelInterface.php',
|
||||
'PhabricatorProfilePanelPHIDType' => 'applications/search/phidtype/PhabricatorProfilePanelPHIDType.php',
|
||||
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
|
||||
'PhabricatorProjectAddHeraldAction' => 'applications/project/herald/PhabricatorProjectAddHeraldAction.php',
|
||||
|
@ -2902,6 +2901,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectPHIDResolver' => 'applications/phid/resolver/PhabricatorProjectPHIDResolver.php',
|
||||
'PhabricatorProjectPanelController' => 'applications/project/controller/PhabricatorProjectPanelController.php',
|
||||
'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php',
|
||||
'PhabricatorProjectProfilePanelEngine' => 'applications/project/engine/PhabricatorProjectProfilePanelEngine.php',
|
||||
'PhabricatorProjectProjectHasMemberEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasMemberEdgeType.php',
|
||||
'PhabricatorProjectProjectHasObjectEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasObjectEdgeType.php',
|
||||
'PhabricatorProjectProjectPHIDType' => 'applications/project/phid/PhabricatorProjectProjectPHIDType.php',
|
||||
|
@ -7214,7 +7214,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDestructibleInterface',
|
||||
'PhabricatorFulltextInterface',
|
||||
'PhabricatorConduitResultInterface',
|
||||
'PhabricatorProfilePanelInterface',
|
||||
),
|
||||
'PhabricatorProjectAddHeraldAction' => 'PhabricatorProjectHeraldAction',
|
||||
'PhabricatorProjectApplication' => 'PhabricatorApplication',
|
||||
|
@ -7289,6 +7288,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectPHIDResolver' => 'PhabricatorPHIDResolver',
|
||||
'PhabricatorProjectPanelController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectProfilePanelEngine' => 'PhabricatorProfilePanelEngine',
|
||||
'PhabricatorProjectProjectHasMemberEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorProjectProjectHasObjectEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorProjectProjectPHIDType' => 'PhabricatorPHIDType',
|
||||
|
|
|
@ -102,7 +102,7 @@ abstract class PhabricatorProjectController extends PhabricatorController {
|
|||
if ($project) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$engine = id(new PhabricatorProfilePanelEngine())
|
||||
$engine = id(new PhabricatorProjectProfilePanelEngine())
|
||||
->setViewer($viewer)
|
||||
->setProfileObject($project);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ final class PhabricatorProjectPanelController
|
|||
$viewer = $this->getViewer();
|
||||
$project = $this->getProject();
|
||||
|
||||
return id(new PhabricatorProfilePanelEngine())
|
||||
return id(new PhabricatorProjectProfilePanelEngine())
|
||||
->setProfileObject($project)
|
||||
->setController($this)
|
||||
->buildResponse();
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectProfilePanelEngine
|
||||
extends PhabricatorProfilePanelEngine {
|
||||
|
||||
protected function getPanelURI($path) {
|
||||
$project = $this->getProfileObject();
|
||||
$id = $project->getID();
|
||||
return "/project/{$id}/panel/{$path}";
|
||||
}
|
||||
|
||||
protected function getBuiltinProfilePanels($object) {
|
||||
$panels = array();
|
||||
|
||||
$panels[] = $this->newPanel()
|
||||
->setBuiltinKey(PhabricatorProject::PANEL_PROFILE)
|
||||
->setPanelKey(PhabricatorProjectDetailsProfilePanel::PANELKEY);
|
||||
|
||||
$panels[] = $this->newPanel()
|
||||
->setBuiltinKey(PhabricatorProject::PANEL_WORKBOARD)
|
||||
->setPanelKey(PhabricatorProjectWorkboardProfilePanel::PANELKEY);
|
||||
|
||||
// TODO: This is temporary.
|
||||
$uri = urisprintf(
|
||||
'/maniphest/?statuses=open()&projects=%s#R',
|
||||
$object->getPHID());
|
||||
|
||||
$panels[] = $this->newPanel()
|
||||
->setBuiltinKey('tasks')
|
||||
->setPanelKey(PhabricatorLinkProfilePanel::PANELKEY)
|
||||
->setPanelProperty('icon', 'maniphest')
|
||||
->setPanelProperty('name', pht('Open Tasks'))
|
||||
->setPanelProperty('uri', $uri);
|
||||
|
||||
// TODO: This is temporary.
|
||||
$id = $object->getID();
|
||||
$panels[] = $this->newPanel()
|
||||
->setBuiltinKey('feed')
|
||||
->setPanelKey(PhabricatorLinkProfilePanel::PANELKEY)
|
||||
->setPanelProperty('icon', 'feed')
|
||||
->setPanelProperty('name', pht('Feed'))
|
||||
->setPanelProperty('uri', "/project/feed/{$id}/");
|
||||
|
||||
$panels[] = $this->newPanel()
|
||||
->setBuiltinKey(PhabricatorProject::PANEL_MEMBERS)
|
||||
->setPanelKey(PhabricatorProjectMembersProfilePanel::PANELKEY);
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,8 +10,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
PhabricatorCustomFieldInterface,
|
||||
PhabricatorDestructibleInterface,
|
||||
PhabricatorFulltextInterface,
|
||||
PhabricatorConduitResultInterface,
|
||||
PhabricatorProfilePanelInterface {
|
||||
PhabricatorConduitResultInterface {
|
||||
|
||||
protected $name;
|
||||
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
|
||||
|
@ -651,47 +650,4 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
|||
return array();
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorProfilePanelInterface )----------------------------------- */
|
||||
|
||||
|
||||
public function getBuiltinProfilePanels() {
|
||||
$panels = array();
|
||||
|
||||
$panels[] = PhabricatorProfilePanelConfiguration::initializeNewBuiltin()
|
||||
->setBuiltinKey(self::PANEL_PROFILE)
|
||||
->setPanelKey(PhabricatorProjectDetailsProfilePanel::PANELKEY);
|
||||
|
||||
$panels[] = PhabricatorProfilePanelConfiguration::initializeNewBuiltin()
|
||||
->setBuiltinKey(self::PANEL_WORKBOARD)
|
||||
->setPanelKey(PhabricatorProjectWorkboardProfilePanel::PANELKEY);
|
||||
|
||||
// TODO: This is temporary.
|
||||
$uri = urisprintf(
|
||||
'/maniphest/?statuses=open()&projects=%s#R',
|
||||
$this->getPHID());
|
||||
|
||||
$panels[] = PhabricatorProfilePanelConfiguration::initializeNewBuiltin()
|
||||
->setBuiltinKey('tasks')
|
||||
->setPanelKey(PhabricatorLinkProfilePanel::PANELKEY)
|
||||
->setPanelProperty('icon', 'maniphest')
|
||||
->setPanelProperty('name', pht('Open Tasks'))
|
||||
->setPanelProperty('uri', $uri);
|
||||
|
||||
// TODO: This is temporary.
|
||||
$id = $this->getID();
|
||||
$panels[] = PhabricatorProfilePanelConfiguration::initializeNewBuiltin()
|
||||
->setBuiltinKey('feed')
|
||||
->setPanelKey(PhabricatorLinkProfilePanel::PANELKEY)
|
||||
->setPanelProperty('icon', 'feed')
|
||||
->setPanelProperty('name', pht('Feed'))
|
||||
->setPanelProperty('uri', "/project/feed/{$id}/");
|
||||
|
||||
$panels[] = PhabricatorProfilePanelConfiguration::initializeNewBuiltin()
|
||||
->setBuiltinKey(self::PANEL_MEMBERS)
|
||||
->setPanelKey(PhabricatorProjectMembersProfilePanel::PANELKEY);
|
||||
|
||||
return $panels;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ final class PhabricatorProfilePanelEditEngine
|
|||
return $this->panelEngine;
|
||||
}
|
||||
|
||||
public function setProfileObject(
|
||||
PhabricatorProfilePanelInterface $profile_object) {
|
||||
public function setProfileObject($profile_object) {
|
||||
$this->profileObject = $profile_object;
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProfilePanelEngine extends Phobject {
|
||||
abstract class PhabricatorProfilePanelEngine extends Phobject {
|
||||
|
||||
private $viewer;
|
||||
private $profileObject;
|
||||
|
@ -16,8 +16,7 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
|||
return $this->viewer;
|
||||
}
|
||||
|
||||
public function setProfileObject(
|
||||
PhabricatorProfilePanelInterface $profile_object) {
|
||||
public function setProfileObject($profile_object) {
|
||||
$this->profileObject = $profile_object;
|
||||
return $this;
|
||||
}
|
||||
|
@ -35,6 +34,8 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
|||
return $this->controller;
|
||||
}
|
||||
|
||||
abstract protected function getPanelURI($path);
|
||||
|
||||
public function buildResponse() {
|
||||
$controller = $this->getController();
|
||||
|
||||
|
@ -132,7 +133,7 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
|||
public function buildNavigation() {
|
||||
$nav = id(new AphrontSideNavFilterView())
|
||||
->setIsProfileMenu(true)
|
||||
->setBaseURI(new PhutilURI('/project/'));
|
||||
->setBaseURI(new PhutilURI($this->getPanelURI('')));
|
||||
|
||||
$panels = $this->getPanels();
|
||||
|
||||
|
@ -225,7 +226,7 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
|||
|
||||
private function loadBuiltinProfilePanels() {
|
||||
$object = $this->getProfileObject();
|
||||
$builtins = $object->getBuiltinProfilePanels();
|
||||
$builtins = $this->getBuiltinProfilePanels($object);
|
||||
|
||||
$panels = PhabricatorProfilePanel::getAllPanels();
|
||||
|
||||
|
@ -310,12 +311,6 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
|||
return $this->getPanelURI('configure/');
|
||||
}
|
||||
|
||||
private function getPanelURI($path) {
|
||||
$project = $this->getProfileObject();
|
||||
$id = $project->getID();
|
||||
return "/project/{$id}/panel/{$path}";
|
||||
}
|
||||
|
||||
private function buildPanelReorderContent(array $panels) {
|
||||
$viewer = $this->getViewer();
|
||||
$object = $this->getProfileObject();
|
||||
|
@ -646,4 +641,8 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
|||
->addSubmitButton(pht('Save Changes'));
|
||||
}
|
||||
|
||||
protected function newPanel() {
|
||||
return PhabricatorProfilePanelConfiguration::initializeNewBuiltin();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
interface PhabricatorProfilePanelInterface {
|
||||
|
||||
public function getBuiltinProfilePanels();
|
||||
|
||||
}
|
|
@ -13,8 +13,7 @@ final class PhabricatorLinkProfilePanel
|
|||
return pht('Link');
|
||||
}
|
||||
|
||||
public function canAddToObject(
|
||||
PhabricatorProfilePanelInterface $object) {
|
||||
public function canAddToObject($object) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ abstract class PhabricatorProfilePanel extends Phobject {
|
|||
return array();
|
||||
}
|
||||
|
||||
public function canAddToObject(
|
||||
PhabricatorProfilePanelInterface $object) {
|
||||
public function canAddToObject($object) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ final class PhabricatorProfilePanelConfiguration
|
|||
}
|
||||
|
||||
public static function initializeNewPanelConfiguration(
|
||||
PhabricatorProfilePanelInterface $profile_object,
|
||||
$profile_object,
|
||||
PhabricatorProfilePanel $panel) {
|
||||
|
||||
return self::initializeNewBuiltin()
|
||||
|
@ -77,8 +77,7 @@ final class PhabricatorProfilePanelConfiguration
|
|||
return $this->assertAttached($this->panel);
|
||||
}
|
||||
|
||||
public function attachProfileObject(
|
||||
PhabricatorProfilePanelInterface $profile_object) {
|
||||
public function attachProfileObject($profile_object) {
|
||||
$this->profileObject = $profile_object;
|
||||
return $this;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue