mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-27 15:08:20 +01:00
Use standard UI kit on project member page
Summary: Fixes T4400. Removes very, very old "PhabricatorObjectListView", which was only used here. Test Plan: {F132249} Reviewers: chad, btrahan Reviewed By: btrahan Subscribers: epriestley, chad Maniphest Tasks: T4400 Differential Revision: https://secure.phabricator.com/D8574
This commit is contained in:
parent
cebc7f4e8b
commit
70ed1ff7d0
7 changed files with 110 additions and 128 deletions
|
@ -95,7 +95,6 @@ return array(
|
|||
'rsrc/css/application/ponder/post.css' => 'ebab8a70',
|
||||
'rsrc/css/application/ponder/vote.css' => '8ed6ed8b',
|
||||
'rsrc/css/application/profile/profile-view.css' => '9bdb9804',
|
||||
'rsrc/css/application/projects/phabricator-object-list-view.css' => '1a1ea560',
|
||||
'rsrc/css/application/projects/project-tag.css' => '095c9404',
|
||||
'rsrc/css/application/releeph/releeph-branch.css' => 'b8821d2d',
|
||||
'rsrc/css/application/releeph/releeph-colors.css' => '2d2d6aa8',
|
||||
|
@ -705,7 +704,6 @@ return array(
|
|||
'phabricator-notification' => '0c6946e7',
|
||||
'phabricator-notification-css' => '6901121e',
|
||||
'phabricator-notification-menu-css' => 'fc9a363c',
|
||||
'phabricator-object-list-view-css' => '1a1ea560',
|
||||
'phabricator-object-selector-css' => '029a133d',
|
||||
'phabricator-phtize' => 'd254d646',
|
||||
'phabricator-prefab' => '0326e5d0',
|
||||
|
|
|
@ -1735,7 +1735,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorObjectHandleStatus' => 'applications/phid/handle/const/PhabricatorObjectHandleStatus.php',
|
||||
'PhabricatorObjectListQuery' => 'applications/phid/query/PhabricatorObjectListQuery.php',
|
||||
'PhabricatorObjectListQueryTestCase' => 'applications/phid/query/__tests__/PhabricatorObjectListQueryTestCase.php',
|
||||
'PhabricatorObjectListView' => 'view/control/PhabricatorObjectListView.php',
|
||||
'PhabricatorObjectMailReceiver' => 'applications/metamta/receiver/PhabricatorObjectMailReceiver.php',
|
||||
'PhabricatorObjectMailReceiverTestCase' => 'applications/metamta/receiver/__tests__/PhabricatorObjectMailReceiverTestCase.php',
|
||||
'PhabricatorObjectQuery' => 'applications/phid/query/PhabricatorObjectQuery.php',
|
||||
|
@ -1864,6 +1863,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectEditorTestCase' => 'applications/project/editor/__tests__/PhabricatorProjectEditorTestCase.php',
|
||||
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
|
||||
'PhabricatorProjectMembersEditController' => 'applications/project/controller/PhabricatorProjectMembersEditController.php',
|
||||
'PhabricatorProjectMembersRemoveController' => 'applications/project/controller/PhabricatorProjectMembersRemoveController.php',
|
||||
'PhabricatorProjectMoveController' => 'applications/project/controller/PhabricatorProjectMoveController.php',
|
||||
'PhabricatorProjectNameCollisionException' => 'applications/project/exception/PhabricatorProjectNameCollisionException.php',
|
||||
'PhabricatorProjectPHIDTypeColumn' => 'applications/project/phid/PhabricatorProjectPHIDTypeColumn.php',
|
||||
|
@ -4494,7 +4494,6 @@ phutil_register_library_map(array(
|
|||
'PhabricatorObjectHandle' => 'PhabricatorPolicyInterface',
|
||||
'PhabricatorObjectHandleStatus' => 'PhabricatorObjectHandleConstants',
|
||||
'PhabricatorObjectListQueryTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorObjectListView' => 'AphrontView',
|
||||
'PhabricatorObjectMailReceiver' => 'PhabricatorMailReceiver',
|
||||
'PhabricatorObjectMailReceiverTestCase' => 'PhabricatorTestCase',
|
||||
'PhabricatorObjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
|
@ -4654,6 +4653,7 @@ phutil_register_library_map(array(
|
|||
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
|
||||
),
|
||||
'PhabricatorProjectMembersEditController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectMembersRemoveController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectMoveController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectNameCollisionException' => 'Exception',
|
||||
'PhabricatorProjectPHIDTypeColumn' => 'PhabricatorPHIDType',
|
||||
|
|
|
@ -44,6 +44,8 @@ final class PhabricatorApplicationProject extends PhabricatorApplication {
|
|||
'PhabricatorProjectArchiveController',
|
||||
'members/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorProjectMembersEditController',
|
||||
'members/(?P<id>[1-9]\d*)/remove/'
|
||||
=> 'PhabricatorProjectMembersRemoveController',
|
||||
'view/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorProjectProfileController',
|
||||
'picture/(?P<id>[1-9]\d*)/' =>
|
||||
|
|
|
@ -76,8 +76,6 @@ final class PhabricatorProjectMembersEditController
|
|||
$header_name = pht('Edit Members');
|
||||
$title = pht('Edit Members');
|
||||
|
||||
$list = $this->renderMemberList($handles);
|
||||
|
||||
$form = new AphrontFormView();
|
||||
$form
|
||||
->setUser($user)
|
||||
|
@ -90,15 +88,8 @@ final class PhabricatorProjectMembersEditController
|
|||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton('/project/view/'.$project->getID().'/')
|
||||
->setValue(pht('Add Members')));
|
||||
$faux_form = id(new AphrontFormView())
|
||||
->setUser($user)
|
||||
->appendChild(
|
||||
id(new AphrontFormInsetView())
|
||||
->appendChild($list));
|
||||
|
||||
$box = id(new PHUIObjectBoxView())
|
||||
->setHeaderText(pht('Current Members (%d)', count($handles)))
|
||||
->setForm($faux_form);
|
||||
$member_list = $this->renderMemberList($project, $handles);
|
||||
|
||||
$form_box = id(new PHUIObjectBoxView())
|
||||
->setHeaderText($title)
|
||||
|
@ -114,7 +105,7 @@ final class PhabricatorProjectMembersEditController
|
|||
array(
|
||||
$crumbs,
|
||||
$form_box,
|
||||
$box,
|
||||
$member_list,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
|
@ -122,38 +113,33 @@ final class PhabricatorProjectMembersEditController
|
|||
));
|
||||
}
|
||||
|
||||
private function renderMemberList(array $handles) {
|
||||
private function renderMemberList(
|
||||
PhabricatorProject $project,
|
||||
array $handles) {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
$list = id(new PhabricatorObjectListView())
|
||||
->setHandles($handles);
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$list = id(new PHUIObjectItemListView())
|
||||
->setNoDataString(pht('This project does not have any members.'));
|
||||
|
||||
foreach ($handles as $handle) {
|
||||
$hidden_input = phutil_tag(
|
||||
'input',
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'remove',
|
||||
'value' => $handle->getPHID(),
|
||||
),
|
||||
'');
|
||||
$remove_uri = $this->getApplicationURI(
|
||||
'/members/'.$project->getID().'/remove/?phid='.$handle->getPHID());
|
||||
|
||||
$button = javelin_tag(
|
||||
'button',
|
||||
array(
|
||||
'class' => 'grey',
|
||||
),
|
||||
pht('Remove'));
|
||||
$item = id(new PHUIObjectItemView())
|
||||
->setHeader($handle->getFullName())
|
||||
->setHref($handle->getURI())
|
||||
->setImageURI($handle->getImageURI());
|
||||
|
||||
$list->addButton(
|
||||
$handle,
|
||||
phabricator_form(
|
||||
$user,
|
||||
array(
|
||||
'method' => 'POST',
|
||||
'action' => $request->getRequestURI(),
|
||||
),
|
||||
array($hidden_input, $button)));
|
||||
$item->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setIcon('delete')
|
||||
->setName(pht('Remove'))
|
||||
->setHref($remove_uri)
|
||||
->setWorkflow(true));
|
||||
|
||||
$list->addItem($item);
|
||||
}
|
||||
|
||||
return $list;
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectMembersRemoveController
|
||||
extends PhabricatorProjectController {
|
||||
|
||||
private $id;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
|
||||
$project = id(new PhabricatorProjectQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($this->id))
|
||||
->needMembers(true)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$project) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$member_phids = $project->getMemberPHIDs();
|
||||
$remove_phid = $request->getStr('phid');
|
||||
|
||||
if (!in_array($remove_phid, $member_phids)) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$members_uri = $this->getApplicationURI('members/'.$project->getID().'/');
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$member_spec = array();
|
||||
$member_spec['-'] = array($remove_phid => $remove_phid);
|
||||
|
||||
$type_member = PhabricatorEdgeConfig::TYPE_PROJ_MEMBER;
|
||||
|
||||
$xactions = array();
|
||||
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $type_member)
|
||||
->setNewValue($member_spec);
|
||||
|
||||
$editor = id(new PhabricatorProjectTransactionEditor($project))
|
||||
->setActor($viewer)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContinueOnMissingFields(true)
|
||||
->applyTransactions($project, $xactions);
|
||||
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($members_uri);
|
||||
}
|
||||
|
||||
$handle = id(new PhabricatorHandleQuery())
|
||||
->setViewer($viewer)
|
||||
->withPHIDs(array($remove_phid))
|
||||
->executeOne();
|
||||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($viewer)
|
||||
->setTitle(pht('Really Remove Member?'))
|
||||
->appendParagraph(
|
||||
pht(
|
||||
'Really remove %s from the project %s?',
|
||||
phutil_tag('strong', array(), $handle->getName()),
|
||||
phutil_tag('strong', array(), $project->getName())))
|
||||
->addCancelButton($members_uri)
|
||||
->addSubmitButton(pht('Remove Project Member'));
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorObjectListView extends AphrontView {
|
||||
|
||||
private $handles = array();
|
||||
private $buttons = array();
|
||||
|
||||
public function setHandles(array $handles) {
|
||||
assert_instances_of($handles, 'PhabricatorObjectHandle');
|
||||
|
||||
$this->handles = $handles;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addButton(PhabricatorObjectHandle $handle, $button) {
|
||||
$this->buttons[$handle->getPHID()][] = $button;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$handles = $this->handles;
|
||||
|
||||
require_celerity_resource('phabricator-object-list-view-css');
|
||||
|
||||
$out = array();
|
||||
foreach ($handles as $handle) {
|
||||
$buttons = idx($this->buttons, $handle->getPHID(), array());
|
||||
if ($buttons) {
|
||||
$buttons = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-object-list-view-buttons',
|
||||
),
|
||||
$buttons);
|
||||
} else {
|
||||
$buttons = null;
|
||||
}
|
||||
|
||||
$out[] = javelin_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-object-list-view-item',
|
||||
'style' => 'background-image: url('.$handle->getImageURI().');',
|
||||
),
|
||||
array(
|
||||
$handle->renderLink(),
|
||||
$buttons,
|
||||
));
|
||||
}
|
||||
|
||||
return phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phabricator-object-list-view',
|
||||
),
|
||||
$out);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/**
|
||||
* @provides phabricator-object-list-view-css
|
||||
*/
|
||||
|
||||
.phabricator-object-list-view {
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.phabricator-object-list-view-item {
|
||||
line-height: 60px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: 5px 5px;
|
||||
padding-left: 70px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.phabricator-object-list-view-item + .phabricator-object-list-view-item {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.phabricator-object-list-view-buttons {
|
||||
position: absolute;
|
||||
text-align: right;
|
||||
top: 0;
|
||||
right: 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue