diff --git a/src/applications/phriction/controller/PhrictionHistoryController.php b/src/applications/phriction/controller/PhrictionHistoryController.php --- a/src/applications/phriction/controller/PhrictionHistoryController.php +++ b/src/applications/phriction/controller/PhrictionHistoryController.php @@ -31,32 +31,18 @@ ->executeWithCursorPager($pager); $author_phids = mpull($history, 'getAuthorPHID'); - $handles = $this->loadViewerHandles($author_phids); + $handles = $viewer->loadHandles($author_phids); + + $max_version = (int)$document->getMaxVersion(); + $current_version = $document->getContent()->getVersion(); $list = new PHUIObjectItemListView(); $list->setFlush(true); - foreach ($history as $content) { - - $author = $handles[$content->getAuthorPHID()]->renderLink(); $slug_uri = PhrictionDocument::getSlugURI($document->getSlug()); $version = $content->getVersion(); - $diff_uri = new PhutilURI('/phriction/diff/'.$document->getID().'/'); - - $vs_previous = null; - if ($content->getVersion() != 1) { - $vs_previous = $diff_uri - ->alter('l', $content->getVersion() - 1) - ->alter('r', $content->getVersion()); - } - - $vs_head = null; - if ($content->getPHID() != $document->getContentPHID()) { - $vs_head = $diff_uri - ->alter('l', $content->getVersion()) - ->alter('r', $current->getVersion()); - } + $base_uri = new PhutilURI('/phriction/diff/'.$document->getID().'/'); $change_type = PhrictionChangeType::getChangeTypeLabel( $content->getChangeType()); @@ -68,63 +54,90 @@ $color = 'lightbluetext'; break; case PhrictionChangeType::CHANGE_MOVE_HERE: - $color = 'yellow'; + $color = 'yellow'; break; case PhrictionChangeType::CHANGE_MOVE_AWAY: - $color = 'orange'; + $color = 'orange'; break; case PhrictionChangeType::CHANGE_STUB: $color = 'green'; break; default: - throw new Exception(pht('Unknown change type!')); + $color = 'indigo'; break; } + $version_uri = $slug_uri.'?v='.$version; + $item = id(new PHUIObjectItemView()) - ->setHeader(pht('%s by %s', $change_type, $author)) - ->setStatusIcon('fa-file '.$color) - ->addAttribute( - phutil_tag( - 'a', - array( - 'href' => $slug_uri.'?v='.$version, - ), - pht('Version %s', $version))) - ->addAttribute(pht('%s %s', - phabricator_date($content->getDateCreated(), $viewer), - phabricator_time($content->getDateCreated(), $viewer))); - - if ($content->getDescription()) { - $item->addAttribute($content->getDescription()); + ->setHref($version_uri); + + if ($version > $current_version) { + $icon = 'fa-spinner'; + $color = 'pink'; + $header = pht('Draft %d', $version); + } else { + $icon = 'fa-file-o'; + $header = pht('Version %d', $version); + } + + if ($version == $current_version) { + $item->setEffect('selected'); } - if ($vs_previous) { - $item->addIcon( - 'fa-reply', - pht('Show Change'), - array( - 'href' => $vs_previous, - )); + $item + ->setHeader($header) + ->setStatusIcon($icon.' '.$color); + + $description = $content->getDescription(); + if (strlen($description)) { + $item->addAttribute($description); + } + + $item->addIcon( + null, + phabricator_datetime($content->getDateCreated(), $viewer)); + + $author_phid = $content->getAuthorPHID(); + $item->addByline($viewer->renderHandle($author_phid)); + + $diff_uri = null; + if ($version > 1) { + $diff_uri = $base_uri + ->alter('l', $version - 1) + ->alter('r', $version); } else { - $item->addIcon( - 'fa-reply grey', - phutil_tag('em', array(), pht('No previous change'))); + $diff_uri = null; } - if ($vs_head) { - $item->addIcon( - 'fa-reply-all', - pht('Show Later Changes'), - array( - 'href' => $vs_head, - )); + if ($content->getVersion() != $max_version) { + $compare_uri = $base_uri + ->alter('l', $version) + ->alter('r', $max_version); } else { - $item->addIcon( - 'fa-reply-all grey', - phutil_tag('em', array(), pht('No later changes'))); + $compare_uri = null; } + $button_bar = id(new PHUIButtonBarView()) + ->addButton( + id(new PHUIButtonView()) + ->setTag('a') + ->setColor('grey') + ->setIcon('fa-chevron-down') + ->setDisabled(!$diff_uri) + ->setHref($diff_uri) + ->setText(pht('Diff'))) + ->addButton( + id(new PHUIButtonView()) + ->setTag('a') + ->setColor('grey') + ->setIcon('fa-chevron-circle-up') + ->setDisabled(!$compare_uri) + ->setHref($compare_uri) + ->setText(pht('Compare'))); + + $item->setSideColumn($button_bar); + $list->addItem($item); } diff --git a/src/view/phui/PHUIObjectItemView.php b/src/view/phui/PHUIObjectItemView.php --- a/src/view/phui/PHUIObjectItemView.php +++ b/src/view/phui/PHUIObjectItemView.php @@ -709,8 +709,9 @@ } /* Fixed width, right column container. */ + $column3 = null; if ($this->sideColumn) { - $column2 = phutil_tag( + $column3 = phutil_tag( 'div', array( 'class' => 'phui-oi-col2 phui-oi-side-column', @@ -731,6 +732,7 @@ $column0, $column1, $column2, + $column3, ))); $box = phutil_tag(