updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
+97 -66
View File
@@ -3,75 +3,22 @@
*
* May only be loaded for authenticated users, with the History module enabled.
*/
(function ($, Drupal, window) {
/**
* Render "new" and "updated" node indicators, as well as "X new" replies links.
*/
Drupal.behaviors.trackerHistory = {
attach(context) {
// Find all "new" comment indicator placeholders newer than 30 days ago that
// have not already been read after their last comment timestamp.
const nodeIDs = [];
const $nodeNewPlaceholders = $(context)
.find('[data-history-node-timestamp]')
.once('history')
.filter(function () {
const nodeTimestamp = parseInt(this.getAttribute('data-history-node-timestamp'), 10);
const nodeID = this.getAttribute('data-history-node-id');
if (Drupal.history.needsServerCheck(nodeID, nodeTimestamp)) {
nodeIDs.push(nodeID);
return true;
}
return false;
});
// Find all "new" comment indicator placeholders newer than 30 days ago that
// have not already been read after their last comment timestamp.
const $newRepliesPlaceholders = $(context)
.find('[data-history-node-last-comment-timestamp]')
.once('history')
.filter(function () {
const lastCommentTimestamp = parseInt(this.getAttribute('data-history-node-last-comment-timestamp'), 10);
const nodeTimestamp = parseInt(this.previousSibling.previousSibling.getAttribute('data-history-node-timestamp'), 10);
// Discard placeholders that have zero comments.
if (lastCommentTimestamp === nodeTimestamp) {
return false;
}
const nodeID = this.previousSibling.previousSibling.getAttribute('data-history-node-id');
if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
if (nodeIDs.indexOf(nodeID) === -1) {
nodeIDs.push(nodeID);
}
return true;
}
return false;
});
if ($nodeNewPlaceholders.length === 0 && $newRepliesPlaceholders.length === 0) {
return;
}
// Fetch the node read timestamps from the server.
Drupal.history.fetchTimestamps(nodeIDs, () => {
processNodeNewIndicators($nodeNewPlaceholders);
processNewRepliesIndicators($newRepliesPlaceholders);
});
},
};
(function($, Drupal, window) {
function processNodeNewIndicators($placeholders) {
const newNodeString = Drupal.t('new');
const updatedNodeString = Drupal.t('updated');
$placeholders.each((index, placeholder) => {
const timestamp = parseInt(placeholder.getAttribute('data-history-node-timestamp'), 10);
const timestamp = parseInt(
placeholder.getAttribute('data-history-node-timestamp'),
10,
);
const nodeID = placeholder.getAttribute('data-history-node-id');
const lastViewTimestamp = Drupal.history.getLastRead(nodeID);
if (timestamp > lastViewTimestamp) {
const message = (lastViewTimestamp === 0) ? newNodeString : updatedNodeString;
const message =
lastViewTimestamp === 0 ? newNodeString : updatedNodeString;
$(placeholder).append(`<span class="marker">${message}</span>`);
}
});
@@ -81,8 +28,13 @@
// Figure out which placeholders need the "x new" replies links.
const placeholdersToUpdate = {};
$placeholders.each((index, placeholder) => {
const timestamp = parseInt(placeholder.getAttribute('data-history-node-last-comment-timestamp'), 10);
const nodeID = placeholder.previousSibling.previousSibling.getAttribute('data-history-node-id');
const timestamp = parseInt(
placeholder.getAttribute('data-history-node-last-comment-timestamp'),
10,
);
const nodeID = placeholder.previousSibling.previousSibling.getAttribute(
'data-history-node-id',
);
const lastViewTimestamp = Drupal.history.getLastRead(nodeID);
// Queue this placeholder's "X new" replies link to be downloaded from the
@@ -103,14 +55,93 @@
data: { 'node_ids[]': nodeIDs },
dataType: 'json',
success(results) {
Object.keys(results || {}).forEach((nodeID) => {
Object.keys(results || {}).forEach(nodeID => {
if (placeholdersToUpdate.hasOwnProperty(nodeID)) {
const url = results[nodeID].first_new_comment_link;
const text = Drupal.formatPlural(results[nodeID].new_comment_count, '1 new', '@count new');
$(placeholdersToUpdate[nodeID]).append(`<br /><a href="${url}">${text}</a>`);
const text = Drupal.formatPlural(
results[nodeID].new_comment_count,
'1 new',
'@count new',
);
$(placeholdersToUpdate[nodeID]).append(
`<br /><a href="${url}">${text}</a>`,
);
}
});
},
});
}
}(jQuery, Drupal, window));
/**
* Render "new" and "updated" node indicators, as well as "X new" replies links.
*/
Drupal.behaviors.trackerHistory = {
attach(context) {
// Find all "new" comment indicator placeholders newer than 30 days ago that
// have not already been read after their last comment timestamp.
const nodeIDs = [];
const $nodeNewPlaceholders = $(context)
.find('[data-history-node-timestamp]')
.once('history')
.filter(function() {
const nodeTimestamp = parseInt(
this.getAttribute('data-history-node-timestamp'),
10,
);
const nodeID = this.getAttribute('data-history-node-id');
if (Drupal.history.needsServerCheck(nodeID, nodeTimestamp)) {
nodeIDs.push(nodeID);
return true;
}
return false;
});
// Find all "new" comment indicator placeholders newer than 30 days ago that
// have not already been read after their last comment timestamp.
const $newRepliesPlaceholders = $(context)
.find('[data-history-node-last-comment-timestamp]')
.once('history')
.filter(function() {
const lastCommentTimestamp = parseInt(
this.getAttribute('data-history-node-last-comment-timestamp'),
10,
);
const nodeTimestamp = parseInt(
this.previousSibling.previousSibling.getAttribute(
'data-history-node-timestamp',
),
10,
);
// Discard placeholders that have zero comments.
if (lastCommentTimestamp === nodeTimestamp) {
return false;
}
const nodeID = this.previousSibling.previousSibling.getAttribute(
'data-history-node-id',
);
if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
if (nodeIDs.indexOf(nodeID) === -1) {
nodeIDs.push(nodeID);
}
return true;
}
return false;
});
if (
$nodeNewPlaceholders.length === 0 &&
$newRepliesPlaceholders.length === 0
) {
return;
}
// Fetch the node read timestamps from the server.
Drupal.history.fetchTimestamps(nodeIDs, () => {
processNodeNewIndicators($nodeNewPlaceholders);
processNewRepliesIndicators($newRepliesPlaceholders);
});
},
};
})(jQuery, Drupal, window);
+43 -43
View File
@@ -6,49 +6,6 @@
**/
(function ($, Drupal, window) {
Drupal.behaviors.trackerHistory = {
attach: function attach(context) {
var nodeIDs = [];
var $nodeNewPlaceholders = $(context).find('[data-history-node-timestamp]').once('history').filter(function () {
var nodeTimestamp = parseInt(this.getAttribute('data-history-node-timestamp'), 10);
var nodeID = this.getAttribute('data-history-node-id');
if (Drupal.history.needsServerCheck(nodeID, nodeTimestamp)) {
nodeIDs.push(nodeID);
return true;
}
return false;
});
var $newRepliesPlaceholders = $(context).find('[data-history-node-last-comment-timestamp]').once('history').filter(function () {
var lastCommentTimestamp = parseInt(this.getAttribute('data-history-node-last-comment-timestamp'), 10);
var nodeTimestamp = parseInt(this.previousSibling.previousSibling.getAttribute('data-history-node-timestamp'), 10);
if (lastCommentTimestamp === nodeTimestamp) {
return false;
}
var nodeID = this.previousSibling.previousSibling.getAttribute('data-history-node-id');
if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
if (nodeIDs.indexOf(nodeID) === -1) {
nodeIDs.push(nodeID);
}
return true;
}
return false;
});
if ($nodeNewPlaceholders.length === 0 && $newRepliesPlaceholders.length === 0) {
return;
}
Drupal.history.fetchTimestamps(nodeIDs, function () {
processNodeNewIndicators($nodeNewPlaceholders);
processNewRepliesIndicators($newRepliesPlaceholders);
});
}
};
function processNodeNewIndicators($placeholders) {
var newNodeString = Drupal.t('new');
var updatedNodeString = Drupal.t('updated');
@@ -97,4 +54,47 @@
}
});
}
Drupal.behaviors.trackerHistory = {
attach: function attach(context) {
var nodeIDs = [];
var $nodeNewPlaceholders = $(context).find('[data-history-node-timestamp]').once('history').filter(function () {
var nodeTimestamp = parseInt(this.getAttribute('data-history-node-timestamp'), 10);
var nodeID = this.getAttribute('data-history-node-id');
if (Drupal.history.needsServerCheck(nodeID, nodeTimestamp)) {
nodeIDs.push(nodeID);
return true;
}
return false;
});
var $newRepliesPlaceholders = $(context).find('[data-history-node-last-comment-timestamp]').once('history').filter(function () {
var lastCommentTimestamp = parseInt(this.getAttribute('data-history-node-last-comment-timestamp'), 10);
var nodeTimestamp = parseInt(this.previousSibling.previousSibling.getAttribute('data-history-node-timestamp'), 10);
if (lastCommentTimestamp === nodeTimestamp) {
return false;
}
var nodeID = this.previousSibling.previousSibling.getAttribute('data-history-node-id');
if (Drupal.history.needsServerCheck(nodeID, lastCommentTimestamp)) {
if (nodeIDs.indexOf(nodeID) === -1) {
nodeIDs.push(nodeID);
}
return true;
}
return false;
});
if ($nodeNewPlaceholders.length === 0 && $newRepliesPlaceholders.length === 0) {
return;
}
Drupal.history.fetchTimestamps(nodeIDs, function () {
processNodeNewIndicators($nodeNewPlaceholders);
processNewRepliesIndicators($newRepliesPlaceholders);
});
}
};
})(jQuery, Drupal, window);
@@ -32,7 +32,6 @@ class UserTrackerTab extends LocalTaskDefault {
return $this->currentUser;
}
/**
* {@inheritdoc}
*/
@@ -5,5 +5,5 @@ package: Testing
version: VERSION
core: 8.x
dependencies:
- tracker
- views
- drupal:tracker
- drupal:views
@@ -93,6 +93,7 @@ class TrackerTest extends BrowserTestBase {
$expected_tags = Cache::mergeTags($expected_tags, $role_tags);
$block_tags = [
'block_view',
'local_task',
'config:block.block.page_actions_block',
'config:block.block.page_tabs_block',
'config:block_list',
@@ -179,6 +180,7 @@ class TrackerTest extends BrowserTestBase {
$expected_tags = Cache::mergeTags($expected_tags, $role_tags);
$block_tags = [
'block_view',
'local_task',
'config:block.block.page_actions_block',
'config:block.block.page_tabs_block',
'config:block_list',
@@ -361,8 +363,14 @@ class TrackerTest extends BrowserTestBase {
];
$this->drupalPostForm('comment/reply/node/' . $nodes[3]->id() . '/comment', $comment, t('Save'));
// Start indexing backwards from node 3.
\Drupal::state()->set('tracker.index_nid', 3);
// Create an unpublished node.
$unpublished = $this->drupalCreateNode([
'title' => $this->randomMachineName(8),
'status' => 0,
]);
// Start indexing backwards from node 4.
\Drupal::state()->set('tracker.index_nid', 4);
// Clear the current tracker tables and rebuild them.
db_delete('tracker_node')
@@ -31,7 +31,7 @@ class TrackerUserUidTest extends TrackerTestBase {
[
'nid' => $this->node->id(),
'title' => $this->node->label(),
]
],
];
$view = Views::getView('test_tracker_user_uid');
@@ -30,7 +30,7 @@ class TrackerNodeTest extends MigrateSqlSourceTestBase {
'nid' => '2',
'published' => '1',
'changed' => '1421727536',
]
],
];
// The expected results are identical to the source data.
@@ -31,7 +31,7 @@ class TrackerUserTest extends MigrateSqlSourceTestBase {
'uid' => '2',
'published' => '1',
'changed' => '1421727536',
]
],
];
// The expected results are identical to the source data.
+2 -2
View File
@@ -2,8 +2,8 @@ name: Activity Tracker
type: module
description: 'Enables tracking of recent content for users.'
dependencies:
- node
- comment
- drupal:node
- drupal:comment
package: Core
version: VERSION
core: 8.x
+2 -2
View File
@@ -72,7 +72,7 @@ function tracker_cron() {
db_insert('tracker_node')
->fields([
'nid' => $nid,
'published' => $node->isPublished(),
'published' => (int) $node->isPublished(),
'changed' => $changed,
])
->execute();
@@ -81,7 +81,7 @@ function tracker_cron() {
db_insert('tracker_user')
->fields([
'nid' => $nid,
'published' => $node->isPublished(),
'published' => (int) $node->isPublished(),
'changed' => $changed,
'uid' => $node->getOwnerId(),
])
-1
View File
@@ -25,4 +25,3 @@ tracker.user_tab:
_permission: 'access content'
_entity_access: 'user.view'
user: \d+
+1 -1
View File
@@ -173,7 +173,7 @@ function tracker_views_data_alter(&$data) {
'field' => 'uid',
'name table' => 'users_field_data',
'name field' => 'name',
'id' => 'tracker_user_uid'
'id' => 'tracker_user_uid',
],
];
}