Differential D19663 Diff 47002 src/applications/phriction/controller/PhrictionDocumentController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/controller/PhrictionDocumentController.php
Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | if (!$document) { | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'phui-document-version-navigation', | 'class' => 'phui-document-version-navigation', | ||||
), | ), | ||||
$button_bar), | $button_bar), | ||||
); | ); | ||||
} else { | } else { | ||||
$content = $document->getContent(); | $content = $document->getContent(); | ||||
if ($content->getVersion() < $document->getMaxVersion()) { | |||||
amckinley: I've seen this line of code a few times now; maybe this should be an `isDraft()` method on… | |||||
Done Inline ActionsThis seems reasonable but I couldn't actually find any other checks against this particular condition, or any checks where we're asking the same question in numerous places. We do:
I'll keep an eye out for opportunities here. This might be worth doing even if we have only one callsite today just for clarity, but I'd guess we'll pick up additional callsites for at least some of these questions when, e.g., phriction.document.search gets expanded to handle drafts. epriestley: This seems reasonable but I couldn't actually find any other checks against this particular… | |||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | |||||
$viewer, | |||||
$document, | |||||
PhabricatorPolicyCapability::CAN_EDIT); | |||||
if ($can_edit) { | |||||
$document_uri = new PhutilURI($document->getURI()); | |||||
$draft_uri = $document_uri->alter('v', $document->getMaxVersion()); | |||||
$draft_link = phutil_tag( | |||||
'a', | |||||
array( | |||||
'href' => $draft_uri, | |||||
), | |||||
pht('View Draft Version')); | |||||
$draft_link = phutil_tag('strong', array(), $draft_link); | |||||
$version_note = id(new PHUIInfoView()) | |||||
->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | |||||
->appendChild( | |||||
array( | |||||
pht('This document has unpublished draft changes.'), | |||||
' ', | |||||
$draft_link, | |||||
)); | |||||
} | |||||
} | |||||
} | } | ||||
$page_title = $content->getTitle(); | $page_title = $content->getTitle(); | ||||
$properties = $this | $properties = $this | ||||
->buildPropertyListView($document, $content, $slug); | ->buildPropertyListView($document, $content, $slug); | ||||
$doc_status = $document->getStatus(); | $doc_status = $document->getStatus(); | ||||
$current_status = $content->getChangeType(); | $current_status = $content->getChangeType(); | ||||
▲ Show 20 Lines • Show All 473 Lines • Show Last 20 Lines |
I've seen this line of code a few times now; maybe this should be an isDraft() method on PhrictionDocument?