Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15383814
D19622.id46902.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
D19622.id46902.diff
View Options
diff --git a/resources/celerity/map.php b/resources/celerity/map.php
--- a/resources/celerity/map.php
+++ b/resources/celerity/map.php
@@ -148,7 +148,7 @@
'rsrc/css/phui/phui-curtain-view.css' => '2bdaf026',
'rsrc/css/phui/phui-document-pro.css' => '0e41dd91',
'rsrc/css/phui/phui-document-summary.css' => '9ca48bdf',
- 'rsrc/css/phui/phui-document.css' => '552493fa',
+ 'rsrc/css/phui/phui-document.css' => 'c4ac41f9',
'rsrc/css/phui/phui-feed-story.css' => '44a9c8e9',
'rsrc/css/phui/phui-fontkit.css' => '1320ed01',
'rsrc/css/phui/phui-form-view.css' => 'f808e5be',
@@ -813,7 +813,7 @@
'phui-crumbs-view-css' => '10728aaa',
'phui-curtain-view-css' => '2bdaf026',
'phui-document-summary-view-css' => '9ca48bdf',
- 'phui-document-view-css' => '552493fa',
+ 'phui-document-view-css' => 'c4ac41f9',
'phui-document-view-pro-css' => '0e41dd91',
'phui-feed-story-css' => '44a9c8e9',
'phui-font-icon-base-css' => '870a7360',
diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php
--- a/src/applications/phriction/controller/PhrictionDocumentController.php
+++ b/src/applications/phriction/controller/PhrictionDocumentController.php
@@ -20,8 +20,6 @@
return id(new AphrontRedirectResponse())->setURI($uri);
}
- require_celerity_resource('phriction-document-css');
-
$version_note = null;
$core_content = '';
$move_notice = '';
@@ -29,6 +27,8 @@
$content = null;
$toc = null;
+ $is_draft = false;
+
$document = id(new PhrictionDocumentQuery())
->setViewer($viewer)
->withSlugs(array($slug))
@@ -66,8 +66,14 @@
->addAction($create_button);
} else {
- $version = $request->getInt('v');
+ $draft_content = id(new PhrictionContentQuery())
+ ->setViewer($viewer)
+ ->withDocumentPHIDs(array($document->getPHID()))
+ ->setLimit(1)
+ ->executeOne();
+ $max_version = (int)$draft_content->getVersion();
+ $version = $request->getInt('v');
if ($version) {
$content = id(new PhrictionContentQuery())
->setViewer($viewer)
@@ -78,15 +84,111 @@
return new Aphront404Response();
}
- if ($content->getPHID() != $document->getContentPHID()) {
- $version_note = id(new PHUIInfoView())
- ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
- ->appendChild(
- pht(
- 'You are viewing an older version of this document, as it '.
- 'appeared on %s.',
- phabricator_datetime($content->getDateCreated(), $viewer)));
+ // When the "v" parameter exists, the user is in history mode so we
+ // show this header even if they're looking at the current version
+ // of the document. This keeps the next/previous links working.
+
+ $view_version = (int)$content->getVersion();
+ $published_version = (int)$document->getContent()->getVersion();
+
+ if ($view_version < $published_version) {
+ $version_note = pht(
+ 'You are viewing an older version of this document, as it '.
+ 'appeared on %s.',
+ phabricator_datetime($content->getDateCreated(), $viewer));
+ } else if ($view_version > $published_version) {
+ $is_draft = true;
+ $version_note = pht(
+ 'You are viewing an unpublished draft of this document.');
+ } else {
+ $version_note = pht(
+ 'You are viewing the current published version of this document.');
+ }
+
+ $version_note = array(
+ phutil_tag(
+ 'strong',
+ array(),
+ pht('Version %d of %d: ', $view_version, $max_version)),
+ ' ',
+ $version_note,
+ );
+
+ $version_note = id(new PHUIInfoView())
+ ->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
+ ->appendChild($version_note);
+
+ $document_uri = new PhutilURI($document->getURI());
+
+ if ($view_version > 1) {
+ $previous_uri = $document_uri->alter('v', ($view_version - 1));
+ } else {
+ $previous_uri = null;
+ }
+
+ if ($view_version !== $published_version) {
+ $current_uri = $document_uri->alter('v', $published_version);
+ } else {
+ $current_uri = null;
+ }
+
+ if ($view_version < $max_version) {
+ $next_uri = $document_uri->alter('v', ($view_version + 1));
+ } else {
+ $next_uri = null;
+ }
+
+ if ($view_version !== $max_version) {
+ $draft_uri = $document_uri->alter('v', $max_version);
+ } else {
+ $draft_uri = null;
}
+
+ $button_bar = id(new PHUIButtonBarView())
+ ->addButton(
+ id(new PHUIButtonView())
+ ->setTag('a')
+ ->setColor('grey')
+ ->setIcon('fa-backward')
+ ->setDisabled(!$previous_uri)
+ ->setHref($previous_uri)
+ ->setText(pht('Previous')))
+ ->addButton(
+ id(new PHUIButtonView())
+ ->setTag('a')
+ ->setColor('grey')
+ ->setIcon('fa-file-o')
+ ->setDisabled(!$current_uri)
+ ->setHref($current_uri)
+ ->setText(pht('Published')))
+ ->addButton(
+ id(new PHUIButtonView())
+ ->setTag('a')
+ ->setColor('grey')
+ ->setIcon('fa-forward', false)
+ ->setDisabled(!$next_uri)
+ ->setHref($next_uri)
+ ->setText(pht('Next')))
+ ->addButton(
+ id(new PHUIButtonView())
+ ->setTag('a')
+ ->setColor('grey')
+ ->setIcon('fa-fast-forward', false)
+ ->setDisabled(!$draft_uri)
+ ->setHref($draft_uri)
+ ->setText(pht('Draft')));
+
+ require_celerity_resource('phui-document-view-css');
+
+ $version_note = array(
+ $version_note,
+ phutil_tag(
+ 'div',
+ array(
+ 'class' => 'phui-document-version-navigation',
+ ),
+ $button_bar),
+ );
} else {
$content = $document->getContent();
}
@@ -218,7 +320,15 @@
->setPolicyObject($document)
->setHeader($page_title);
- if ($content) {
+ if ($is_draft) {
+ $draft_tag = id(new PHUITagView())
+ ->setName(pht('Draft'))
+ ->setIcon('fa-spinner')
+ ->setColor('pink')
+ ->setType(PHUITagView::TYPE_SHADE);
+
+ $header->addTag($draft_tag);
+ } else if ($content) {
$header->setEpoch($content->getDateCreated());
}
@@ -299,21 +409,37 @@
->setIcon('fa-pencil')
->setHref('/phriction/edit/'.$document->getID().'/'));
+ $curtain->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('View History'))
+ ->setIcon('fa-history')
+ ->setHref(PhrictionDocument::getSlugURI($slug, 'history')));
+
$is_current = false;
$content_id = null;
+ $is_draft = false;
if ($content) {
if ($content->getPHID() == $document->getContentPHID()) {
$is_current = true;
}
$content_id = $content->getID();
+
+ $current_version = $document->getContent()->getVersion();
+ $is_draft = ($content->getVersion() >= $current_version);
}
$can_publish = ($can_edit && $content && !$is_current);
+ if ($is_draft) {
+ $publish_name = pht('Publish Draft');
+ } else {
+ $publish_name = pht('Publish Revert');
+ }
+
$publish_uri = "/phriction/publish/{$id}/{$content_id}/";
$curtain->addAction(
id(new PhabricatorActionView())
- ->setName(pht('Publish'))
+ ->setName($publish_name)
->setIcon('fa-upload')
->setDisabled(!$can_publish)
->setWorkflow(true)
@@ -337,12 +463,6 @@
->setWorkflow(true));
}
- $curtain->addAction(
- id(new PhabricatorActionView())
- ->setName(pht('View History'))
- ->setIcon('fa-list')
- ->setHref(PhrictionDocument::getSlugURI($slug, 'history')));
-
$print_uri = PhrictionDocument::getSlugURI($slug).'?__print__=1';
$curtain->addAction(
diff --git a/webroot/rsrc/css/phui/phui-document.css b/webroot/rsrc/css/phui/phui-document.css
--- a/webroot/rsrc/css/phui/phui-document.css
+++ b/webroot/rsrc/css/phui/phui-document.css
@@ -100,3 +100,9 @@
.remarkup-code {
font: 13px/18px "Menlo", "Consolas", "Monaco", monospace;
}
+
+.phui-document-version-navigation {
+ text-align: center;
+ padding: 8px;
+ background-color: {$lightgreybackground};
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 15, 6:01 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7441924
Default Alt Text
D19622.id46902.diff (8 KB)
Attached To
Mode
D19622: Add a UI element for navigating between versions of a Phriction document
Attached
Detach File
Event Timeline
Log In to Comment