mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
Clean up EditEngine implementation on Badges
Summary: Fixes T10672. Cleaning this up myself since I was responsible for the implementation. Test Plan: Leave a comment, Edit a badge, create a badge. Reviewers: lpriestley, epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T10672 Differential Revision: https://secure.phabricator.com/D15556
This commit is contained in:
parent
dc2dab94bb
commit
154234dd1f
4 changed files with 24 additions and 36 deletions
|
@ -45,8 +45,8 @@ final class PhabricatorBadgesApplication extends PhabricatorApplication {
|
|||
=> 'PhabricatorBadgesEditController',
|
||||
'comment/(?P<id>[1-9]\d*)/'
|
||||
=> 'PhabricatorBadgesCommentController',
|
||||
'edit/(?:(?P<id>\d+)/)?'
|
||||
=> 'PhabricatorBadgesEditController',
|
||||
$this->getEditRoutePattern('edit/')
|
||||
=> 'PhabricatorBadgesEditController',
|
||||
'archive/(?:(?P<id>\d+)/)?'
|
||||
=> 'PhabricatorBadgesArchiveController',
|
||||
'view/(?:(?P<id>\d+)/)?'
|
||||
|
|
|
@ -16,16 +16,9 @@ final class PhabricatorBadgesListController
|
|||
protected function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
$can_create = $this->hasApplicationCapability(
|
||||
PhabricatorBadgesCreateCapability::CAPABILITY);
|
||||
|
||||
$crumbs->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setName(pht('Create Badge'))
|
||||
->setHref($this->getApplicationURI('create/'))
|
||||
->setIcon('fa-plus-square')
|
||||
->setDisabled(!$can_create)
|
||||
->setWorkflow(!$can_create));
|
||||
id(new PhabricatorBadgesEditEngine())
|
||||
->setViewer($this->getViewer())
|
||||
->addActionToCrumbs($crumbs);
|
||||
|
||||
return $crumbs;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,9 @@ final class PhabricatorBadgesViewController
|
|||
->setHandles($handles)
|
||||
->setUser($viewer);
|
||||
|
||||
$add_comment = $this->buildCommentForm($badge);
|
||||
$comment_view = id(new PhabricatorBadgesEditEngine())
|
||||
->setViewer($viewer)
|
||||
->buildEditEngineCommentView($badge);
|
||||
|
||||
$view = id(new PHUITwoColumnView())
|
||||
->setHeader($header)
|
||||
|
@ -68,7 +70,7 @@ final class PhabricatorBadgesViewController
|
|||
->setMainColumn(array(
|
||||
$recipient_list,
|
||||
$timeline,
|
||||
$add_comment,
|
||||
$comment_view,
|
||||
))
|
||||
->addPropertySection(pht('DESCRIPTION'), $details);
|
||||
|
||||
|
@ -154,24 +156,4 @@ final class PhabricatorBadgesViewController
|
|||
return $curtain;
|
||||
}
|
||||
|
||||
private function buildCommentForm(PhabricatorBadgesBadge $badge) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
||||
|
||||
$add_comment_header = $is_serious
|
||||
? pht('Add Comment')
|
||||
: pht('Render Honors');
|
||||
|
||||
$draft = PhabricatorDraft::newFromUserAndKey($viewer, $badge->getPHID());
|
||||
|
||||
return id(new PhabricatorApplicationTransactionCommentView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($badge->getPHID())
|
||||
->setDraft($draft)
|
||||
->setHeaderText($add_comment_header)
|
||||
->setAction($this->getApplicationURI('/comment/'.$badge->getID().'/'))
|
||||
->setSubmitButtonName(pht('Add Comment'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,18 +49,31 @@ final class PhabricatorBadgesEditEngine
|
|||
return pht('Badge');
|
||||
}
|
||||
|
||||
protected function getObjectCreateCancelURI($object) {
|
||||
return $this->getApplication()->getApplicationURI('/');
|
||||
}
|
||||
|
||||
protected function getEditorURI() {
|
||||
return $this->getApplication()->getApplicationURI('edit/');
|
||||
}
|
||||
|
||||
protected function getCommentViewHeaderText($object) {
|
||||
return pht('Add Comment');
|
||||
return pht('Render Honors');
|
||||
}
|
||||
|
||||
protected function getCommentViewButtonText($object) {
|
||||
return pht('Submit');
|
||||
return pht('Salute');
|
||||
}
|
||||
|
||||
protected function getObjectViewURI($object) {
|
||||
return $object->getViewURI();
|
||||
}
|
||||
|
||||
protected function getCreateNewObjectPolicy() {
|
||||
return $this->getApplication()->getPolicy(
|
||||
PhabricatorBadgesCreateCapability::CAPABILITY);
|
||||
}
|
||||
|
||||
protected function buildCustomEditFields($object) {
|
||||
|
||||
return array(
|
||||
|
|
Loading…
Reference in a new issue