jenkins-bot has submitted this change and it was merged.
Change subject: Don't include edit-topic-summary in Topic's supported POST
actions
......................................................................
Don't include edit-topic-summary in Topic's supported POST actions
It means Topic will recognize it as an action it can render, but
it can't (not part of $templates) and throws an exception (when run
from View.php - for no-JS)
Topic had to be able to render it, because we wanted the topic
API output to re-render the topic in JS.
However:
* that shouldn't come at the expense of breaking no-JS
* there were some hacks in place already to make this work
I've just made 'summary' just another formatterRow (instead of
the content/format array). This allows us to re-use the partial
with the API output of just the summary (instead of needing all
of the topic's output)
Added bonus: editing a summary no longer wipes out any replies-in-
progress, because we no longer reload the entire topic.
Bug: T95362
Change-Id: I2a0c962903b234c16d3abdc08a35a7f4c67dfd51
---
M handlebars/compiled/flow_block_topic.handlebars.php
M handlebars/compiled/flow_block_topiclist.handlebars.php
M handlebars/compiled/flow_block_topicsummary_edit.handlebars.php
M handlebars/flow_block_topicsummary_edit.handlebars
M handlebars/flow_topic_titlebar_content.partial.handlebars
M handlebars/flow_topic_titlebar_summary.partial.handlebars
M includes/Block/Topic.php
M includes/Formatter/PostSummaryQuery.php
M includes/Formatter/RevisionFormatter.php
M includes/Formatter/SinglePostQuery.php
M includes/Formatter/TopicListQuery.php
M includes/Formatter/TopicRow.php
M modules/engine/components/board/base/flow-board-api-events.js
M tests/qunit/engine/components/board/test_flow-board.js
14 files changed, 28 insertions(+), 29 deletions(-)
Approvals:
EBernhardson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/handlebars/compiled/flow_block_topic.handlebars.php
b/handlebars/compiled/flow_block_topic.handlebars.php
index 1b4b4d5..1362a66 100644
--- a/handlebars/compiled/flow_block_topic.handlebars.php
+++ b/handlebars/compiled/flow_block_topic.handlebars.php
@@ -39,8 +39,8 @@
';},'flow_topic_moderation_flag' => function ($cx, $in) {return '<span
class="wikiglyph'.LCRun3::hbch($cx, 'ifCond',
array(array(((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'===','lock'),array()), $in, false, function($cx,
$in) {return ' wikiglyph-lock';}).''.LCRun3::hbch($cx, 'ifCond',
array(array(((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'===','hide'),array()), $in, false, function($cx,
$in) {return ' wikiglyph-flag';}).''.LCRun3::hbch($cx, 'ifCond',
array(array(((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'===','delete'),array()), $in, false,
function($cx, $in) {return ' wikiglyph-trash';}).'"></span>
';},'flow_post_moderation_state' => function ($cx, $in) {return '<span
class="plainlinks">'.((LCRun3::ifvar($cx, ((isset($in['replyToId']) &&
is_array($in)) ? $in['replyToId'] : null))) ? ''.LCRun3::ch($cx, 'l10nParse',
array(array(LCRun3::ch($cx, 'concat',
array(array('flow-',((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'-post-content'),array()),
'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ?
$in['moderator']['name'] : null),((isset($in['links']['topic-history']['url'])
&& is_array($in['links']['topic-history'])) ?
$in['links']['topic-history']['url'] : null)),array()), 'encq').'' :
''.LCRun3::ch($cx, 'l10nParse', array(array(LCRun3::ch($cx, 'concat',
array(array('flow-',((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'-title-content'),array()),
'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ?
$in['moderator']['name'] : null),((isset($in['links']['topic-history']['url'])
&& is_array($in['links']['topic-history'])) ?
$in['links']['topic-history']['url'] : null)),array()), 'encq').'').'</span>
';},'flow_topic_titlebar_summary' => function ($cx, $in) {return '<div
class="flow-topic-summary-container">
-'.LCRun3::p($cx, 'flow_errors',
array(array($in),array())).''.((LCRun3::ifvar($cx, ((isset($in['summary']) &&
is_array($in)) ? $in['summary'] : null))) ? ' <div
class="flow-topic-summary">
- '.LCRun3::ch($cx, 'escapeContent',
array(array(((isset($in['summary']['format']) && is_array($in['summary'])) ?
$in['summary']['format'] : null),((isset($in['summary']['content']) &&
is_array($in['summary'])) ? $in['summary']['content'] : null)),array()),
'encq').'
+'.LCRun3::p($cx, 'flow_errors',
array(array($in),array())).''.((LCRun3::ifvar($cx,
((isset($in['revision']['content']) && is_array($in['revision'])) ?
$in['revision']['content'] : null))) ? ' <div
class="flow-topic-summary">
+ '.LCRun3::ch($cx, 'escapeContent',
array(array(((isset($in['revision']['content']['format']) &&
is_array($in['revision']['content'])) ? $in['revision']['content']['format'] :
null),((isset($in['revision']['content']['content']) &&
is_array($in['revision']['content'])) ? $in['revision']['content']['content'] :
null)),array()), 'encq').'
</div>
<br class="flow-ui-clear"/>
' : '').'</div>
@@ -63,7 +63,7 @@
</div>
' : '').'<span class="flow-reply-count"><span class="wikiglyph
wikiglyph-speech-bubble"></span><span
class="flow-reply-count-number">'.htmlentities((string)((isset($in['reply_count'])
&& is_array($in)) ? $in['reply_count'] : null), ENT_QUOTES,
'UTF-8').'</span></span>
-'.LCRun3::p($cx, 'flow_topic_titlebar_summary',
array(array($in),array())).'';},'flow_topic_titlebar_watch' => function ($cx,
$in) {return '<div class="flow-topic-watchlist flow-watch-link">
+'.LCRun3::p($cx, 'flow_topic_titlebar_summary',
array(array(((isset($in['summary']) && is_array($in)) ? $in['summary'] :
null)),array())).'';},'flow_topic_titlebar_watch' => function ($cx, $in)
{return '<div class="flow-topic-watchlist flow-watch-link">
'.LCRun3::p($cx, 'flow_errors', array(array($in),array())).'
<a href="'.((LCRun3::ifvar($cx, ((isset($in['isWatched']) &&
is_array($in)) ? $in['isWatched'] : null))) ?
''.htmlentities((string)((isset($in['links']['unwatch-topic']['url']) &&
is_array($in['links']['unwatch-topic'])) ? $in['links']['unwatch-topic']['url']
: null), ENT_QUOTES, 'UTF-8').'' :
''.htmlentities((string)((isset($in['links']['watch-topic']['url']) &&
is_array($in['links']['watch-topic'])) ? $in['links']['watch-topic']['url'] :
null), ENT_QUOTES, 'UTF-8').'').'"
class="mw-ui-anchor mw-ui-constructive '.((!LCRun3::ifvar($cx,
((isset($in['isWatched']) && is_array($in)) ? $in['isWatched'] : null))) ?
'mw-ui-quiet' : '').'
diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index 2978e4b..7b36003 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -142,8 +142,8 @@
' : '').'';},'flow_topic_moderation_flag' => function ($cx, $in) {return
'<span class="wikiglyph'.LCRun3::hbch($cx, 'ifCond',
array(array(((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'===','lock'),array()), $in, false, function($cx,
$in) {return ' wikiglyph-lock';}).''.LCRun3::hbch($cx, 'ifCond',
array(array(((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'===','hide'),array()), $in, false, function($cx,
$in) {return ' wikiglyph-flag';}).''.LCRun3::hbch($cx, 'ifCond',
array(array(((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'===','delete'),array()), $in, false,
function($cx, $in) {return ' wikiglyph-trash';}).'"></span>
';},'flow_post_moderation_state' => function ($cx, $in) {return '<span
class="plainlinks">'.((LCRun3::ifvar($cx, ((isset($in['replyToId']) &&
is_array($in)) ? $in['replyToId'] : null))) ? ''.LCRun3::ch($cx, 'l10nParse',
array(array(LCRun3::ch($cx, 'concat',
array(array('flow-',((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'-post-content'),array()),
'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ?
$in['moderator']['name'] : null),((isset($in['links']['topic-history']['url'])
&& is_array($in['links']['topic-history'])) ?
$in['links']['topic-history']['url'] : null)),array()), 'encq').'' :
''.LCRun3::ch($cx, 'l10nParse', array(array(LCRun3::ch($cx, 'concat',
array(array('flow-',((isset($in['moderateState']) && is_array($in)) ?
$in['moderateState'] : null),'-title-content'),array()),
'raw'),((isset($in['moderator']['name']) && is_array($in['moderator'])) ?
$in['moderator']['name'] : null),((isset($in['links']['topic-history']['url'])
&& is_array($in['links']['topic-history'])) ?
$in['links']['topic-history']['url'] : null)),array()), 'encq').'').'</span>
';},'flow_topic_titlebar_summary' => function ($cx, $in) {return '<div
class="flow-topic-summary-container">
-'.LCRun3::p($cx, 'flow_errors',
array(array($in),array())).''.((LCRun3::ifvar($cx, ((isset($in['summary']) &&
is_array($in)) ? $in['summary'] : null))) ? ' <div
class="flow-topic-summary">
- '.LCRun3::ch($cx, 'escapeContent',
array(array(((isset($in['summary']['format']) && is_array($in['summary'])) ?
$in['summary']['format'] : null),((isset($in['summary']['content']) &&
is_array($in['summary'])) ? $in['summary']['content'] : null)),array()),
'encq').'
+'.LCRun3::p($cx, 'flow_errors',
array(array($in),array())).''.((LCRun3::ifvar($cx,
((isset($in['revision']['content']) && is_array($in['revision'])) ?
$in['revision']['content'] : null))) ? ' <div
class="flow-topic-summary">
+ '.LCRun3::ch($cx, 'escapeContent',
array(array(((isset($in['revision']['content']['format']) &&
is_array($in['revision']['content'])) ? $in['revision']['content']['format'] :
null),((isset($in['revision']['content']['content']) &&
is_array($in['revision']['content'])) ? $in['revision']['content']['content'] :
null)),array()), 'encq').'
</div>
<br class="flow-ui-clear"/>
' : '').'</div>
@@ -166,7 +166,7 @@
</div>
' : '').'<span class="flow-reply-count"><span class="wikiglyph
wikiglyph-speech-bubble"></span><span
class="flow-reply-count-number">'.htmlentities((string)((isset($in['reply_count'])
&& is_array($in)) ? $in['reply_count'] : null), ENT_QUOTES,
'UTF-8').'</span></span>
-'.LCRun3::p($cx, 'flow_topic_titlebar_summary',
array(array($in),array())).'';},'flow_topic_titlebar_watch' => function ($cx,
$in) {return '<div class="flow-topic-watchlist flow-watch-link">
+'.LCRun3::p($cx, 'flow_topic_titlebar_summary',
array(array(((isset($in['summary']) && is_array($in)) ? $in['summary'] :
null)),array())).'';},'flow_topic_titlebar_watch' => function ($cx, $in)
{return '<div class="flow-topic-watchlist flow-watch-link">
'.LCRun3::p($cx, 'flow_errors', array(array($in),array())).'
<a href="'.((LCRun3::ifvar($cx, ((isset($in['isWatched']) &&
is_array($in)) ? $in['isWatched'] : null))) ?
''.htmlentities((string)((isset($in['links']['unwatch-topic']['url']) &&
is_array($in['links']['unwatch-topic'])) ? $in['links']['unwatch-topic']['url']
: null), ENT_QUOTES, 'UTF-8').'' :
''.htmlentities((string)((isset($in['links']['watch-topic']['url']) &&
is_array($in['links']['watch-topic'])) ? $in['links']['watch-topic']['url'] :
null), ENT_QUOTES, 'UTF-8').'').'"
class="mw-ui-anchor mw-ui-constructive '.((!LCRun3::ifvar($cx,
((isset($in['isWatched']) && is_array($in)) ? $in['isWatched'] : null))) ?
'mw-ui-quiet' : '').'
diff --git a/handlebars/compiled/flow_block_topicsummary_edit.handlebars.php
b/handlebars/compiled/flow_block_topicsummary_edit.handlebars.php
index d2f1bb3..420e6bc 100644
--- a/handlebars/compiled/flow_block_topicsummary_edit.handlebars.php
+++ b/handlebars/compiled/flow_block_topicsummary_edit.handlebars.php
@@ -48,7 +48,6 @@
<textarea class="mw-ui-input"
required
name="'.htmlentities((string)((isset($in['type']) && is_array($in)) ?
$in['type'] : null), ENT_QUOTES, 'UTF-8').'_summary"
- data-flow-preview-node="summary"
data-flow-preview-template="flow_topic_titlebar_summary.partial"
data-flow-preview-title="'.htmlentities((string)((isset($in['revision']['articleTitle'])
&& is_array($in['revision'])) ? $in['revision']['articleTitle'] : null),
ENT_QUOTES, 'UTF-8').'"
type="text"
diff --git a/handlebars/flow_block_topicsummary_edit.handlebars
b/handlebars/flow_block_topicsummary_edit.handlebars
index 13a813f..56cf6e4 100644
--- a/handlebars/flow_block_topicsummary_edit.handlebars
+++ b/handlebars/flow_block_topicsummary_edit.handlebars
@@ -12,7 +12,6 @@
<textarea class="mw-ui-input"
required
name="{{type}}_summary"
- data-flow-preview-node="summary"
data-flow-preview-template="flow_topic_titlebar_summary.partial"
data-flow-preview-title="{{revision.articleTitle}}"
type="text"
diff --git a/handlebars/flow_topic_titlebar_content.partial.handlebars
b/handlebars/flow_topic_titlebar_content.partial.handlebars
index bf515b4..565b71f 100644
--- a/handlebars/flow_topic_titlebar_content.partial.handlebars
+++ b/handlebars/flow_topic_titlebar_content.partial.handlebars
@@ -24,4 +24,4 @@
{{/if}}
<span class="flow-reply-count"><span class="wikiglyph
wikiglyph-speech-bubble"></span><span
class="flow-reply-count-number">{{reply_count}}</span></span>
-{{> flow_topic_titlebar_summary}}
+{{> flow_topic_titlebar_summary summary}}
diff --git a/handlebars/flow_topic_titlebar_summary.partial.handlebars
b/handlebars/flow_topic_titlebar_summary.partial.handlebars
index 48df93a..7d60a60 100644
--- a/handlebars/flow_topic_titlebar_summary.partial.handlebars
+++ b/handlebars/flow_topic_titlebar_summary.partial.handlebars
@@ -1,8 +1,8 @@
<div class="flow-topic-summary-container">
{{> flow_errors }}
- {{#if summary}}
+ {{#if revision.content}}
<div class="flow-topic-summary">
- {{escapeContent summary.format summary.content}}
+ {{escapeContent revision.content.format
revision.content.content}}
</div>
<br class="flow-ui-clear"/>
{{/if}}
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 5f60708..eb7a918 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -65,9 +65,6 @@
// Other stuff
'edit-title',
'undo-edit-post',
- // psuedo-action, we don't do anything but we return
- // information about the topic in the api response
- 'edit-topic-summary',
);
protected $supportedGetActions = array(
diff --git a/includes/Formatter/PostSummaryQuery.php
b/includes/Formatter/PostSummaryQuery.php
index c397a01..47ca869 100644
--- a/includes/Formatter/PostSummaryQuery.php
+++ b/includes/Formatter/PostSummaryQuery.php
@@ -20,6 +20,6 @@
}
$this->loadMetadataBatch( $found );
- return $this->buildResult( reset( $found ), null );
+ return $this->buildResult( reset( $found ), 'rev_id' );
}
}
diff --git a/includes/Formatter/RevisionFormatter.php
b/includes/Formatter/RevisionFormatter.php
index 7ab94fd..5f7e7d9 100644
--- a/includes/Formatter/RevisionFormatter.php
+++ b/includes/Formatter/RevisionFormatter.php
@@ -258,11 +258,11 @@
);
if (
$row->summary &&
- $this->permissions->isAllowed( $row->summary,
'view' )
+ $this->permissions->isAllowed(
$row->summary->revision, 'view' )
) {
- $res['summary']['content'] =
$this->templating->getContent( $row->summary, $this->contentFormat );
- $res['summary']['format'] =
$this->contentFormat;
- $res['summary']['revId'] =
$row->summary->getRevisionId()->getAlphadecimal();
+ $res['summary'] = array(
+ 'revision' => $this->formatApi(
$row->summary, $ctx )
+ );
}
// Only non-anon users can watch/unwatch a flow topic
diff --git a/includes/Formatter/SinglePostQuery.php
b/includes/Formatter/SinglePostQuery.php
index ae86094..961a7af 100644
--- a/includes/Formatter/SinglePostQuery.php
+++ b/includes/Formatter/SinglePostQuery.php
@@ -33,7 +33,7 @@
);
if ( $summary ) {
$formatterRow = new TopicRow();
- $formatterRow->summary = reset( $summary );
+ $formatterRow->summary = $this->buildResult(
reset( $summary ), 'rev_id' );
}
}
diff --git a/includes/Formatter/TopicListQuery.php
b/includes/Formatter/TopicListQuery.php
index e68ff07..7961e04 100644
--- a/includes/Formatter/TopicListQuery.php
+++ b/includes/Formatter/TopicListQuery.php
@@ -74,7 +74,7 @@
if ( $post->isTopicTitle() ) {
// Attach the summary
if ( isset( $topicSummary[$postId] ) ) {
- $row->summary =
$topicSummary[$postId];
+ $row->summary =
$this->buildResult( $topicSummary[$postId], 'rev_id' );
}
// Attach the watch status
if ( isset( $watchStatus[$postId] ) &&
$watchStatus[$postId] ) {
diff --git a/includes/Formatter/TopicRow.php b/includes/Formatter/TopicRow.php
index 122ee62..80a38fc 100644
--- a/includes/Formatter/TopicRow.php
+++ b/includes/Formatter/TopicRow.php
@@ -3,7 +3,6 @@
namespace Flow\Formatter;
use Flow\Model\PostRevision;
-use Flow\Model\PostSummary;
class TopicRow extends FormatterRow {
/**
@@ -12,7 +11,7 @@
public $replies;
/**
- * @var PostSummary
+ * @var FormatterRow
*/
public $summary;
diff --git a/modules/engine/components/board/base/flow-board-api-events.js
b/modules/engine/components/board/base/flow-board-api-events.js
index 015cc5c..8d35f01 100644
--- a/modules/engine/components/board/base/flow-board-api-events.js
+++ b/modules/engine/components/board/base/flow-board-api-events.js
@@ -689,11 +689,16 @@
return $.Deferred().reject().promise();
}
- _flowBoardComponentRefreshTopic(
- info.$target,
- data.flow['edit-topic-summary'].result.topic,
- '.flow-topic-titlebar'
- );
+ var $this = $( this ),
+ flowBoard = mw.flow.getPrototypeMethod( 'board',
'getInstanceByElement' )( $this ),
+ $oldSummary = info.$target,
+ $newSummary = $(
flowBoard.constructor.static.TemplateEngine.processTemplateGetFragment(
+ 'flow_topic_titlebar_summary.partial',
+
data.flow['edit-topic-summary'].result.topicsummary
+ ) ).children();
+
+ $oldSummary.replaceWith( $newSummary );
+ flowBoard.emitWithReturn( 'makeContentInteractive', $newSummary
);
return $.Deferred().resolve().promise();
};
diff --git a/tests/qunit/engine/components/board/test_flow-board.js
b/tests/qunit/engine/components/board/test_flow-board.js
index eb2a8e3..fd59445 100644
--- a/tests/qunit/engine/components/board/test_flow-board.js
+++ b/tests/qunit/engine/components/board/test_flow-board.js
@@ -151,7 +151,7 @@
QUnit.test( 'FlowBoardComponent.UI.events.apiHandlers.preview (summary)', 3,
function( assert ) {
var $container = this.$el,
$form = $( '<form>' ).appendTo( $container ),
- $textarea = $( '<textarea
data-flow-preview-template="flow_topic_titlebar_summary.partial"
data-flow-preview-node="summary">text</textarea>' ).appendTo( $form ),
+ $textarea = $( '<textarea
data-flow-preview-template="flow_topic_titlebar_summary.partial">text</textarea>'
).appendTo( $form ),
$btn = $( '<button name="preview">' ).
appendTo( $form ),
info = {
--
To view, visit https://gerrit.wikimedia.org/r/197027
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2a0c962903b234c16d3abdc08a35a7f4c67dfd51
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits