Skip to content

Commit

Permalink
Add diff patch (#105)
Browse files Browse the repository at this point in the history
* removes diff from page moves
* fix diff bg color when hovering
* remove "close" button from diff page
* indicates page review when banner closed
  • Loading branch information
krisfield authored Mar 22, 2019
1 parent de5e9d9 commit f63d80b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
12 changes: 8 additions & 4 deletions includes/ReviewHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,14 @@ public function getTemplate() {

$diff = new DifferenceEngine( null, $lastSeenId, 0 );

$template =
"<div id='watch-analytics-review-handler'>
$unReviewLink $reviewLink
<p>$bannerText</p>";
$template = "<div id='watch-analytics-review-handler'> $unReviewLink";

// Don't show "close banner" button when viewing full diff page
if ( !( $this->isDiff ) ) {
$template .= $reviewLink;
}

$template .= "<p>$bannerText</p>";

global $egWatchAnalyticsShowUnreviewDiff;
if ( $egWatchAnalyticsShowUnreviewDiff ) {
Expand Down
4 changes: 4 additions & 0 deletions modules/pendingreviews/ext.watchanalytics.pendingreviews.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ tr.pendingreviews-row-hover td {
background-color: #f9f9f9;
}

div.pending-review-diff td {
background-color: #fff;
}

.pendingreviews-legend {
float:right;
margin-bottom: 10px;
Expand Down
7 changes: 7 additions & 0 deletions modules/reviewhandler/reviewhandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
rowLines.remove();
});

rowLines.css("background-color", "#00af89");
rowLines.html("<strong>Page reviewed!</strong>");

rowLines.fadeOut( 700, function() {
rowLines.remove();
});

});

});
Expand Down
47 changes: 24 additions & 23 deletions specials/SpecialPendingReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,32 +300,33 @@ public function getStandardChangeRow( PendingReview $item, $rowCount ) {
$changes = $this->getPendingReviewChangesList( $combinedList );
$acceptChangesButton = null;

if ( count( $item->newRevisions ) ) {
$previousViewedChange = Revision::newFromRow( $item->newRevisions[0] )->getPrevious();
if ( $previousViewedChange ) {
$prevId = $previousViewedChange->getId();
$context = new DerivativeContext( RequestContext::getMain() );
$context->setTitle( $item->title );
$diff = new DifferenceEngine( $context, $prevId, 0 );
$diff->showDiffStyle();
$theDiff = $diff->getDiff( '<b>Last seen</b>', '<b>Current</b>' );

$numChars = strlen( $theDiff );
$numRows = substr_count( $theDiff, '<tr' );

if ( $numRows < $egPendingReviewMaxDiffRows && $numChars < $egPendingReviewMaxDiffChar ) {
$changes .= "<div class='pending-review-diff'>";
$changes .= $theDiff;
$changes .= '</div>';
$acceptChangesButton = $this->getAcceptChangeButton( $item );
}

}
}

if ( $item->title->isRedirect() ) {
$reviewButton = $this->getAcceptRedirectButton( $item );
} else {

if ( count( $item->newRevisions ) ) {
$previousViewedChange = Revision::newFromRow( $item->newRevisions[0] )->getPrevious();
if ( $previousViewedChange ) {
$prevId = $previousViewedChange->getId();
$context = new DerivativeContext( RequestContext::getMain() );
$context->setTitle( $item->title );
$diff = new DifferenceEngine( $context, $prevId, 0 );
$diff->showDiffStyle();
$theDiff = $diff->getDiff( '<b>Last seen</b>', '<b>Current</b>' );

$numChars = strlen( $theDiff );
$numRows = substr_count( $theDiff, '<tr' );

if ( $numRows < $egPendingReviewMaxDiffRows && $numChars < $egPendingReviewMaxDiffChar ) {
$changes .= "<div class='pending-review-diff'>";
$changes .= $theDiff;
$changes .= '</div>';
$acceptChangesButton = $this->getAcceptChangeButton( $item );
}

}
}

$reviewButton = $this->getReviewButton( $item );
}

Expand Down

0 comments on commit f63d80b

Please sign in to comment.