mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-09 19:04:48 +01:00
Summary: Ref T10054. This shuffles some stuff around to move us closer to mocks in M1450 in terms of what information is on which pages. Home now has feed, members, watchers, link to "edit project / project edit history". History now has edit history, edit details, edit picture, archive/unarchive. Test Plan: New home page: {F1064889} New edit/history page: {F1064890} Reviewers: chad Reviewed By: chad Maniphest Tasks: T10054 Differential Revision: https://secure.phabricator.com/D15060
133 lines
3.6 KiB
PHP
133 lines
3.6 KiB
PHP
<?php
|
|
|
|
final class PhabricatorProjectHistoryController
|
|
extends PhabricatorProjectController {
|
|
|
|
public function shouldAllowPublic() {
|
|
return true;
|
|
}
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$response = $this->loadProject();
|
|
if ($response) {
|
|
return $response;
|
|
}
|
|
|
|
$viewer = $request->getUser();
|
|
$project = $this->getProject();
|
|
$id = $project->getID();
|
|
$picture = $project->getProfileImageURI();
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
->setHeader(pht('Project History'))
|
|
->setUser($viewer)
|
|
->setPolicyObject($project)
|
|
->setImage($picture);
|
|
|
|
if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) {
|
|
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
|
|
} else {
|
|
$header->setStatus('fa-ban', 'red', pht('Archived'));
|
|
}
|
|
|
|
$actions = $this->buildActionListView($project);
|
|
$properties = $this->buildPropertyListView($project, $actions);
|
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
->setHeader($header)
|
|
->addPropertyList($properties);
|
|
|
|
$timeline = $this->buildTransactionTimeline(
|
|
$project,
|
|
new PhabricatorProjectTransactionQuery());
|
|
$timeline->setShouldTerminate(true);
|
|
|
|
$nav = $this->getProfileMenu();
|
|
$nav->selectFilter(PhabricatorProject::PANEL_PROFILE);
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
$crumbs->addTextCrumb(pht('History'));
|
|
|
|
return $this->newPage()
|
|
->setNavigation($nav)
|
|
->setCrumbs($crumbs)
|
|
->setTitle($project->getName())
|
|
->appendChild(
|
|
array(
|
|
$object_box,
|
|
$timeline,
|
|
));
|
|
}
|
|
|
|
private function buildActionListView(PhabricatorProject $project) {
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
$id = $project->getID();
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
->setUser($viewer);
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
$viewer,
|
|
$project,
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Back to Profile'))
|
|
->setIcon('fa-chevron-left')
|
|
->setHref($project->getURI()));
|
|
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Edit Details'))
|
|
->setIcon('fa-pencil')
|
|
->setHref($this->getApplicationURI("edit/{$id}/"))
|
|
->setDisabled(!$can_edit)
|
|
->setWorkflow(!$can_edit));
|
|
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Edit Picture'))
|
|
->setIcon('fa-picture-o')
|
|
->setHref($this->getApplicationURI("picture/{$id}/"))
|
|
->setDisabled(!$can_edit)
|
|
->setWorkflow(!$can_edit));
|
|
|
|
if ($project->isArchived()) {
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Activate Project'))
|
|
->setIcon('fa-check')
|
|
->setHref($this->getApplicationURI("archive/{$id}/"))
|
|
->setDisabled(!$can_edit)
|
|
->setWorkflow(true));
|
|
} else {
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Archive Project'))
|
|
->setIcon('fa-ban')
|
|
->setHref($this->getApplicationURI("archive/{$id}/"))
|
|
->setDisabled(!$can_edit)
|
|
->setWorkflow(true));
|
|
}
|
|
|
|
return $view;
|
|
}
|
|
|
|
private function buildPropertyListView(
|
|
PhabricatorProject $project,
|
|
PhabricatorActionListView $actions) {
|
|
$request = $this->getRequest();
|
|
$viewer = $request->getUser();
|
|
|
|
$view = id(new PHUIPropertyListView())
|
|
->setUser($viewer)
|
|
->setActionList($actions);
|
|
|
|
return $view;
|
|
}
|
|
|
|
|
|
}
|