mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 13:00:56 +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',
|
'PhabricatorProfilePanelEditor' => 'applications/search/editor/PhabricatorProfilePanelEditor.php',
|
||||||
'PhabricatorProfilePanelEngine' => 'applications/search/engine/PhabricatorProfilePanelEngine.php',
|
'PhabricatorProfilePanelEngine' => 'applications/search/engine/PhabricatorProfilePanelEngine.php',
|
||||||
'PhabricatorProfilePanelIconSet' => 'applications/search/profilepanel/PhabricatorProfilePanelIconSet.php',
|
'PhabricatorProfilePanelIconSet' => 'applications/search/profilepanel/PhabricatorProfilePanelIconSet.php',
|
||||||
'PhabricatorProfilePanelInterface' => 'applications/search/interface/PhabricatorProfilePanelInterface.php',
|
|
||||||
'PhabricatorProfilePanelPHIDType' => 'applications/search/phidtype/PhabricatorProfilePanelPHIDType.php',
|
'PhabricatorProfilePanelPHIDType' => 'applications/search/phidtype/PhabricatorProfilePanelPHIDType.php',
|
||||||
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
|
'PhabricatorProject' => 'applications/project/storage/PhabricatorProject.php',
|
||||||
'PhabricatorProjectAddHeraldAction' => 'applications/project/herald/PhabricatorProjectAddHeraldAction.php',
|
'PhabricatorProjectAddHeraldAction' => 'applications/project/herald/PhabricatorProjectAddHeraldAction.php',
|
||||||
|
@ -2902,6 +2901,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectPHIDResolver' => 'applications/phid/resolver/PhabricatorProjectPHIDResolver.php',
|
'PhabricatorProjectPHIDResolver' => 'applications/phid/resolver/PhabricatorProjectPHIDResolver.php',
|
||||||
'PhabricatorProjectPanelController' => 'applications/project/controller/PhabricatorProjectPanelController.php',
|
'PhabricatorProjectPanelController' => 'applications/project/controller/PhabricatorProjectPanelController.php',
|
||||||
'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php',
|
'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php',
|
||||||
|
'PhabricatorProjectProfilePanelEngine' => 'applications/project/engine/PhabricatorProjectProfilePanelEngine.php',
|
||||||
'PhabricatorProjectProjectHasMemberEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasMemberEdgeType.php',
|
'PhabricatorProjectProjectHasMemberEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasMemberEdgeType.php',
|
||||||
'PhabricatorProjectProjectHasObjectEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasObjectEdgeType.php',
|
'PhabricatorProjectProjectHasObjectEdgeType' => 'applications/project/edge/PhabricatorProjectProjectHasObjectEdgeType.php',
|
||||||
'PhabricatorProjectProjectPHIDType' => 'applications/project/phid/PhabricatorProjectProjectPHIDType.php',
|
'PhabricatorProjectProjectPHIDType' => 'applications/project/phid/PhabricatorProjectProjectPHIDType.php',
|
||||||
|
@ -7214,7 +7214,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
'PhabricatorFulltextInterface',
|
'PhabricatorFulltextInterface',
|
||||||
'PhabricatorConduitResultInterface',
|
'PhabricatorConduitResultInterface',
|
||||||
'PhabricatorProfilePanelInterface',
|
|
||||||
),
|
),
|
||||||
'PhabricatorProjectAddHeraldAction' => 'PhabricatorProjectHeraldAction',
|
'PhabricatorProjectAddHeraldAction' => 'PhabricatorProjectHeraldAction',
|
||||||
'PhabricatorProjectApplication' => 'PhabricatorApplication',
|
'PhabricatorProjectApplication' => 'PhabricatorApplication',
|
||||||
|
@ -7289,6 +7288,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectPHIDResolver' => 'PhabricatorPHIDResolver',
|
'PhabricatorProjectPHIDResolver' => 'PhabricatorPHIDResolver',
|
||||||
'PhabricatorProjectPanelController' => 'PhabricatorProjectController',
|
'PhabricatorProjectPanelController' => 'PhabricatorProjectController',
|
||||||
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',
|
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',
|
||||||
|
'PhabricatorProjectProfilePanelEngine' => 'PhabricatorProfilePanelEngine',
|
||||||
'PhabricatorProjectProjectHasMemberEdgeType' => 'PhabricatorEdgeType',
|
'PhabricatorProjectProjectHasMemberEdgeType' => 'PhabricatorEdgeType',
|
||||||
'PhabricatorProjectProjectHasObjectEdgeType' => 'PhabricatorEdgeType',
|
'PhabricatorProjectProjectHasObjectEdgeType' => 'PhabricatorEdgeType',
|
||||||
'PhabricatorProjectProjectPHIDType' => 'PhabricatorPHIDType',
|
'PhabricatorProjectProjectPHIDType' => 'PhabricatorPHIDType',
|
||||||
|
|
|
@ -102,7 +102,7 @@ abstract class PhabricatorProjectController extends PhabricatorController {
|
||||||
if ($project) {
|
if ($project) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$engine = id(new PhabricatorProfilePanelEngine())
|
$engine = id(new PhabricatorProjectProfilePanelEngine())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->setProfileObject($project);
|
->setProfileObject($project);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ final class PhabricatorProjectPanelController
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$project = $this->getProject();
|
$project = $this->getProject();
|
||||||
|
|
||||||
return id(new PhabricatorProfilePanelEngine())
|
return id(new PhabricatorProjectProfilePanelEngine())
|
||||||
->setProfileObject($project)
|
->setProfileObject($project)
|
||||||
->setController($this)
|
->setController($this)
|
||||||
->buildResponse();
|
->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,
|
PhabricatorCustomFieldInterface,
|
||||||
PhabricatorDestructibleInterface,
|
PhabricatorDestructibleInterface,
|
||||||
PhabricatorFulltextInterface,
|
PhabricatorFulltextInterface,
|
||||||
PhabricatorConduitResultInterface,
|
PhabricatorConduitResultInterface {
|
||||||
PhabricatorProfilePanelInterface {
|
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
|
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
|
||||||
|
@ -651,47 +650,4 @@ final class PhabricatorProject extends PhabricatorProjectDAO
|
||||||
return array();
|
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;
|
return $this->panelEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setProfileObject(
|
public function setProfileObject($profile_object) {
|
||||||
PhabricatorProfilePanelInterface $profile_object) {
|
|
||||||
$this->profileObject = $profile_object;
|
$this->profileObject = $profile_object;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class PhabricatorProfilePanelEngine extends Phobject {
|
abstract class PhabricatorProfilePanelEngine extends Phobject {
|
||||||
|
|
||||||
private $viewer;
|
private $viewer;
|
||||||
private $profileObject;
|
private $profileObject;
|
||||||
|
@ -16,8 +16,7 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
||||||
return $this->viewer;
|
return $this->viewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setProfileObject(
|
public function setProfileObject($profile_object) {
|
||||||
PhabricatorProfilePanelInterface $profile_object) {
|
|
||||||
$this->profileObject = $profile_object;
|
$this->profileObject = $profile_object;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +34,8 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
||||||
return $this->controller;
|
return $this->controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract protected function getPanelURI($path);
|
||||||
|
|
||||||
public function buildResponse() {
|
public function buildResponse() {
|
||||||
$controller = $this->getController();
|
$controller = $this->getController();
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
||||||
public function buildNavigation() {
|
public function buildNavigation() {
|
||||||
$nav = id(new AphrontSideNavFilterView())
|
$nav = id(new AphrontSideNavFilterView())
|
||||||
->setIsProfileMenu(true)
|
->setIsProfileMenu(true)
|
||||||
->setBaseURI(new PhutilURI('/project/'));
|
->setBaseURI(new PhutilURI($this->getPanelURI('')));
|
||||||
|
|
||||||
$panels = $this->getPanels();
|
$panels = $this->getPanels();
|
||||||
|
|
||||||
|
@ -225,7 +226,7 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
||||||
|
|
||||||
private function loadBuiltinProfilePanels() {
|
private function loadBuiltinProfilePanels() {
|
||||||
$object = $this->getProfileObject();
|
$object = $this->getProfileObject();
|
||||||
$builtins = $object->getBuiltinProfilePanels();
|
$builtins = $this->getBuiltinProfilePanels($object);
|
||||||
|
|
||||||
$panels = PhabricatorProfilePanel::getAllPanels();
|
$panels = PhabricatorProfilePanel::getAllPanels();
|
||||||
|
|
||||||
|
@ -310,12 +311,6 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
||||||
return $this->getPanelURI('configure/');
|
return $this->getPanelURI('configure/');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getPanelURI($path) {
|
|
||||||
$project = $this->getProfileObject();
|
|
||||||
$id = $project->getID();
|
|
||||||
return "/project/{$id}/panel/{$path}";
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildPanelReorderContent(array $panels) {
|
private function buildPanelReorderContent(array $panels) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$object = $this->getProfileObject();
|
$object = $this->getProfileObject();
|
||||||
|
@ -646,4 +641,8 @@ final class PhabricatorProfilePanelEngine extends Phobject {
|
||||||
->addSubmitButton(pht('Save Changes'));
|
->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');
|
return pht('Link');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canAddToObject(
|
public function canAddToObject($object) {
|
||||||
PhabricatorProfilePanelInterface $object) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,8 +26,7 @@ abstract class PhabricatorProfilePanel extends Phobject {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canAddToObject(
|
public function canAddToObject($object) {
|
||||||
PhabricatorProfilePanelInterface $object) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class PhabricatorProfilePanelConfiguration
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function initializeNewPanelConfiguration(
|
public static function initializeNewPanelConfiguration(
|
||||||
PhabricatorProfilePanelInterface $profile_object,
|
$profile_object,
|
||||||
PhabricatorProfilePanel $panel) {
|
PhabricatorProfilePanel $panel) {
|
||||||
|
|
||||||
return self::initializeNewBuiltin()
|
return self::initializeNewBuiltin()
|
||||||
|
@ -77,8 +77,7 @@ final class PhabricatorProfilePanelConfiguration
|
||||||
return $this->assertAttached($this->panel);
|
return $this->assertAttached($this->panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachProfileObject(
|
public function attachProfileObject($profile_object) {
|
||||||
PhabricatorProfilePanelInterface $profile_object) {
|
|
||||||
$this->profileObject = $profile_object;
|
$this->profileObject = $profile_object;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue