mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Add Revisions to User Profiles
Summary: Ref T12423. Adds back revisions as a user profile page. I don't want to think about custom profiles for a while. Test Plan: Make some diffs, visit my profile, see diffs. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12423 Differential Revision: https://secure.phabricator.com/D17987
This commit is contained in:
parent
bc4ef0d22f
commit
11578bfc90
7 changed files with 158 additions and 12 deletions
|
@ -3457,10 +3457,12 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPeopleProfileManageController' => 'applications/people/controller/PhabricatorPeopleProfileManageController.php',
|
'PhabricatorPeopleProfileManageController' => 'applications/people/controller/PhabricatorPeopleProfileManageController.php',
|
||||||
'PhabricatorPeopleProfileMenuEngine' => 'applications/people/engine/PhabricatorPeopleProfileMenuEngine.php',
|
'PhabricatorPeopleProfileMenuEngine' => 'applications/people/engine/PhabricatorPeopleProfileMenuEngine.php',
|
||||||
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
|
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
|
||||||
|
'PhabricatorPeopleProfileRevisionsController' => 'applications/people/controller/PhabricatorPeopleProfileRevisionsController.php',
|
||||||
'PhabricatorPeopleProfileTasksController' => 'applications/people/controller/PhabricatorPeopleProfileTasksController.php',
|
'PhabricatorPeopleProfileTasksController' => 'applications/people/controller/PhabricatorPeopleProfileTasksController.php',
|
||||||
'PhabricatorPeopleProfileViewController' => 'applications/people/controller/PhabricatorPeopleProfileViewController.php',
|
'PhabricatorPeopleProfileViewController' => 'applications/people/controller/PhabricatorPeopleProfileViewController.php',
|
||||||
'PhabricatorPeopleQuery' => 'applications/people/query/PhabricatorPeopleQuery.php',
|
'PhabricatorPeopleQuery' => 'applications/people/query/PhabricatorPeopleQuery.php',
|
||||||
'PhabricatorPeopleRenameController' => 'applications/people/controller/PhabricatorPeopleRenameController.php',
|
'PhabricatorPeopleRenameController' => 'applications/people/controller/PhabricatorPeopleRenameController.php',
|
||||||
|
'PhabricatorPeopleRevisionsProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php',
|
||||||
'PhabricatorPeopleSearchEngine' => 'applications/people/query/PhabricatorPeopleSearchEngine.php',
|
'PhabricatorPeopleSearchEngine' => 'applications/people/query/PhabricatorPeopleSearchEngine.php',
|
||||||
'PhabricatorPeopleTasksProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php',
|
'PhabricatorPeopleTasksProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php',
|
||||||
'PhabricatorPeopleTestDataGenerator' => 'applications/people/lipsum/PhabricatorPeopleTestDataGenerator.php',
|
'PhabricatorPeopleTestDataGenerator' => 'applications/people/lipsum/PhabricatorPeopleTestDataGenerator.php',
|
||||||
|
@ -8825,10 +8827,12 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorPeopleProfileManageController' => 'PhabricatorPeopleProfileController',
|
'PhabricatorPeopleProfileManageController' => 'PhabricatorPeopleProfileController',
|
||||||
'PhabricatorPeopleProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
|
'PhabricatorPeopleProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
|
||||||
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleProfileController',
|
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleProfileController',
|
||||||
|
'PhabricatorPeopleProfileRevisionsController' => 'PhabricatorPeopleProfileController',
|
||||||
'PhabricatorPeopleProfileTasksController' => 'PhabricatorPeopleProfileController',
|
'PhabricatorPeopleProfileTasksController' => 'PhabricatorPeopleProfileController',
|
||||||
'PhabricatorPeopleProfileViewController' => 'PhabricatorPeopleProfileController',
|
'PhabricatorPeopleProfileViewController' => 'PhabricatorPeopleProfileController',
|
||||||
'PhabricatorPeopleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhabricatorPeopleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhabricatorPeopleRenameController' => 'PhabricatorPeopleController',
|
'PhabricatorPeopleRenameController' => 'PhabricatorPeopleController',
|
||||||
|
'PhabricatorPeopleRevisionsProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||||
'PhabricatorPeopleSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
'PhabricatorPeopleSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||||
'PhabricatorPeopleTasksProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
'PhabricatorPeopleTasksProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||||
'PhabricatorPeopleTestDataGenerator' => 'PhabricatorTestDataGenerator',
|
'PhabricatorPeopleTestDataGenerator' => 'PhabricatorTestDataGenerator',
|
||||||
|
|
|
@ -70,6 +70,8 @@ final class PhabricatorPeopleApplication extends PhabricatorApplication {
|
||||||
'PhabricatorPeopleProfileTasksController',
|
'PhabricatorPeopleProfileTasksController',
|
||||||
'commits/(?P<id>[1-9]\d*)/' =>
|
'commits/(?P<id>[1-9]\d*)/' =>
|
||||||
'PhabricatorPeopleProfileCommitsController',
|
'PhabricatorPeopleProfileCommitsController',
|
||||||
|
'revisions/(?P<id>[1-9]\d*)/' =>
|
||||||
|
'PhabricatorPeopleProfileRevisionsController',
|
||||||
'picture/(?P<id>[1-9]\d*)/' =>
|
'picture/(?P<id>[1-9]\d*)/' =>
|
||||||
'PhabricatorPeopleProfilePictureController',
|
'PhabricatorPeopleProfilePictureController',
|
||||||
'manage/(?P<id>[1-9]\d*)/' =>
|
'manage/(?P<id>[1-9]\d*)/' =>
|
||||||
|
|
|
@ -13,10 +13,6 @@ final class PhabricatorPeopleProfileCommitsController
|
||||||
->needProfile(true)
|
->needProfile(true)
|
||||||
->needProfileImage(true)
|
->needProfileImage(true)
|
||||||
->needAvailability(true)
|
->needAvailability(true)
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
))
|
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
|
@ -63,10 +59,6 @@ final class PhabricatorPeopleProfileCommitsController
|
||||||
->needAuditRequests(true)
|
->needAuditRequests(true)
|
||||||
->needCommitData(true)
|
->needCommitData(true)
|
||||||
->needDrafts(true)
|
->needDrafts(true)
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
))
|
|
||||||
->setLimit(100)
|
->setLimit(100)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorPeopleProfileRevisionsController
|
||||||
|
extends PhabricatorPeopleProfileController {
|
||||||
|
|
||||||
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$id = $request->getURIData('id');
|
||||||
|
|
||||||
|
$user = id(new PhabricatorPeopleQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withIDs(array($id))
|
||||||
|
->needProfile(true)
|
||||||
|
->needProfileImage(true)
|
||||||
|
->needAvailability(true)
|
||||||
|
->executeOne();
|
||||||
|
if (!$user) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = 'PhabricatorDifferentialApplication';
|
||||||
|
if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setUser($user);
|
||||||
|
$title = array(pht('Recent Revisions'), $user->getUsername());
|
||||||
|
$header = $this->buildProfileHeader();
|
||||||
|
$commits = $this->buildRevisionsView($user);
|
||||||
|
|
||||||
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
|
$crumbs->addTextCrumb(pht('Recent Revisions'));
|
||||||
|
$crumbs->setBorder(true);
|
||||||
|
|
||||||
|
$nav = $this->getProfileMenu();
|
||||||
|
$nav->selectFilter(PhabricatorPeopleProfileMenuEngine::ITEM_REVISIONS);
|
||||||
|
|
||||||
|
$view = id(new PHUITwoColumnView())
|
||||||
|
->setHeader($header)
|
||||||
|
->addClass('project-view-home')
|
||||||
|
->addClass('project-view-people-home')
|
||||||
|
->setFooter(array(
|
||||||
|
$commits,
|
||||||
|
));
|
||||||
|
|
||||||
|
return $this->newPage()
|
||||||
|
->setTitle($title)
|
||||||
|
->setCrumbs($crumbs)
|
||||||
|
->setNavigation($nav)
|
||||||
|
->appendChild($view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildRevisionsView(PhabricatorUser $user) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$revisions = id(new DifferentialRevisionQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withAuthors(array($user->getPHID()))
|
||||||
|
->needFlags(true)
|
||||||
|
->needDrafts(true)
|
||||||
|
->needReviewers(true)
|
||||||
|
->setLimit(100)
|
||||||
|
->execute();
|
||||||
|
|
||||||
|
$list = id(new DifferentialRevisionListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setNoBox(true)
|
||||||
|
->setRevisions($revisions)
|
||||||
|
->setNoDataString(pht('No recent revisions.'));
|
||||||
|
|
||||||
|
$object_phids = $list->getRequiredHandlePHIDs();
|
||||||
|
$handles = $this->loadViewerHandles($object_phids);
|
||||||
|
$list->setHandles($handles);
|
||||||
|
|
||||||
|
$view = id(new PHUIObjectBoxView())
|
||||||
|
->setHeaderText(pht('Recent Revisions'))
|
||||||
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
|
->appendChild($list);
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,10 +13,6 @@ final class PhabricatorPeopleProfileTasksController
|
||||||
->needProfile(true)
|
->needProfile(true)
|
||||||
->needProfileImage(true)
|
->needProfileImage(true)
|
||||||
->needAvailability(true)
|
->needAvailability(true)
|
||||||
->requireCapabilities(
|
|
||||||
array(
|
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
|
||||||
))
|
|
||||||
->executeOne();
|
->executeOne();
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
|
|
|
@ -9,6 +9,7 @@ final class PhabricatorPeopleProfileMenuEngine
|
||||||
const ITEM_BADGES = 'people.badges';
|
const ITEM_BADGES = 'people.badges';
|
||||||
const ITEM_TASKS = 'people.tasks';
|
const ITEM_TASKS = 'people.tasks';
|
||||||
const ITEM_COMMITS = 'people.commits';
|
const ITEM_COMMITS = 'people.commits';
|
||||||
|
const ITEM_REVISIONS = 'people.revisions';
|
||||||
|
|
||||||
protected function isMenuEngineConfigurable() {
|
protected function isMenuEngineConfigurable() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -52,6 +53,16 @@ final class PhabricatorPeopleProfileMenuEngine
|
||||||
->setMenuItemKey(PhabricatorPeopleTasksProfileMenuItem::MENUITEMKEY);
|
->setMenuItemKey(PhabricatorPeopleTasksProfileMenuItem::MENUITEMKEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$have_differential = PhabricatorApplication::isClassInstalledForViewer(
|
||||||
|
'PhabricatorDifferentialApplication',
|
||||||
|
$viewer);
|
||||||
|
if ($have_differential) {
|
||||||
|
$items[] = $this->newItem()
|
||||||
|
->setBuiltinKey(self::ITEM_REVISIONS)
|
||||||
|
->setMenuItemKey(
|
||||||
|
PhabricatorPeopleRevisionsProfileMenuItem::MENUITEMKEY);
|
||||||
|
}
|
||||||
|
|
||||||
$have_diffusion = PhabricatorApplication::isClassInstalledForViewer(
|
$have_diffusion = PhabricatorApplication::isClassInstalledForViewer(
|
||||||
'PhabricatorDiffusionApplication',
|
'PhabricatorDiffusionApplication',
|
||||||
$viewer);
|
$viewer);
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorPeopleRevisionsProfileMenuItem
|
||||||
|
extends PhabricatorProfileMenuItem {
|
||||||
|
|
||||||
|
const MENUITEMKEY = 'people.revisions';
|
||||||
|
|
||||||
|
public function getMenuItemTypeName() {
|
||||||
|
return pht('Revisions');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getDefaultName() {
|
||||||
|
return pht('Revisions');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canHideMenuItem(
|
||||||
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDisplayName(
|
||||||
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
|
$name = $config->getMenuItemProperty('name');
|
||||||
|
|
||||||
|
if (strlen($name)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getDefaultName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function buildEditEngineFields(
|
||||||
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
|
return array(
|
||||||
|
id(new PhabricatorTextEditField())
|
||||||
|
->setKey('name')
|
||||||
|
->setLabel(pht('Name'))
|
||||||
|
->setPlaceholder($this->getDefaultName())
|
||||||
|
->setValue($config->getMenuItemProperty('name')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function newNavigationMenuItems(
|
||||||
|
PhabricatorProfileMenuItemConfiguration $config) {
|
||||||
|
|
||||||
|
$user = $config->getProfileObject();
|
||||||
|
$id = $user->getID();
|
||||||
|
|
||||||
|
$item = $this->newItem()
|
||||||
|
->setHref("/people/revisions/{$id}/")
|
||||||
|
->setName($this->getDisplayName($config))
|
||||||
|
->setIcon('fa-gear');
|
||||||
|
|
||||||
|
return array(
|
||||||
|
$item,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue