mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
Merge some of the project editing options into an edit UI
Summary: Ref T4426. This moves "Edit Details", "Edit Picture", and "Archive" to a separate "Edit" interface. "History" becomes part of this UI. Test Plan: {F114417} {F114418} Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T4426 Differential Revision: https://secure.phabricator.com/D8248
This commit is contained in:
parent
ac09a1a245
commit
51acc22962
8 changed files with 185 additions and 123 deletions
|
@ -1844,8 +1844,10 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectCustomFieldStringIndex' => 'applications/project/storage/PhabricatorProjectCustomFieldStringIndex.php',
|
||||
'PhabricatorProjectDAO' => 'applications/project/storage/PhabricatorProjectDAO.php',
|
||||
'PhabricatorProjectDescriptionField' => 'applications/project/customfield/PhabricatorProjectDescriptionField.php',
|
||||
'PhabricatorProjectEditDetailsController' => 'applications/project/controller/PhabricatorProjectEditDetailsController.php',
|
||||
'PhabricatorProjectEditMainController' => 'applications/project/controller/PhabricatorProjectEditMainController.php',
|
||||
'PhabricatorProjectEditPictureController' => 'applications/project/controller/PhabricatorProjectEditPictureController.php',
|
||||
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
|
||||
'PhabricatorProjectHistoryController' => 'applications/project/controller/PhabricatorProjectHistoryController.php',
|
||||
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
|
||||
'PhabricatorProjectMembersEditController' => 'applications/project/controller/PhabricatorProjectMembersEditController.php',
|
||||
'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php',
|
||||
|
@ -1853,8 +1855,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php',
|
||||
'PhabricatorProjectPHIDTypeProject' => 'applications/project/phid/PhabricatorProjectPHIDTypeProject.php',
|
||||
'PhabricatorProjectProfileController' => 'applications/project/controller/PhabricatorProjectProfileController.php',
|
||||
'PhabricatorProjectProfileEditController' => 'applications/project/controller/PhabricatorProjectProfileEditController.php',
|
||||
'PhabricatorProjectProfilePictureController' => 'applications/project/controller/PhabricatorProjectProfilePictureController.php',
|
||||
'PhabricatorProjectQuery' => 'applications/project/query/PhabricatorProjectQuery.php',
|
||||
'PhabricatorProjectSearchEngine' => 'applications/project/query/PhabricatorProjectSearchEngine.php',
|
||||
'PhabricatorProjectSearchIndexer' => 'applications/project/search/PhabricatorProjectSearchIndexer.php',
|
||||
|
@ -4591,8 +4591,10 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage',
|
||||
'PhabricatorProjectDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorProjectDescriptionField' => 'PhabricatorProjectStandardCustomField',
|
||||
'PhabricatorProjectEditDetailsController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditMainController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditorTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorProjectHistoryController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectListController' =>
|
||||
array(
|
||||
0 => 'PhabricatorProjectController',
|
||||
|
@ -4604,8 +4606,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType',
|
||||
'PhabricatorProjectPHIDTypeProject' => 'PhabricatorPHIDType',
|
||||
'PhabricatorProjectProfileController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectProfileEditController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectProfilePictureController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
'PhabricatorProjectSearchEngine' => 'PhabricatorApplicationSearchEngine',
|
||||
'PhabricatorProjectSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
|
||||
|
|
|
@ -37,15 +37,17 @@ final class PhabricatorApplicationProject extends PhabricatorApplication {
|
|||
'/project/' => array(
|
||||
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorProjectListController',
|
||||
'filter/(?P<filter>[^/]+)/' => 'PhabricatorProjectListController',
|
||||
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectProfileEditController',
|
||||
'edit/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectEditMainController',
|
||||
'details/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorProjectEditDetailsController',
|
||||
'archive/(?P<id>[1-9]\d*)/' =>
|
||||
'PhabricatorProjectArchiveController',
|
||||
'members/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorProjectMembersEditController',
|
||||
'view/(?P<id>[1-9]\d*)/(?:(?P<page>\w+)/)?'
|
||||
'view/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorProjectProfileController',
|
||||
'picture/(?P<id>[1-9]\d*)/' =>
|
||||
'PhabricatorProjectProfilePictureController',
|
||||
'PhabricatorProjectEditPictureController',
|
||||
'create/' => 'PhabricatorProjectCreateController',
|
||||
'board/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectBoardController',
|
||||
'move/(?P<id>[1-9]\d*)/' => 'PhabricatorProjectMoveController',
|
||||
|
|
|
@ -26,7 +26,7 @@ final class PhabricatorProjectArchiveController
|
|||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$view_uri = $this->getApplicationURI('view/'.$project->getID().'/');
|
||||
$edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/');
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
if ($project->isArchived()) {
|
||||
|
@ -48,7 +48,7 @@ final class PhabricatorProjectArchiveController
|
|||
->setContinueOnMissingFields(true)
|
||||
->applyTransactions($project, $xactions);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
||||
return id(new AphrontRedirectResponse())->setURI($edit_uri);
|
||||
}
|
||||
|
||||
if ($project->isArchived()) {
|
||||
|
@ -65,7 +65,7 @@ final class PhabricatorProjectArchiveController
|
|||
->setUser($viewer)
|
||||
->setTitle($title)
|
||||
->appendChild($body)
|
||||
->addCancelButton($view_uri)
|
||||
->addCancelButton($edit_uri)
|
||||
->addSubmitButton($button);
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectProfileEditController
|
||||
final class PhabricatorProjectEditDetailsController
|
||||
extends PhabricatorProjectController {
|
||||
|
||||
private $id;
|
||||
|
@ -34,6 +34,7 @@ final class PhabricatorProjectProfileEditController
|
|||
->readFieldsFromStorage($project);
|
||||
|
||||
$view_uri = $this->getApplicationURI('view/'.$project->getID().'/');
|
||||
$edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/');
|
||||
|
||||
$e_name = true;
|
||||
$e_edit = null;
|
||||
|
@ -81,7 +82,7 @@ final class PhabricatorProjectProfileEditController
|
|||
try {
|
||||
$editor->applyTransactions($project, $xactions);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
||||
return id(new AphrontRedirectResponse())->setURI($edit_uri);
|
||||
} catch (PhabricatorApplicationTransactionValidationException $ex) {
|
||||
$validation_exception = $ex;
|
||||
|
||||
|
@ -119,7 +120,6 @@ final class PhabricatorProjectProfileEditController
|
|||
id(new AphrontFormPolicyControl())
|
||||
->setUser($viewer)
|
||||
->setName('can_view')
|
||||
->setCaption(pht('Members can always view a project.'))
|
||||
->setPolicyObject($project)
|
||||
->setPolicies($policies)
|
||||
->setCapability(PhabricatorPolicyCapability::CAN_VIEW))
|
||||
|
@ -142,7 +142,7 @@ final class PhabricatorProjectProfileEditController
|
|||
->setCapability(PhabricatorPolicyCapability::CAN_JOIN))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton($view_uri)
|
||||
->addCancelButton($edit_uri)
|
||||
->setValue(pht('Save')));
|
||||
|
||||
$form_box = id(new PHUIObjectBoxView())
|
||||
|
@ -152,7 +152,8 @@ final class PhabricatorProjectProfileEditController
|
|||
|
||||
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView())
|
||||
->addTextCrumb($project->getName(), $view_uri)
|
||||
->addTextCrumb(pht('Edit Project'), $this->getApplicationURI());
|
||||
->addTextCrumb(pht('Edit'), $edit_uri)
|
||||
->addTextCrumb(pht('Details'));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectEditMainController
|
||||
extends PhabricatorProjectController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = idx($data, 'id');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($this->id))
|
||||
->needImages(true)
|
||||
->executeOne();
|
||||
if (!$project) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Edit %s', $project->getName()))
|
||||
->setUser($viewer)
|
||||
->setPolicyObject($project)
|
||||
->setImage($project->getProfileImageURI());
|
||||
|
||||
if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) {
|
||||
$header->setStatus('oh-ok', '', pht('Active'));
|
||||
} else {
|
||||
$header->setStatus('policy-noone', '', pht('Archived'));
|
||||
}
|
||||
|
||||
$actions = $this->buildActionListView($project);
|
||||
$properties = $this->buildPropertyListView($project, $actions);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb(
|
||||
$project->getName(),
|
||||
$this->getApplicationURI('view/'.$project->getID().'/'));
|
||||
$crumbs->addTextCrumb(pht('Edit'));
|
||||
|
||||
$object_box = id(new PHUIObjectBoxView())
|
||||
->setHeader($header)
|
||||
->addPropertyList($properties);
|
||||
|
||||
$xactions = id(new PhabricatorProjectTransactionQuery())
|
||||
->setViewer($viewer)
|
||||
->withObjectPHIDs(array($project->getPHID()))
|
||||
->execute();
|
||||
|
||||
$timeline = id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($project->getPHID())
|
||||
->setTransactions($xactions);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$object_box,
|
||||
$timeline,
|
||||
),
|
||||
array(
|
||||
'title' => $project->getName(),
|
||||
'device' => true,
|
||||
));
|
||||
}
|
||||
|
||||
private function buildActionListView(PhabricatorProject $project) {
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$id = $project->getID();
|
||||
|
||||
$view = id(new PhabricatorActionListView())
|
||||
->setUser($viewer)
|
||||
->setObjectURI($request->getRequestURI());
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
$project,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Edit Details'))
|
||||
->setIcon('edit')
|
||||
->setHref($this->getApplicationURI("details/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Edit Picture'))
|
||||
->setIcon('image')
|
||||
->setHref($this->getApplicationURI("picture/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
if ($project->isArchived()) {
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Unarchive Project'))
|
||||
->setIcon('enable')
|
||||
->setHref($this->getApplicationURI("archive/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(true));
|
||||
} else {
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Archive Project'))
|
||||
->setIcon('disable')
|
||||
->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)
|
||||
->setObject($project)
|
||||
->setActionList($actions);
|
||||
|
||||
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
|
||||
$viewer,
|
||||
$project);
|
||||
|
||||
$view->addProperty(
|
||||
pht('Visible To'),
|
||||
$descriptions[PhabricatorPolicyCapability::CAN_VIEW]);
|
||||
|
||||
$view->addProperty(
|
||||
pht('Editable By'),
|
||||
$descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
|
||||
|
||||
$view->addProperty(
|
||||
pht('Joinable By'),
|
||||
$descriptions[PhabricatorPolicyCapability::CAN_JOIN]);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectProfilePictureController
|
||||
final class PhabricatorProjectEditPictureController
|
||||
extends PhabricatorProjectController {
|
||||
|
||||
private $id;
|
||||
|
@ -26,7 +26,8 @@ final class PhabricatorProjectProfilePictureController
|
|||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$project_uri = $this->getApplicationURI('view/'.$project->getID().'/');
|
||||
$edit_uri = $this->getApplicationURI('edit/'.$project->getID().'/');
|
||||
$view_uri = $this->getApplicationURI('view/'.$project->getID().'/');
|
||||
|
||||
$supported_formats = PhabricatorFile::getTransformableImageFormats();
|
||||
$e_file = true;
|
||||
|
@ -93,14 +94,15 @@ final class PhabricatorProjectProfilePictureController
|
|||
|
||||
$editor->applyTransactions($project, $xactions);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($project_uri);
|
||||
return id(new AphrontRedirectResponse())->setURI($edit_uri);
|
||||
}
|
||||
}
|
||||
|
||||
$title = pht('Edit Project Picture');
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($project->getName(), $project_uri);
|
||||
$crumbs->addTextCrumb($title);
|
||||
$crumbs->addTextCrumb($project->getName(), $view_uri);
|
||||
$crumbs->addTextCrumb(pht('Edit'), $edit_uri);
|
||||
$crumbs->addTextCrumb(pht('Picture'));
|
||||
|
||||
$form = id(new PHUIFormLayoutView())
|
||||
->setUser($viewer);
|
||||
|
@ -244,7 +246,7 @@ final class PhabricatorProjectProfilePictureController
|
|||
pht('Supported formats: %s', implode(', ', $supported_formats))))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton($project_uri)
|
||||
->addCancelButton($edit_uri)
|
||||
->setValue(pht('Upload Picture')));
|
||||
|
||||
$form_box = id(new PHUIObjectBoxView())
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectHistoryController
|
||||
extends PhabricatorProjectController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$id = $this->id;
|
||||
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->executeOne();
|
||||
if (!$project) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$xactions = id(new PhabricatorProjectTransactionQuery())
|
||||
->setViewer($viewer)
|
||||
->withObjectPHIDs(array($project->getPHID()))
|
||||
->execute();
|
||||
|
||||
$timeline = id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($project->getPHID())
|
||||
->setTransactions($xactions);
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs()
|
||||
->addTextCrumb(
|
||||
$project->getName(),
|
||||
$this->getApplicationURI("view/{$id}/"))
|
||||
->addTextCrumb(pht('History'));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$timeline,
|
||||
),
|
||||
array(
|
||||
'title' => $project->getName(),
|
||||
'device' => true,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
|
@ -4,7 +4,6 @@ final class PhabricatorProjectProfileController
|
|||
extends PhabricatorProjectController {
|
||||
|
||||
private $id;
|
||||
private $page;
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
|
@ -12,7 +11,6 @@ final class PhabricatorProjectProfileController
|
|||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = idx($data, 'id');
|
||||
$this->page = idx($data, 'page');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
|
@ -200,45 +198,16 @@ final class PhabricatorProjectProfileController
|
|||
id(new PhabricatorActionView())
|
||||
->setName(pht('Edit Project'))
|
||||
->setIcon('edit')
|
||||
->setHref($this->getApplicationURI("edit/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
if ($project->isArchived()) {
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Unarchive Project'))
|
||||
->setIcon('enable')
|
||||
->setHref($this->getApplicationURI("archive/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(true));
|
||||
} else {
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Archive Project'))
|
||||
->setIcon('disable')
|
||||
->setHref($this->getApplicationURI("archive/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(true));
|
||||
}
|
||||
->setHref($this->getApplicationURI("edit/{$id}/")));
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Edit Members'))
|
||||
->setIcon('edit')
|
||||
->setIcon('user')
|
||||
->setHref($this->getApplicationURI("members/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Edit Picture'))
|
||||
->setIcon('image')
|
||||
->setHref($this->getApplicationURI("picture/{$id}/"))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
|
||||
$action = null;
|
||||
if (!$project->isUserMember($viewer->getPHID())) {
|
||||
$can_join = PhabricatorPolicyFilter::hasCapability(
|
||||
|
@ -262,12 +231,6 @@ final class PhabricatorProjectProfileController
|
|||
}
|
||||
$view->addAction($action);
|
||||
|
||||
$view->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('View History'))
|
||||
->setHref($this->getApplicationURI("history/{$id}/"))
|
||||
->setIcon('transcript'));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
@ -284,10 +247,6 @@ final class PhabricatorProjectProfileController
|
|||
->setObject($project)
|
||||
->setActionList($actions);
|
||||
|
||||
$view->addProperty(
|
||||
pht('Created'),
|
||||
phabricator_datetime($project->getDateCreated(), $viewer));
|
||||
|
||||
$view->addProperty(
|
||||
pht('Members'),
|
||||
$project->getMemberPHIDs()
|
||||
|
|
Loading…
Reference in a new issue