jenkins-bot has submitted this change and it was merged.
Change subject: Separate lock reason from summary
......................................................................
Separate lock reason from summary
We recently adjusted to display the moderation reason of a topic directly
in the topic titlebar. Since locking/unlocking a topic was setting both the
moderation reason and the summary duplicate content is being displayed. We
decided to split the two, showing the lock reason and leaving the summary alone
for usage as the users see fit.
This patch changes the locking forms and apis to accept the reason argument
instead of summary, and removes the code in the TopicSummary block that responds
to the lock-topic action.
Change-Id: Ic576481b1215f1ab0bd836915900a34a48f7047b
(cherry picked from commit e93057a458b9691f6a9710b5ad92f63db5259805)
---
M handlebars/compiled/flow_block_topic_lock.handlebars.php
M handlebars/flow_topic_titlebar_lock.handlebars
M includes/Block/Topic.php
M includes/Block/TopicSummary.php
M includes/api/ApiFlowLockTopic.php
5 files changed, 46 insertions(+), 111 deletions(-)
Approvals:
Spage: Looks good to me, approved
jenkins-bot: Verified
diff --git a/handlebars/compiled/flow_block_topic_lock.handlebars.php
b/handlebars/compiled/flow_block_topic_lock.handlebars.php
index 3f3ea91..32e0498 100644
--- a/handlebars/compiled/flow_block_topic_lock.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_lock.handlebars.php
@@ -37,28 +37,25 @@
</div>
<input type="hidden" name="wpEditToken"
value="'.htmlentities(((is_array($cx['scopes'][0]) &&
isset($cx['scopes'][0]['editToken'])) ? $cx['scopes'][0]['editToken'] : null),
ENT_QUOTES, 'UTF-8').'" />
- '.((LCRun3::ifvar($cx, ((is_array($in) &&
isset($in['summary'])) ? $in['summary'] : null))) ? '
- <input type="hidden" name="flow_prev_revision"
value="'.htmlentities(((is_array($in['summary']) &&
isset($in['summary']['revId'])) ? $in['summary']['revId'] : null), ENT_QUOTES,
'UTF-8').'" />
- ' : '').'
- <textarea name="flow_summary"
- class="mw-ui-input"
- type="text"
- required
- data-flow-preview-node="summary"
-
data-flow-preview-template="flow_topic_titlebar_summary">'.((LCRun3::ifvar($cx,
((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['content'])) ?
$cx['scopes'][0]['submitted']['content'] : null))) ?
''.htmlentities(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['content'])) ?
$cx['scopes'][0]['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'' :
''.((LCRun3::ifvar($cx, ((is_array($in) && isset($in['summary'])) ?
$in['summary'] : null))) ? ''.'
-
'.htmlentities(((is_array($in['summary']) && isset($in['summary']['content']))
? $in['summary']['content'] : null), ENT_QUOTES, 'UTF-8').'' :
'').'').'</textarea>
+ <textarea name="flow_reason"
+ class="mw-ui-input"
+ type="text"
+ required
+ data-flow-preview-node="moderateReason"
+
data-flow-preview-template="flow_topic_titlebar"
+ >'.((LCRun3::ifvar($cx,
((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['reason'])) ?
$cx['scopes'][0]['submitted']['reason'] : null))) ?
''.htmlentities(((is_array($cx['scopes'][0]['submitted']) &&
isset($cx['scopes'][0]['submitted']['reason'])) ?
$cx['scopes'][0]['submitted']['reason'] : null), ENT_QUOTES, 'UTF-8').'' :
'').'</textarea>
<div class="flow-form-actions flow-form-collapsible">
- <button
- data-role="submit"
- class="mw-ui-button mw-ui-constructive"
-
data-flow-interactive-handler="apiRequest"
- data-flow-api-target="< .flow-topic"
- data-flow-api-handler="lockTopic">
- '.((LCRun3::ifvar($cx,
((is_array($in) && isset($in['isModerated'])) ? $in['isModerated'] : null))) ? '
- '.LCRun3::ch($cx,
'l10n', Array(Array('flow-topic-action-unlock-topic'),Array()), 'encq').'
- ' : '
- '.LCRun3::ch($cx,
'l10n', Array(Array('flow-topic-action-lock-topic'),Array()), 'encq').'
- ').'
+ <button data-role="submit"
+ class="mw-ui-button mw-ui-constructive"
+
data-flow-interactive-handler="apiRequest"
+ data-flow-api-target="< .flow-topic"
+ data-flow-api-handler="lockTopic"
+ >
+ '.((LCRun3::ifvar($cx, ((is_array($in)
&& isset($in['isModerated'])) ? $in['isModerated'] : null))) ? '
+ '.LCRun3::ch($cx, 'l10n',
Array(Array('flow-topic-action-unlock-topic'),Array()), 'encq').'
+ ' : '
+ '.LCRun3::ch($cx, 'l10n',
Array(Array('flow-topic-action-lock-topic'),Array()), 'encq').'
+ ').'
</button>
'.LCRun3::hbch($cx, 'progressiveEnhancement',
Array(Array(),Array()), $in, function($cx, $in) {return '
<button data-flow-api-handler="preview"
diff --git a/handlebars/flow_topic_titlebar_lock.handlebars
b/handlebars/flow_topic_titlebar_lock.handlebars
index 818d864..c62a7e1 100644
--- a/handlebars/flow_topic_titlebar_lock.handlebars
+++ b/handlebars/flow_topic_titlebar_lock.handlebars
@@ -9,39 +9,29 @@
{{~/if~}}">
{{> flow_errors }}
<input type="hidden" name="wpEditToken"
value="{{@root.editToken}}" />
- {{#if summary}}
- <input type="hidden" name="flow_prev_revision"
value="{{summary.revId}}" />
- {{/if}}
- <textarea name="flow_summary"
- class="mw-ui-input"
- type="text"
- required
- data-flow-preview-node="summary"
-
data-flow-preview-template="flow_topic_titlebar_summary">
- {{~#if @root.submitted.content~}}
- {{[email protected]~}}
- {{~else~}}
- {{~#if summary~}}
- {{!-- This should always be
wikitext, even if its not we should
- still escape rather
than sending to conditional escape because
- tags make no sense
inside a <textrea>
- --}}
- {{~summary.content~}}
- {{~/if~}}
+ <textarea name="flow_reason"
+ class="mw-ui-input"
+ type="text"
+ required
+ data-flow-preview-node="moderateReason"
+
data-flow-preview-template="flow_topic_titlebar"
+ >
+ {{~#if @root.submitted.reason~}}
+ {{[email protected]~}}
{{~/if~}}
</textarea>
<div class="flow-form-actions flow-form-collapsible">
- <button
- data-role="submit"
- class="mw-ui-button mw-ui-constructive"
-
data-flow-interactive-handler="apiRequest"
- data-flow-api-target="< .flow-topic"
- data-flow-api-handler="lockTopic">
- {{#if isModerated}}
- {{l10n
"flow-topic-action-unlock-topic"}}
- {{else}}
- {{l10n
"flow-topic-action-lock-topic"}}
- {{/if}}
+ <button data-role="submit"
+ class="mw-ui-button mw-ui-constructive"
+
data-flow-interactive-handler="apiRequest"
+ data-flow-api-target="< .flow-topic"
+ data-flow-api-handler="lockTopic"
+ >
+ {{#if isModerated}}
+ {{l10n
"flow-topic-action-unlock-topic"}}
+ {{else}}
+ {{l10n
"flow-topic-action-lock-topic"}}
+ {{/if}}
</button>
{{> flow_form_buttons }}
<small class="flow-terms-of-use plainlinks">
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 0b784da..e1e9e5a 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -325,23 +325,8 @@
}
if ( empty( $this->submitted['reason'] ) ) {
- // If a summary is provided instead, parse the content
and truncate it
- if ( !empty( $this->submitted['summary'] ) ) {
- // @todo there might be a better
wikitext->plaintext method
- $this->submitted['reason'] =
Utils::htmlToPlaintext(
- Utils::convert(
- 'wikitext',
- 'html',
- $this->submitted['summary'],
-
$this->workflow->getArticleTitle()
- ),
- 255
- );
- }
- if ( empty( $this->submitted['reason'] ) ) {
- $this->addError( 'moderate', wfMessage(
'flow-error-invalid-moderation-reason' ) );
- return;
- }
+ $this->addError( 'moderate', wfMessage(
'flow-error-invalid-moderation-reason' ) );
+ return;
}
$reason = $this->submitted['reason'];
diff --git a/includes/Block/TopicSummary.php b/includes/Block/TopicSummary.php
index 6e21944..f60480b 100644
--- a/includes/Block/TopicSummary.php
+++ b/includes/Block/TopicSummary.php
@@ -47,7 +47,7 @@
/**
* @var string[]
*/
- protected $supportedPostActions = array( 'edit-topic-summary',
'lock-topic' );
+ protected $supportedPostActions = array( 'edit-topic-summary' );
/**
* @var string[]
@@ -64,7 +64,6 @@
'view-topic-summary' => 'single_view',
'compare-postsummary-revisions' => 'diff_view',
'edit-topic-summary' => 'edit',
- 'lock-topic' => 'lock',
);
/**
@@ -92,41 +91,9 @@
$this->validateTopicSummary();
break;
- case 'lock-topic':
- if ( !$this->isLockTopic() ) {
- $this->addError( 'moderate', wfMessage(
'flow-error-invalid-moderation-state' ) );
- return;
- }
- $this->validateTopicSummary();
- break;
-
default:
throw new InvalidActionException( "Unexpected
action: {$this->action}", 'invalid-action' );
}
- }
-
- /**
- * Check if this is closing/restoring a topic
- */
- protected function isLockTopic() {
- $state = isset( $this->submitted['moderationState'] ) ?
$this->submitted['moderationState'] : '';
- $bc = array(
- 'close' => AbstractRevision::MODERATED_LOCKED,
- 'reopen' => 'un' . AbstractRevision::MODERATED_LOCKED
- );
- $state = str_replace( array_keys( $bc ), array_values( $bc ),
$state );
-
- if ( $state == AbstractRevision::MODERATED_LOCKED ) {
- return true;
- }
- $root = $this->findTopicTitle();
- if (
- $root->getModerationState() ==
AbstractRevision::MODERATED_LOCKED &&
- $state == 'unlock' )
- {
- return true;
- }
- return false;
}
/**
@@ -243,7 +210,6 @@
public function commit() {
switch( $this->action ) {
case 'edit-topic-summary':
- case 'lock-topic':
return $this->saveTopicSummary();
break;
diff --git a/includes/api/ApiFlowLockTopic.php
b/includes/api/ApiFlowLockTopic.php
index e732cb0..83c1f04 100644
--- a/includes/api/ApiFlowLockTopic.php
+++ b/includes/api/ApiFlowLockTopic.php
@@ -10,10 +10,8 @@
protected function getBlockParams() {
$params = $this->extractRequestParams();
-
return array(
'topic' => $params,
- 'topicsummary' => $params,
);
}
@@ -30,18 +28,17 @@
'close', 'reopen' // BC: now replaced
by lock & unlock
),
),
- 'summary' => array(
+ 'reason' => array(
ApiBase::PARAM_REQUIRED => true,
+ ApiBase::PARAM_TYPE => 'string',
),
- 'prev_revision' => null,
);
}
public function getParamDescription() {
return array(
- 'moderationState' => 'What level to moderate at',
- 'summary' => 'Summary for closing/reopening topic',
- 'prev_revision' => 'Revision id of the current topic
summary revision to check for edit conflicts. Null for a new topic summary
revision',
+ 'moderationState' => "State to put topic in, either
locked or unlocked",
+ 'reason' => 'Reason for locking or unlocking the topic',
);
}
@@ -51,7 +48,7 @@
public function getExamples() {
return array(
-
'api.php?action=flow&submodule=lock-topic&cotmoderationState=lock&cotsummary=Ahhhh&cotprev_revision=xjs&workflow=',
+
'api.php?action=flow&submodule=lock-topic&cotmoderationState=lock&cotsummary=Ahhhh&workflow=',
);
}
}
--
To view, visit https://gerrit.wikimedia.org/r/165639
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic576481b1215f1ab0bd836915900a34a48f7047b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: wmf/1.25wmf2
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: Spage <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits