mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-21 21:10:56 +01:00
Use modern UI elements and application/event-oriented construction in Projects
Summary: Ref T2715. This partially modernizes projects. Precursor to using ApplicationSearch, which is a precursor to using application PHIDs. Then, some day, we will make projects good. Test Plan: {F51126} Reviewers: btrahan, chad Reviewed By: chad CC: aran Maniphest Tasks: T2715 Differential Revision: https://secure.phabricator.com/D6524
This commit is contained in:
parent
3fcd9c93f1
commit
7cbe82d777
8 changed files with 152 additions and 162 deletions
|
@ -1812,6 +1812,7 @@ phutil_register_library_map(array(
|
||||||
'PhrequentUserTime' => 'applications/phrequent/storage/PhrequentUserTime.php',
|
'PhrequentUserTime' => 'applications/phrequent/storage/PhrequentUserTime.php',
|
||||||
'PhrequentUserTimeQuery' => 'applications/phrequent/query/PhrequentUserTimeQuery.php',
|
'PhrequentUserTimeQuery' => 'applications/phrequent/query/PhrequentUserTimeQuery.php',
|
||||||
'PhrictionActionConstants' => 'applications/phriction/constants/PhrictionActionConstants.php',
|
'PhrictionActionConstants' => 'applications/phriction/constants/PhrictionActionConstants.php',
|
||||||
|
'PhrictionActionMenuEventListener' => 'applications/phriction/event/PhrictionActionMenuEventListener.php',
|
||||||
'PhrictionChangeType' => 'applications/phriction/constants/PhrictionChangeType.php',
|
'PhrictionChangeType' => 'applications/phriction/constants/PhrictionChangeType.php',
|
||||||
'PhrictionConstants' => 'applications/phriction/constants/PhrictionConstants.php',
|
'PhrictionConstants' => 'applications/phriction/constants/PhrictionConstants.php',
|
||||||
'PhrictionContent' => 'applications/phriction/storage/PhrictionContent.php',
|
'PhrictionContent' => 'applications/phriction/storage/PhrictionContent.php',
|
||||||
|
@ -3850,6 +3851,7 @@ phutil_register_library_map(array(
|
||||||
'PhrequentUserTime' => 'PhrequentDAO',
|
'PhrequentUserTime' => 'PhrequentDAO',
|
||||||
'PhrequentUserTimeQuery' => 'PhabricatorOffsetPagedQuery',
|
'PhrequentUserTimeQuery' => 'PhabricatorOffsetPagedQuery',
|
||||||
'PhrictionActionConstants' => 'PhrictionConstants',
|
'PhrictionActionConstants' => 'PhrictionConstants',
|
||||||
|
'PhrictionActionMenuEventListener' => 'PhutilEventListener',
|
||||||
'PhrictionChangeType' => 'PhrictionConstants',
|
'PhrictionChangeType' => 'PhrictionConstants',
|
||||||
'PhrictionContent' =>
|
'PhrictionContent' =>
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -15,20 +15,21 @@ final class ManiphestPeopleMenuEventListener extends PhutilEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function handleActionsEvent($event) {
|
private function handleActionsEvent($event) {
|
||||||
$person = $event->getValue('object');
|
|
||||||
if (!($person instanceof PhabricatorUser)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$href = '/maniphest/view/action/?users='.$person->getPHID();
|
|
||||||
|
|
||||||
$actions = $event->getValue('actions');
|
$actions = $event->getValue('actions');
|
||||||
|
|
||||||
$actions[] = id(new PhabricatorActionView())
|
$action = id(new PhabricatorActionView())
|
||||||
->setIcon('maniphest-dark')
|
->setIcon('maniphest-dark')
|
||||||
->setIconSheet(PHUIIconView::SPRITE_APPS)
|
->setIconSheet(PHUIIconView::SPRITE_APPS)
|
||||||
->setName(pht('View Tasks'))
|
->setName(pht('View Tasks'));
|
||||||
->setHref($href);
|
|
||||||
|
$object = $event->getValue('object');
|
||||||
|
if ($object instanceof PhabricatorUser) {
|
||||||
|
$href = '/maniphest/view/action/?users='.$object->getPHID();
|
||||||
|
$actions[] = $action->setHref($href);
|
||||||
|
} else if ($object instanceof PhabricatorProject) {
|
||||||
|
$href = '/maniphest/view/all/?projects='.$object->getPHID();
|
||||||
|
$actions[] = $action->setHref($href);
|
||||||
|
}
|
||||||
|
|
||||||
$event->setValue('actions', $actions);
|
$event->setValue('actions', $actions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,12 @@ final class PhabricatorApplicationPhriction extends PhabricatorApplication {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getEventListeners() {
|
||||||
|
return array(
|
||||||
|
new PhrictionActionMenuEventListener(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function getRoutes() {
|
public function getRoutes() {
|
||||||
return array(
|
return array(
|
||||||
// Match "/w/" with slug "/".
|
// Match "/w/" with slug "/".
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhrictionActionMenuEventListener extends PhutilEventListener {
|
||||||
|
|
||||||
|
public function register() {
|
||||||
|
$this->listen(PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleEvent(PhutilEvent $event) {
|
||||||
|
switch ($event->getType()) {
|
||||||
|
case PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS:
|
||||||
|
$this->handleActionsEvent($event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function handleActionsEvent($event) {
|
||||||
|
$actions = $event->getValue('actions');
|
||||||
|
|
||||||
|
$action = id(new PhabricatorActionView())
|
||||||
|
->setIcon('phriction-dark')
|
||||||
|
->setIconSheet(PHUIIconView::SPRITE_APPS)
|
||||||
|
->setName(pht('View Wiki'));
|
||||||
|
|
||||||
|
$object = $event->getValue('object');
|
||||||
|
if ($object instanceof PhabricatorProject) {
|
||||||
|
$slug = PhabricatorSlug::normalize($object->getPhrictionSlug());
|
||||||
|
$href = '/w/projects/'.$slug;
|
||||||
|
$actions[] = $action->setHref($href);
|
||||||
|
}
|
||||||
|
|
||||||
|
$event->setValue('actions', $actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -2,51 +2,6 @@
|
||||||
|
|
||||||
abstract class PhabricatorProjectController extends PhabricatorController {
|
abstract class PhabricatorProjectController extends PhabricatorController {
|
||||||
|
|
||||||
protected function buildLocalNavigation(PhabricatorProject $project) {
|
|
||||||
$id = $project->getID();
|
|
||||||
|
|
||||||
$nav_view = new AphrontSideNavFilterView();
|
|
||||||
$uri = new PhutilURI('/project/view/'.$id.'/');
|
|
||||||
$nav_view->setBaseURI($uri);
|
|
||||||
|
|
||||||
$external_arrow = "\xE2\x86\x97";
|
|
||||||
$tasks_uri = '/maniphest/view/all/?projects='.$project->getPHID();
|
|
||||||
$slug = PhabricatorSlug::normalize($project->getPhrictionSlug());
|
|
||||||
$phriction_uri = '/w/projects/'.$slug;
|
|
||||||
|
|
||||||
$edit_uri = '/project/edit/'.$id.'/';
|
|
||||||
$members_uri = '/project/members/'.$id.'/';
|
|
||||||
|
|
||||||
$nav_view->addLabel(pht('Project'));
|
|
||||||
$nav_view->addFilter('dashboard', pht('Dashboard'));
|
|
||||||
$nav_view->addFilter(null, pht('Tasks').' '.$external_arrow, $tasks_uri);
|
|
||||||
$nav_view->addFilter(null, pht('Wiki').' '.$external_arrow, $phriction_uri);
|
|
||||||
|
|
||||||
$user = $this->getRequest()->getUser();
|
|
||||||
$can_edit = PhabricatorPolicyCapability::CAN_EDIT;
|
|
||||||
|
|
||||||
$nav_view->addLabel(pht('Manage'));
|
|
||||||
if (PhabricatorPolicyFilter::hasCapability($user, $project, $can_edit)) {
|
|
||||||
$nav_view->addFilter('edit', pht("Edit Project"), $edit_uri);
|
|
||||||
$nav_view->addFilter('members', pht("Edit Members"), $members_uri);
|
|
||||||
} else {
|
|
||||||
$nav_view->addFilter(
|
|
||||||
'edit',
|
|
||||||
pht("Edit Project"),
|
|
||||||
$edit_uri,
|
|
||||||
$relative = false,
|
|
||||||
'disabled');
|
|
||||||
$nav_view->addFilter(
|
|
||||||
'members',
|
|
||||||
pht("Edit Members"),
|
|
||||||
$members_uri,
|
|
||||||
$relative = false,
|
|
||||||
'disabled');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $nav_view;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildSideNavView($filter = null, $for_app = false) {
|
public function buildSideNavView($filter = null, $for_app = false) {
|
||||||
$user = $this->getRequest()->getUser();
|
$user = $this->getRequest()->getUser();
|
||||||
|
|
||||||
|
|
|
@ -113,11 +113,6 @@ final class PhabricatorProjectMembersEditController
|
||||||
$box->addPadding(PHUI::PADDING_LARGE);
|
$box->addPadding(PHUI::PADDING_LARGE);
|
||||||
$box->addMargin(PHUI::MARGIN_LARGE);
|
$box->addMargin(PHUI::MARGIN_LARGE);
|
||||||
|
|
||||||
$nav = $this->buildLocalNavigation($project);
|
|
||||||
$nav->selectFilter('members');
|
|
||||||
$nav->appendChild($form);
|
|
||||||
$nav->appendChild($box);
|
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
|
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
|
||||||
$crumbs->addCrumb(
|
$crumbs->addCrumb(
|
||||||
id(new PhabricatorCrumbView())
|
id(new PhabricatorCrumbView())
|
||||||
|
@ -127,10 +122,13 @@ final class PhabricatorProjectMembersEditController
|
||||||
id(new PhabricatorCrumbView())
|
id(new PhabricatorCrumbView())
|
||||||
->setName(pht('Edit Members'))
|
->setName(pht('Edit Members'))
|
||||||
->setHref($this->getApplicationURI()));
|
->setHref($this->getApplicationURI()));
|
||||||
$nav->setCrumbs($crumbs);
|
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
$nav,
|
array(
|
||||||
|
$crumbs,
|
||||||
|
$form,
|
||||||
|
$box,
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'device' => true,
|
'device' => true,
|
||||||
|
|
|
@ -34,10 +34,6 @@ final class PhabricatorProjectProfileController
|
||||||
|
|
||||||
$picture = $profile->loadProfileImageURI();
|
$picture = $profile->loadProfileImageURI();
|
||||||
|
|
||||||
$nav_view = $this->buildLocalNavigation($project);
|
|
||||||
|
|
||||||
$this->page = $nav_view->selectFilter($this->page, 'dashboard');
|
|
||||||
|
|
||||||
require_celerity_resource('phabricator-profile-css');
|
require_celerity_resource('phabricator-profile-css');
|
||||||
|
|
||||||
$tasks = $this->renderTasksPage($project, $profile);
|
$tasks = $this->renderTasksPage($project, $profile);
|
||||||
|
@ -51,12 +47,10 @@ final class PhabricatorProjectProfileController
|
||||||
$query->setViewer($this->getRequest()->getUser());
|
$query->setViewer($this->getRequest()->getUser());
|
||||||
$stories = $query->execute();
|
$stories = $query->execute();
|
||||||
$feed = $this->renderStories($stories);
|
$feed = $this->renderStories($stories);
|
||||||
$about = $this->renderAboutPage($project, $profile);
|
|
||||||
$people = $this->renderPeoplePage($project, $profile);
|
$people = $this->renderPeoplePage($project, $profile);
|
||||||
$col1 = hsprintf('%s%s', $about, $people);
|
|
||||||
|
|
||||||
$content = id(new AphrontMultiColumnView())
|
$content = id(new AphrontMultiColumnView())
|
||||||
->addColumn($col1)
|
->addColumn($people)
|
||||||
->addColumn($feed)
|
->addColumn($feed)
|
||||||
->setFluidLayout(true);
|
->setFluidLayout(true);
|
||||||
|
|
||||||
|
@ -70,97 +64,29 @@ final class PhabricatorProjectProfileController
|
||||||
->setSubheader(phutil_utf8_shorten($profile->getBlurb(), 1024))
|
->setSubheader(phutil_utf8_shorten($profile->getBlurb(), 1024))
|
||||||
->setImage($picture);
|
->setImage($picture);
|
||||||
|
|
||||||
$action = null;
|
$actions = $this->buildActionListView($project);
|
||||||
if (!$project->isUserMember($user->getPHID())) {
|
$properties = $this->buildPropertyListView($project);
|
||||||
$can_join = PhabricatorPolicyFilter::hasCapability(
|
|
||||||
$user,
|
|
||||||
$project,
|
|
||||||
PhabricatorPolicyCapability::CAN_JOIN);
|
|
||||||
|
|
||||||
$action = id(new PhabricatorActionView())
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
->setUser($user)
|
$crumbs->addCrumb(
|
||||||
->setRenderAsForm(true)
|
id(new PhabricatorCrumbView())
|
||||||
->setHref('/project/update/'.$project->getID().'/join/')
|
->setName($project->getName()));
|
||||||
->setIcon('new')
|
|
||||||
->setDisabled(!$can_join)
|
|
||||||
->setName(pht('Join Project'));
|
|
||||||
} else {
|
|
||||||
$action = id(new PhabricatorActionView())
|
|
||||||
->setWorkflow(true)
|
|
||||||
->setHref('/project/update/'.$project->getID().'/leave/')
|
|
||||||
->setIcon('delete')
|
|
||||||
->setName(pht('Leave Project...'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$action_list = id(new PhabricatorActionListView())
|
|
||||||
->setUser($user)
|
|
||||||
->setObjectURI($request->getRequestURI())
|
|
||||||
->addAction($action);
|
|
||||||
|
|
||||||
$nav_view->appendChild($header);
|
|
||||||
$nav_view->appendChild($action_list);
|
|
||||||
$nav_view->appendChild($content);
|
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
$nav_view,
|
|
||||||
array(
|
array(
|
||||||
'title' => pht('%s Project', $project->getName()),
|
$crumbs,
|
||||||
|
$header,
|
||||||
|
$actions,
|
||||||
|
$properties,
|
||||||
|
$content,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'title' => $project->getName(),
|
||||||
'device' => true,
|
'device' => true,
|
||||||
'dust' => true,
|
'dust' => true,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderAboutPage(
|
|
||||||
PhabricatorProject $project,
|
|
||||||
PhabricatorProjectProfile $profile) {
|
|
||||||
|
|
||||||
$viewer = $this->getRequest()->getUser();
|
|
||||||
|
|
||||||
$blurb = $profile->getBlurb();
|
|
||||||
$blurb = phutil_escape_html_newlines($blurb);
|
|
||||||
|
|
||||||
$phids = array($project->getAuthorPHID());
|
|
||||||
$phids = array_unique($phids);
|
|
||||||
$handles = $this->loadViewerHandles($phids);
|
|
||||||
|
|
||||||
$timestamp = phabricator_datetime($project->getDateCreated(), $viewer);
|
|
||||||
|
|
||||||
$about = hsprintf(
|
|
||||||
'<div class="phabricator-profile-info-group profile-wrap-responsive">
|
|
||||||
<h1 class="phabricator-profile-info-header">%s</h1>
|
|
||||||
<div class="phabricator-profile-info-pane">
|
|
||||||
<table class="phabricator-profile-info-table">
|
|
||||||
<tr>
|
|
||||||
<th>%s</th>
|
|
||||||
<td>%s</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>%s</th>
|
|
||||||
<td>%s</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>PHID</th>
|
|
||||||
<td>%s</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th>%s</th>
|
|
||||||
<td>%s</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>',
|
|
||||||
pht('About This Project'),
|
|
||||||
pht('Creator'),
|
|
||||||
$handles[$project->getAuthorPHID()]->renderLink(),
|
|
||||||
pht('Created'),
|
|
||||||
$timestamp,
|
|
||||||
$project->getPHID(),
|
|
||||||
pht('Blurb'),
|
|
||||||
$blurb);
|
|
||||||
|
|
||||||
return $about;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function renderPeoplePage(
|
private function renderPeoplePage(
|
||||||
PhabricatorProject $project,
|
PhabricatorProject $project,
|
||||||
PhabricatorProjectProfile $profile) {
|
PhabricatorProjectProfile $profile) {
|
||||||
|
@ -272,8 +198,79 @@ final class PhabricatorProjectProfileController
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildApplicationMenu() {
|
private function buildActionListView(PhabricatorProject $project) {
|
||||||
return $this->buildLocalNavigation($this->project)->getMenu();
|
$request = $this->getRequest();
|
||||||
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
|
$id = $project->getID();
|
||||||
|
|
||||||
|
$view = id(new PhabricatorActionListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObject($project)
|
||||||
|
->setObjectURI($request->getRequestURI());
|
||||||
|
|
||||||
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$viewer,
|
||||||
|
$project,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT);
|
||||||
|
|
||||||
|
$view->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Edit Project'))
|
||||||
|
->setIcon('edit')
|
||||||
|
->setHref($this->getApplicationURI("edit/{$id}/"))
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
$view->addAction(
|
||||||
|
id(new PhabricatorActionView())
|
||||||
|
->setName(pht('Edit Members'))
|
||||||
|
->setIcon('edit')
|
||||||
|
->setHref($this->getApplicationURI("members/{$id}/"))
|
||||||
|
->setDisabled(!$can_edit)
|
||||||
|
->setWorkflow(!$can_edit));
|
||||||
|
|
||||||
|
|
||||||
|
$action = null;
|
||||||
|
if (!$project->isUserMember($viewer->getPHID())) {
|
||||||
|
$can_join = PhabricatorPolicyFilter::hasCapability(
|
||||||
|
$viewer,
|
||||||
|
$project,
|
||||||
|
PhabricatorPolicyCapability::CAN_JOIN);
|
||||||
|
|
||||||
|
$action = id(new PhabricatorActionView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setRenderAsForm(true)
|
||||||
|
->setHref('/project/update/'.$project->getID().'/join/')
|
||||||
|
->setIcon('new')
|
||||||
|
->setDisabled(!$can_join)
|
||||||
|
->setName(pht('Join Project'));
|
||||||
|
} else {
|
||||||
|
$action = id(new PhabricatorActionView())
|
||||||
|
->setWorkflow(true)
|
||||||
|
->setHref('/project/update/'.$project->getID().'/leave/')
|
||||||
|
->setIcon('delete')
|
||||||
|
->setName(pht('Leave Project...'));
|
||||||
|
}
|
||||||
|
$view->addAction($action);
|
||||||
|
|
||||||
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buildPropertyListView(PhabricatorProject $project) {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$viewer = $request->getUser();
|
||||||
|
|
||||||
|
$view = id(new PhabricatorPropertyListView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObject($project);
|
||||||
|
|
||||||
|
$view->addProperty(
|
||||||
|
pht('Created'),
|
||||||
|
phabricator_datetime($project->getDateCreated(), $viewer));
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,13 +220,6 @@ final class PhabricatorProjectProfileEditController
|
||||||
->addCancelButton('/project/view/'.$project->getID().'/')
|
->addCancelButton('/project/view/'.$project->getID().'/')
|
||||||
->setValue(pht('Save')));
|
->setValue(pht('Save')));
|
||||||
|
|
||||||
$nav = $this->buildLocalNavigation($project);
|
|
||||||
$nav->selectFilter('edit');
|
|
||||||
$nav->appendChild(
|
|
||||||
array(
|
|
||||||
$error_view,
|
|
||||||
$form,
|
|
||||||
));
|
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
|
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
|
||||||
$crumbs->addCrumb(
|
$crumbs->addCrumb(
|
||||||
|
@ -237,10 +230,13 @@ final class PhabricatorProjectProfileEditController
|
||||||
id(new PhabricatorCrumbView())
|
id(new PhabricatorCrumbView())
|
||||||
->setName(pht('Edit Project'))
|
->setName(pht('Edit Project'))
|
||||||
->setHref($this->getApplicationURI()));
|
->setHref($this->getApplicationURI()));
|
||||||
$nav->setCrumbs($crumbs);
|
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->buildApplicationPage(
|
||||||
$nav,
|
array(
|
||||||
|
$crumbs,
|
||||||
|
$error_view,
|
||||||
|
$form,
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'device' => true,
|
'device' => true,
|
||||||
|
|
Loading…
Reference in a new issue