mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Convert Macro to PHUITwoColumnView
Summary: Converts Macro to new layout Test Plan: Add Macro, Edit Macro, Mobile, Desktop layouts Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D15372
This commit is contained in:
parent
caadd1025a
commit
6f481aa84f
1 changed files with 81 additions and 39 deletions
|
@ -20,29 +20,18 @@ final class PhabricatorMacroViewController
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $macro->getFile();
|
|
||||||
|
|
||||||
$title_short = pht('Macro "%s"', $macro->getName());
|
$title_short = pht('Macro "%s"', $macro->getName());
|
||||||
$title_long = pht('Image Macro "%s"', $macro->getName());
|
$title_long = pht('Image Macro "%s"', $macro->getName());
|
||||||
|
|
||||||
$actions = $this->buildActionView($macro);
|
$actions = $this->buildActionView($macro);
|
||||||
|
$subheader = $this->buildSubheaderView($macro);
|
||||||
|
$properties = $this->buildPropertyView($macro);
|
||||||
|
$file = $this->buildFileView($macro);
|
||||||
|
$details = $this->buildPropertySectionView($macro);
|
||||||
|
|
||||||
$crumbs = $this->buildApplicationCrumbs();
|
$crumbs = $this->buildApplicationCrumbs();
|
||||||
$crumbs->addTextCrumb(
|
$crumbs->addTextCrumb($macro->getName());
|
||||||
$title_short,
|
$crumbs->setBorder(true);
|
||||||
$this->getApplicationURI('/view/'.$macro->getID().'/'));
|
|
||||||
|
|
||||||
$properties = $this->buildPropertyView($macro, $actions);
|
|
||||||
if ($file) {
|
|
||||||
$file_view = new PHUIPropertyListView();
|
|
||||||
$file_view->addImageContent(
|
|
||||||
phutil_tag(
|
|
||||||
'img',
|
|
||||||
array(
|
|
||||||
'src' => $file->getViewURI(),
|
|
||||||
'class' => 'phabricator-image-macro-hero',
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
$timeline = $this->buildTransactionTimeline(
|
$timeline = $this->buildTransactionTimeline(
|
||||||
$macro,
|
$macro,
|
||||||
|
@ -75,28 +64,30 @@ final class PhabricatorMacroViewController
|
||||||
->setAction($this->getApplicationURI('/comment/'.$macro->getID().'/'))
|
->setAction($this->getApplicationURI('/comment/'.$macro->getID().'/'))
|
||||||
->setSubmitButtonName(pht('Add Comment'));
|
->setSubmitButtonName(pht('Add Comment'));
|
||||||
|
|
||||||
$object_box = id(new PHUIObjectBoxView())
|
$view = id(new PHUITwoColumnView())
|
||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->addPropertyList($properties);
|
->setSubheader($subheader)
|
||||||
|
->setMainColumn(array(
|
||||||
if ($file_view) {
|
|
||||||
$object_box->addPropertyList($file_view);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
|
||||||
array(
|
|
||||||
$crumbs,
|
|
||||||
$object_box,
|
|
||||||
$timeline,
|
$timeline,
|
||||||
$add_comment_form,
|
$add_comment_form,
|
||||||
),
|
))
|
||||||
array(
|
->addPropertySection(pht('MACRO'), $file)
|
||||||
'title' => $title_short,
|
->addPropertySection(pht('DETAILS'), $details)
|
||||||
'pageObjects' => array($macro->getPHID()),
|
->setPropertyList($properties)
|
||||||
|
->setActionList($actions);
|
||||||
|
|
||||||
|
return $this->newPage()
|
||||||
|
->setTitle($title_short)
|
||||||
|
->setCrumbs($crumbs)
|
||||||
|
->setPageObjectPHIDs(array($macro->getPHID()))
|
||||||
|
->appendChild(
|
||||||
|
array(
|
||||||
|
$view,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildActionView(PhabricatorFileImageMacro $macro) {
|
private function buildActionView(
|
||||||
|
PhabricatorFileImageMacro $macro) {
|
||||||
$can_manage = $this->hasApplicationCapability(
|
$can_manage = $this->hasApplicationCapability(
|
||||||
PhabricatorMacroManageCapability::CAPABILITY);
|
PhabricatorMacroManageCapability::CAPABILITY);
|
||||||
|
|
||||||
|
@ -141,15 +132,34 @@ final class PhabricatorMacroViewController
|
||||||
return $view;
|
return $view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildPropertyView(
|
private function buildSubheaderView(
|
||||||
PhabricatorFileImageMacro $macro,
|
PhabricatorFileImageMacro $macro) {
|
||||||
PhabricatorActionListView $actions) {
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$author_phid = $macro->getAuthorPHID();
|
||||||
|
|
||||||
|
$author = $viewer->renderHandle($author_phid)->render();
|
||||||
|
$date = phabricator_datetime($macro->getDateCreated(), $viewer);
|
||||||
|
$author = phutil_tag('strong', array(), $author);
|
||||||
|
|
||||||
|
$handles = $viewer->loadHandles(array($author_phid));
|
||||||
|
$image_uri = $handles[$author_phid]->getImageURI();
|
||||||
|
$image_href = $handles[$author_phid]->getURI();
|
||||||
|
|
||||||
|
$content = pht('Masterfully imagined by %s on %s.', $author, $date);
|
||||||
|
|
||||||
|
return id(new PHUIHeadThingView())
|
||||||
|
->setImage($image_uri)
|
||||||
|
->setImageHref($image_href)
|
||||||
|
->setContent($content);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildPropertySectionView(
|
||||||
|
PhabricatorFileImageMacro $macro) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$view = id(new PHUIPropertyListView())
|
$view = id(new PHUIPropertyListView())
|
||||||
->setUser($this->getRequest()->getUser())
|
->setUser($viewer);
|
||||||
->setObject($macro)
|
|
||||||
->setActionList($actions);
|
|
||||||
|
|
||||||
switch ($macro->getAudioBehavior()) {
|
switch ($macro->getAudioBehavior()) {
|
||||||
case PhabricatorFileImageMacro::AUDIO_BEHAVIOR_ONCE:
|
case PhabricatorFileImageMacro::AUDIO_BEHAVIOR_ONCE:
|
||||||
|
@ -167,6 +177,38 @@ final class PhabricatorMacroViewController
|
||||||
$viewer->renderHandle($audio_phid));
|
$viewer->renderHandle($audio_phid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildFileView(
|
||||||
|
PhabricatorFileImageMacro $macro) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$view = id(new PHUIPropertyListView())
|
||||||
|
->setUser($viewer);
|
||||||
|
|
||||||
|
$file = $macro->getFile();
|
||||||
|
if ($file) {
|
||||||
|
$view->addImageContent(
|
||||||
|
phutil_tag(
|
||||||
|
'img',
|
||||||
|
array(
|
||||||
|
'src' => $file->getViewURI(),
|
||||||
|
'class' => 'phabricator-image-macro-hero',
|
||||||
|
)));
|
||||||
|
return $view;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildPropertyView(
|
||||||
|
PhabricatorFileImageMacro $macro) {
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
|
$view = id(new PHUIPropertyListView())
|
||||||
|
->setUser($this->getRequest()->getUser())
|
||||||
|
->setObject($macro);
|
||||||
|
|
||||||
$view->invokeWillRenderEvent();
|
$view->invokeWillRenderEvent();
|
||||||
|
|
||||||
return $view;
|
return $view;
|
||||||
|
|
Loading…
Reference in a new issue