mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +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',
|
||||
'PhabricatorPeopleProfileMenuEngine' => 'applications/people/engine/PhabricatorPeopleProfileMenuEngine.php',
|
||||
'PhabricatorPeopleProfilePictureController' => 'applications/people/controller/PhabricatorPeopleProfilePictureController.php',
|
||||
'PhabricatorPeopleProfileRevisionsController' => 'applications/people/controller/PhabricatorPeopleProfileRevisionsController.php',
|
||||
'PhabricatorPeopleProfileTasksController' => 'applications/people/controller/PhabricatorPeopleProfileTasksController.php',
|
||||
'PhabricatorPeopleProfileViewController' => 'applications/people/controller/PhabricatorPeopleProfileViewController.php',
|
||||
'PhabricatorPeopleQuery' => 'applications/people/query/PhabricatorPeopleQuery.php',
|
||||
'PhabricatorPeopleRenameController' => 'applications/people/controller/PhabricatorPeopleRenameController.php',
|
||||
'PhabricatorPeopleRevisionsProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleRevisionsProfileMenuItem.php',
|
||||
'PhabricatorPeopleSearchEngine' => 'applications/people/query/PhabricatorPeopleSearchEngine.php',
|
||||
'PhabricatorPeopleTasksProfileMenuItem' => 'applications/people/menuitem/PhabricatorPeopleTasksProfileMenuItem.php',
|
||||
'PhabricatorPeopleTestDataGenerator' => 'applications/people/lipsum/PhabricatorPeopleTestDataGenerator.php',
|
||||
|
@ -8825,10 +8827,12 @@ phutil_register_library_map(array(
|
|||
'PhabricatorPeopleProfileManageController' => 'PhabricatorPeopleProfileController',
|
||||
'PhabricatorPeopleProfileMenuEngine' => 'PhabricatorProfileMenuEngine',
|
||||
'PhabricatorPeopleProfilePictureController' => 'PhabricatorPeopleProfileController',
|
||||
'PhabricatorPeopleProfileRevisionsController' => 'PhabricatorPeopleProfileController',
|
||||
'PhabricatorPeopleProfileTasksController' => 'PhabricatorPeopleProfileController',
|
||||
'PhabricatorPeopleProfileViewController' => 'PhabricatorPeopleProfileController',
|
||||
'PhabricatorPeopleQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorPeopleRenameController' => 'PhabricatorPeopleController',
|
||||
'PhabricatorPeopleRevisionsProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||
'PhabricatorPeopleSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhabricatorPeopleTasksProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||
'PhabricatorPeopleTestDataGenerator' => 'PhabricatorTestDataGenerator',
|
||||
|
|
|
@ -70,6 +70,8 @@ final class PhabricatorPeopleApplication extends PhabricatorApplication {
|
|||
'PhabricatorPeopleProfileTasksController',
|
||||
'commits/(?P<id>[1-9]\d*)/' =>
|
||||
'PhabricatorPeopleProfileCommitsController',
|
||||
'revisions/(?P<id>[1-9]\d*)/' =>
|
||||
'PhabricatorPeopleProfileRevisionsController',
|
||||
'picture/(?P<id>[1-9]\d*)/' =>
|
||||
'PhabricatorPeopleProfilePictureController',
|
||||
'manage/(?P<id>[1-9]\d*)/' =>
|
||||
|
|
|
@ -13,10 +13,6 @@ final class PhabricatorPeopleProfileCommitsController
|
|||
->needProfile(true)
|
||||
->needProfileImage(true)
|
||||
->needAvailability(true)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$user) {
|
||||
return new Aphront404Response();
|
||||
|
@ -63,10 +59,6 @@ final class PhabricatorPeopleProfileCommitsController
|
|||
->needAuditRequests(true)
|
||||
->needCommitData(true)
|
||||
->needDrafts(true)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
))
|
||||
->setLimit(100)
|
||||
->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)
|
||||
->needProfileImage(true)
|
||||
->needAvailability(true)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$user) {
|
||||
return new Aphront404Response();
|
||||
|
|
|
@ -9,6 +9,7 @@ final class PhabricatorPeopleProfileMenuEngine
|
|||
const ITEM_BADGES = 'people.badges';
|
||||
const ITEM_TASKS = 'people.tasks';
|
||||
const ITEM_COMMITS = 'people.commits';
|
||||
const ITEM_REVISIONS = 'people.revisions';
|
||||
|
||||
protected function isMenuEngineConfigurable() {
|
||||
return false;
|
||||
|
@ -52,6 +53,16 @@ final class PhabricatorPeopleProfileMenuEngine
|
|||
->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(
|
||||
'PhabricatorDiffusionApplication',
|
||||
$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