Matthias Mullie has submitted this change and it was merged.
Change subject: New model for indentation
......................................................................
New model for indentation
Bug: T88501
Change-Id: I998ffb4f718cfb5ae092378bd032157846773d5d
---
M Flow.php
M includes/Formatter/AbstractQuery.php
M includes/Formatter/RevisionFormatter.php
M includes/Repository/MultiGetList.php
M includes/Repository/TreeRepository.php
M modules/engine/components/board/base/flow-board-interactive-events.js
M modules/styles/common.less
7 files changed, 75 insertions(+), 17 deletions(-)
Approvals:
Mattflaschen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/Flow.php b/Flow.php
index fdc1f25..e57f586 100644
--- a/Flow.php
+++ b/Flow.php
@@ -227,7 +227,7 @@
$wgFlowOccupyNamespaces = array();
// Max threading depth
-$wgFlowMaxThreadingDepth = 3;
+$wgFlowMaxThreadingDepth = 8;
// A list of editors to use, in priority order
$wgFlowEditorList = array( 'none' ); // EXPERIMENTAL prepend 'visualeditor'
diff --git a/includes/Formatter/AbstractQuery.php
b/includes/Formatter/AbstractQuery.php
index ee01887..155d7f2 100644
--- a/includes/Formatter/AbstractQuery.php
+++ b/includes/Formatter/AbstractQuery.php
@@ -57,6 +57,8 @@
*/
protected $currentRevisionsCache = array();
+ protected $identityMap = array();
+
/**
* @param ManagerGroup $storage
* @param TreeRepository $treeRepository
@@ -110,11 +112,17 @@
// map from post Id to the related root post id
$rootPostIds = array_filter( $this->treeRepository->findRoots(
$postIds ) );
-
$rootPostRequests = array();
foreach( $rootPostIds as $postId ) {
$rootPostRequests[] = array( 'rev_type_id' => $postId );
}
+
+ // these tree identity maps are required for determining where
a reply goes when
+ //
+ // replying to a specific post.
+ $identityMap = $this->treeRepository->fetchSubtreeIdentityMap(
+ array_unique( $rootPostIds, SORT_REGULAR )
+ );
$rootPostResult = $this->storage->findMulti(
'PostRevision',
@@ -175,6 +183,7 @@
$this->postCache = array_merge( $this->postCache, $rootPosts );
$this->rootPostIdCache = array_merge( $this->rootPostIdCache,
$rootPostIds );
$this->workflowCache = array_merge( $this->workflowCache,
$workflows );
+ $this->identityMap = array_merge( $this->identityMap,
$identityMap );
}
/**
@@ -213,9 +222,24 @@
if ( $revision instanceof PostRevision ) {
$row->rootPost = $this->getRootPost( $revision );
$revision->setRootPost( $row->rootPost );
+ $row->isLastReply = $this->isLastReply( $revision );
}
return $row;
+ }
+
+ protected function isLastReply( PostRevision $revision ) {
+ if ( $revision->isTopicTitle() ) {
+ return false;
+ }
+ $reply = $revision->getReplyToId()->getAlphadecimal();
+ if ( !isset( $this->identityMap[$reply] ) ) {
+ wfDebugLog( 'Flow', __METHOD__ . ": Missing $reply in
identity map" );
+ return false;
+ }
+ $parent =
$this->identityMap[$revision->getReplyToId()->getAlphadecimal()];
+ $keys = array_keys( $parent['children'] );
+ return end( $keys ) ===
$revision->getPostId()->getAlphadecimal();
}
/**
@@ -364,6 +388,8 @@
public $indexFieldValue;
/** @var PostRevision|null */
public $rootPost;
+ /** @var bool */
+ public $isLastReply = false;
// protect against typos
public function __get( $attribute ) {
@@ -375,3 +401,4 @@
throw new \MWException( "Accessing non-existent parameter:
$attribute" );
}
}
+
diff --git a/includes/Formatter/RevisionFormatter.php
b/includes/Formatter/RevisionFormatter.php
index e64d083..c3861c9 100644
--- a/includes/Formatter/RevisionFormatter.php
+++ b/includes/Formatter/RevisionFormatter.php
@@ -480,11 +480,20 @@
}
/*
- * If the post being replied to is at or
exceeds the max
- * threading depth, the reply link should point
to parent.
+ * If the post being replied to is the most
recent post
+ * of its depth, the reply link should point to
parent
*/
$replyToId = $postId;
$replyToRevision = $revision;
+ if ( $row->isLastReply ) {
+ $replyToId =
$replyToRevision->getReplyToId();
+ $replyToRevision =
PostCollection::newFromId( $replyToId )->getLastRevision();
+ }
+
+ /*
+ * If the post being replied to is at or
exceeds the max
+ * threading depth, the reply link should point
to parent.
+ */
while ( $replyToRevision->getDepth() >=
$this->maxThreadingDepth ) {
$replyToId =
$replyToRevision->getReplyToId();
$replyToRevision =
PostCollection::newFromId( $replyToId )->getLastRevision();
diff --git a/includes/Repository/MultiGetList.php
b/includes/Repository/MultiGetList.php
index 5267873..7cfca54 100644
--- a/includes/Repository/MultiGetList.php
+++ b/includes/Repository/MultiGetList.php
@@ -35,7 +35,8 @@
if ( $id instanceof UUID ) {
$cacheId = $id->getAlphadecimal();
} elseif ( !is_scalar( $id ) ) {
- throw new InvalidInputException( 'Not scalar:'
. gettype( $id ), 'invalid-input' );
+ $type = is_object( $id ) ? get_class( $id ) :
gettype( $id );
+ throw new InvalidInputException( 'Not scalar:'
. $type, 'invalid-input' );
} else {
$cacheId = $id;
}
diff --git a/includes/Repository/TreeRepository.php
b/includes/Repository/TreeRepository.php
index 3f0c918..77b8e60 100644
--- a/includes/Repository/TreeRepository.php
+++ b/includes/Repository/TreeRepository.php
@@ -316,10 +316,15 @@
}
/**
- * Fetch a node and all its descendants.
+ * Fetch a node and all its descendants. Children are returned in the
+ * same order they were inserted.
*
* @param UUID|UUID[] $roots
- * @return array Multi-dimensional tree
+ * @return array Multi-dimensional tree. The top level is a map from
the uuid of a node
+ * to attributes about that node. The top level contains not just the
parents, but all nodes
+ * within this tree. Within each node there is a 'children' key that
contains a map from
+ * the child uuid's to references back to the top level of this
identity map. As such this
+ * result can be read either as a list or a tree.
* @throws DataModelException When invalid data is received from
self::fetchSubtreeNodeList
*/
public function fetchSubtreeIdentityMap( $roots ) {
@@ -337,14 +342,18 @@
}
$identityMap = array();
foreach ( $parentMap as $child => $parent ) {
- if ( !isset( $identityMap[$child] ) ) {
+ if ( !array_key_exists( $child, $identityMap ) ) {
$identityMap[$child] = array( 'children' =>
array() );
}
// Root nodes have no parent
if ( $parent !== null ) {
- $identityMap[$parent]['children'][] =&
$identityMap[$child];
+
$identityMap[$parent->getAlphadecimal()]['children'][$child] =&
$identityMap[$child];
}
}
+ foreach ( array_keys( $identityMap ) as $parent ) {
+ ksort( $identityMap[$parent]['children'] );
+ }
+
return $identityMap;
}
diff --git
a/modules/engine/components/board/base/flow-board-interactive-events.js
b/modules/engine/components/board/base/flow-board-interactive-events.js
index 0e37599..f06d05f 100644
--- a/modules/engine/components/board/base/flow-board-interactive-events.js
+++ b/modules/engine/components/board/base/flow-board-interactive-events.js
@@ -176,16 +176,28 @@
event.preventDefault();
var $form,
- flowBoard = mw.flow.getPrototypeMethod( 'board',
'getInstanceByElement' )( $( this ) ),
- $topic = $( this ).closest( '.flow-topic' ),
- topicId = $topic.data( 'flow-id' ),
- $post = $( this ).closest( '.flow-post' ),
- $targetPost = $( this ).closest(
'.flow-post:not(.flow-post-max-depth)' ),
- postId = $targetPost.data( 'flow-id' ),
+ $this = $( this ),
+ topicId = $this.closest( '.flow-topic' ).data(
'flow-id' ),
+ flowBoard = mw.flow.getPrototypeMethod( 'board',
'getInstanceByElement' )( $this ),
+ $post = $this.closest( '.flow-post' ),
+ href = $this.attr( 'href' ),
+ uri = new mw.Uri( href ),
+ postId = uri.query.topic_postId,
+ $targetPost = $( '#flow-post-' + postId ),
topicTitle = $post.closest( '.flow-topic' ).find(
'.flow-topic-title' ).text(),
replyToContent = $post.find( '.flow-post-content'
).filter( ':first' ).text() || topicTitle,
author = $.trim( $post.find( '.flow-author' ).filter(
':first' ).find( '.mw-userlink' ).text() ),
$deferred = $.Deferred();
+
+ if ( $targetPost.length === 0 ) {
+ $targetPost = $( '#flow-topic-' + postId );
+ }
+
+ // forward all top level replys to the topic reply box
+ if ( $targetPost.is( '.flow-topic' ) ) {
+ $targetPost.find( '#flow-post-' + postId +
'-form-content' ).trigger( 'focus' );
+ return $deferred.resolve().promise();
+ }
// Check if reply form has already been opened
if ( $post.data( 'flow-replying' ) ) {
@@ -199,7 +211,7 @@
{
actions: {
reply: {
- url: $( this ).attr( 'href' ),
+ url: href,
text: mw.msg(
'flow-reply-link', author )
}
},
diff --git a/modules/styles/common.less b/modules/styles/common.less
index 84da706..b7022af 100644
--- a/modules/styles/common.less
+++ b/modules/styles/common.less
@@ -33,7 +33,7 @@
.flow-board {
font-size: .875em;
width: 100%;
- max-width: 700px;
+ max-width: 850px;
}
// Individual topic containers
--
To view, visit https://gerrit.wikimedia.org/r/190568
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I998ffb4f718cfb5ae092378bd032157846773d5d
Gerrit-PatchSet: 12
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits