Sbisson has uploaded a new change for review. https://gerrit.wikimedia.org/r/216312
Change subject: [WIP] RC patrolling for Flow ...................................................................... [WIP] RC patrolling for Flow Patrolling link on * board description revision page * topic and post revision page * todo: board description diff page * todo: topic and post diff page Uses core's JS and API Bug: T94452 Change-Id: I04dcba1248a60f67385f736934207c90048b8ee3 --- M Resources.php M handlebars/compiled/flow_block_header_single_view.handlebars.php M handlebars/compiled/flow_block_topic_diff_view.handlebars.php M handlebars/compiled/flow_block_topic_single_view.handlebars.php M handlebars/flow_block_header_single_view.handlebars M handlebars/flow_block_topic_single_view.handlebars A handlebars/flow_patrol_action.partial.handlebars M i18n/en.json M i18n/qqq.json M includes/Formatter/RevisionViewFormatter.php M includes/Model/AbstractRevision.php M includes/UrlGenerator.php M modules/engine/components/board/flow-board.js 13 files changed, 128 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/12/216312/1 diff --git a/Resources.php b/Resources.php index 6b9dc22..4647afd 100644 --- a/Resources.php +++ b/Resources.php @@ -414,6 +414,7 @@ 'mediawiki.api', 'mediawiki.util', 'mediawiki.api.options', // required by switch-editor feature + 'mediawiki.page.patrol.ajax', ), 'messages' => array( 'flow-error-external', diff --git a/handlebars/compiled/flow_block_header_single_view.handlebars.php b/handlebars/compiled/flow_block_header_single_view.handlebars.php index 04b3511..c442e13 100644 --- a/handlebars/compiled/flow_block_header_single_view.handlebars.php +++ b/handlebars/compiled/flow_block_header_single_view.handlebars.php @@ -11,12 +11,26 @@ 'debug' => $debugopt, ), 'constants' => array(), - 'helpers' => array( 'l10nParse' => 'Flow\TemplateHelper::l10nParse', + 'helpers' => array( 'l10n' => 'Flow\TemplateHelper::l10n', + 'l10nParse' => 'Flow\TemplateHelper::l10nParse', 'escapeContent' => 'Flow\TemplateHelper::escapeContent', ), 'blockhelpers' => array(), 'hbhelpers' => array(), - 'partials' => array(), + 'partials' => array('flow_patrol_action' => function ($cx, $in, $sp) {return ''.$sp.''.((LCRun3::ifvar($cx, ((isset($in['revision']['rev_view_links']['markPatrolled']) && is_array($in['revision']['rev_view_links'])) ? $in['revision']['rev_view_links']['markPatrolled'] : null))) ? '<div class="patrollink"> +'.$sp.''.((LCRun3::ifvar($cx, ((isset($in['diffPage']) && is_array($in)) ? $in['diffPage'] : null))) ? ' <a class="mw-ui-quiet" +'.$sp.' href="'.htmlentities((string)((isset($in['revision']['rev_view_links']['markPatrolled']['url']) && is_array($in['revision']['rev_view_links']['markPatrolled'])) ? $in['revision']['rev_view_links']['markPatrolled']['url'] : null), ENT_QUOTES, 'UTF-8').'" +'.$sp.' title="'.LCRun3::ch($cx, 'l10n', array(array('flow-mark-diff-patrolled-link-title'),array()), 'encq').'" +'.$sp.' data-role="patrol"> +'.$sp.' ['.LCRun3::ch($cx, 'l10n', array(array('flow-mark-diff-patrolled-link-text'),array()), 'encq').'] +'.$sp.' </a> +'.$sp.'' : ' <a class="mw-ui-quiet" +'.$sp.' href="'.htmlentities((string)((isset($in['revision']['rev_view_links']['markPatrolled']['url']) && is_array($in['revision']['rev_view_links']['markPatrolled'])) ? $in['revision']['rev_view_links']['markPatrolled']['url'] : null), ENT_QUOTES, 'UTF-8').'" +'.$sp.' title="'.LCRun3::ch($cx, 'l10n', array(array('flow-mark-revision-patrolled-link-title'),array()), 'encq').'" +'.$sp.' data-role="patrol"> +'.$sp.' ['.LCRun3::ch($cx, 'l10n', array(array('flow-mark-revision-patrolled-link-text'),array()), 'encq').'] +'.$sp.' </a> +'.$sp.'').' </div>' : '').'';},), 'scopes' => array(), 'sp_vars' => array('root' => $in), 'lcrun' => 'LCRun3', @@ -32,7 +46,8 @@ <div class="flow-revision-content"> '.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> -</div> + +'.LCRun3::p($cx, 'flow_patrol_action', array(array($in),array())).'</div> '; } ?> \ No newline at end of file diff --git a/handlebars/compiled/flow_block_topic_diff_view.handlebars.php b/handlebars/compiled/flow_block_topic_diff_view.handlebars.php index f089d6e..e8c94b0 100644 --- a/handlebars/compiled/flow_block_topic_diff_view.handlebars.php +++ b/handlebars/compiled/flow_block_topic_diff_view.handlebars.php @@ -30,6 +30,7 @@ <div class="flow-compare-revisions"> '.LCRun3::ch($cx, 'diffRevision', array(array(((isset($in['revision']['diff_content']) && is_array($in['revision'])) ? $in['revision']['diff_content'] : null),((isset($in['revision']['old']['human_timestamp']) && is_array($in['revision']['old'])) ? $in['revision']['old']['human_timestamp'] : null),((isset($in['revision']['new']['human_timestamp']) && is_array($in['revision']['new'])) ? $in['revision']['new']['human_timestamp'] : null),((isset($in['revision']['old']['author']['name']) && is_array($in['revision']['old']['author'])) ? $in['revision']['old']['author']['name'] : null),((isset($in['revision']['new']['author']['name']) && is_array($in['revision']['new']['author'])) ? $in['revision']['new']['author']['name'] : null),((isset($in['revision']['old']['rev_view_links']['single-view']['url']) && is_array($in['revision']['old']['rev_view_links']['single-view'])) ? $in['revision']['old']['rev_view_links']['single-view']['url'] : null),((isset($in['revision']['new']['rev_view_links']['single-view']['url']) && is_array($in['revision']['new']['rev_view_links']['single-view'])) ? $in['revision']['new']['rev_view_links']['single-view']['url'] : null),((isset($in['revision']['links']['previous']) && is_array($in['revision']['links'])) ? $in['revision']['links']['previous'] : null),((isset($in['revision']['links']['next']) && is_array($in['revision']['links'])) ? $in['revision']['links']['next'] : null)),array()), 'encq').' </div> + <h1>ASDFASD</h1> </div> '; } diff --git a/handlebars/compiled/flow_block_topic_single_view.handlebars.php b/handlebars/compiled/flow_block_topic_single_view.handlebars.php index 6da2a7e..05e69e8 100644 --- a/handlebars/compiled/flow_block_topic_single_view.handlebars.php +++ b/handlebars/compiled/flow_block_topic_single_view.handlebars.php @@ -11,12 +11,26 @@ 'debug' => $debugopt, ), 'constants' => array(), - 'helpers' => array( 'l10nParse' => 'Flow\TemplateHelper::l10nParse', + 'helpers' => array( 'l10n' => 'Flow\TemplateHelper::l10n', + 'l10nParse' => 'Flow\TemplateHelper::l10nParse', 'escapeContent' => 'Flow\TemplateHelper::escapeContent', ), 'blockhelpers' => array(), 'hbhelpers' => array(), - 'partials' => array(), + 'partials' => array('flow_patrol_action' => function ($cx, $in, $sp) {return ''.$sp.''.((LCRun3::ifvar($cx, ((isset($in['revision']['rev_view_links']['markPatrolled']) && is_array($in['revision']['rev_view_links'])) ? $in['revision']['rev_view_links']['markPatrolled'] : null))) ? '<div class="patrollink"> +'.$sp.''.((LCRun3::ifvar($cx, ((isset($in['diffPage']) && is_array($in)) ? $in['diffPage'] : null))) ? ' <a class="mw-ui-quiet" +'.$sp.' href="'.htmlentities((string)((isset($in['revision']['rev_view_links']['markPatrolled']['url']) && is_array($in['revision']['rev_view_links']['markPatrolled'])) ? $in['revision']['rev_view_links']['markPatrolled']['url'] : null), ENT_QUOTES, 'UTF-8').'" +'.$sp.' title="'.LCRun3::ch($cx, 'l10n', array(array('flow-mark-diff-patrolled-link-title'),array()), 'encq').'" +'.$sp.' data-role="patrol"> +'.$sp.' ['.LCRun3::ch($cx, 'l10n', array(array('flow-mark-diff-patrolled-link-text'),array()), 'encq').'] +'.$sp.' </a> +'.$sp.'' : ' <a class="mw-ui-quiet" +'.$sp.' href="'.htmlentities((string)((isset($in['revision']['rev_view_links']['markPatrolled']['url']) && is_array($in['revision']['rev_view_links']['markPatrolled'])) ? $in['revision']['rev_view_links']['markPatrolled']['url'] : null), ENT_QUOTES, 'UTF-8').'" +'.$sp.' title="'.LCRun3::ch($cx, 'l10n', array(array('flow-mark-revision-patrolled-link-title'),array()), 'encq').'" +'.$sp.' data-role="patrol"> +'.$sp.' ['.LCRun3::ch($cx, 'l10n', array(array('flow-mark-revision-patrolled-link-text'),array()), 'encq').'] +'.$sp.' </a> +'.$sp.'').' </div>' : '').'';},), 'scopes' => array(), 'sp_vars' => array('root' => $in), 'lcrun' => 'LCRun3', @@ -31,7 +45,8 @@ <div class="flow-revision-content"> '.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> -</div> + +'.LCRun3::p($cx, 'flow_patrol_action', array(array($in),array()), ' ').'</div> '; diff --git a/handlebars/flow_block_header_single_view.handlebars b/handlebars/flow_block_header_single_view.handlebars index 640a048..a4c4a1b 100644 --- a/handlebars/flow_block_header_single_view.handlebars +++ b/handlebars/flow_block_header_single_view.handlebars @@ -16,4 +16,6 @@ <div class="flow-revision-content"> {{escapeContent revision.content.format revision.content.content}} </div> + +{{> flow_patrol_action}} </div> diff --git a/handlebars/flow_block_topic_single_view.handlebars b/handlebars/flow_block_topic_single_view.handlebars index dca9b8e..a55b8c9 100644 --- a/handlebars/flow_block_topic_single_view.handlebars +++ b/handlebars/flow_block_topic_single_view.handlebars @@ -19,6 +19,8 @@ <div class="flow-revision-content"> {{escapeContent revision.content.format revision.content.content}} </div> + + {{> flow_patrol_action}} </div> diff --git a/handlebars/flow_patrol_action.partial.handlebars b/handlebars/flow_patrol_action.partial.handlebars new file mode 100644 index 0000000..fcfe559 --- /dev/null +++ b/handlebars/flow_patrol_action.partial.handlebars @@ -0,0 +1,19 @@ +{{~#if revision.rev_view_links.markPatrolled~}} + <div class="patrollink"> + {{#if diffPage}} + <a class="mw-ui-quiet" + href="{{revision.rev_view_links.markPatrolled.url}}" + title="{{l10n 'flow-mark-diff-patrolled-link-title'}}" + data-role="patrol"> + [{{l10n 'flow-mark-diff-patrolled-link-text'}}] + </a> + {{else}} + <a class="mw-ui-quiet" + href="{{revision.rev_view_links.markPatrolled.url}}" + title="{{l10n 'flow-mark-revision-patrolled-link-title'}}" + data-role="patrol"> + [{{l10n 'flow-mark-revision-patrolled-link-text'}}] + </a> + {{/if}} + </div> +{{~/if~}} diff --git a/i18n/en.json b/i18n/en.json index 1f3f99e..9e215d3 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -545,5 +545,7 @@ "flow-wikitext-editor-help-uses-wikitext": "[[mw:Help:Formatting|uses markup]]", "flow-wikitext-editor-help-preview-the-result": "preview the result", "flow-wikitext-switch-editor-tooltip": "Switch to VisualEditor", - "flow-ve-switch-editor-tool-title": "Switch to Wikitext editor" + "flow-ve-switch-editor-tool-title": "Switch to Wikitext editor", + "flow-mark-revision-patrolled-link-text": "Mark this page as patrolled", + "flow-mark-revision-patrolled-link-title": "Mark this page as patrolled" } diff --git a/i18n/qqq.json b/i18n/qqq.json index fcaeed0..fdbe09a 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -550,5 +550,7 @@ "flow-wikitext-editor-help-uses-wikitext": "Link to wikitext help. Used in the following messages:\n* {{msg-mw|flow-wikitext-editor-help}}\n* {{msg-mw|flow-wikitext-editor-help-and-preview}}", "flow-wikitext-editor-help-preview-the-result": "Text of link that will switch from wikitext editor to an html preview. See also flow-wikitext-editor-help", "flow-wikitext-switch-editor-tooltip": "Tooltip for button shown below a wikitext editor to switch to VisualEditor.", - "flow-ve-switch-editor-tool-title": "Tooltip for button in visualeditor toolbar to switch to the wikitext editor." + "flow-ve-switch-editor-tool-title": "Tooltip for button in visualeditor toolbar to switch to the wikitext editor.", + "flow-mark-revision-patrolled-link-text": "Text of the link to mark a revision as patrolled.", + "flow-mark-revision-patrolled-link-title": "Title of the link to mark a revision as patrolled." } diff --git a/includes/Formatter/RevisionViewFormatter.php b/includes/Formatter/RevisionViewFormatter.php index b17a23d..9c24721 100644 --- a/includes/Formatter/RevisionViewFormatter.php +++ b/includes/Formatter/RevisionViewFormatter.php @@ -7,6 +7,7 @@ use Flow\Model\PostSummary; use Flow\UrlGenerator; use IContextSource; +use ChangesList; class RevisionViewFormatter { /** @@ -39,7 +40,7 @@ */ public function formatApi( FormatterRow $row, IContextSource $ctx ) { $res = $this->serializer->formatApi( $row, $ctx ); - $res['rev_view_links'] = $this->buildLinks( $row ); + $res['rev_view_links'] = $this->buildLinks( $row, $ctx ); $res['human_timestamp'] = $this->getHumanTimestamp( $res['timestamp'] ); if ( $row->revision instanceof PostRevision ) { $res['properties']['topic-of-post'] = $this->serializer->processParam( @@ -61,11 +62,13 @@ } /** - * Generate the links for single and diff vie actions + * Generate the links for single and diff view actions + * * @param FormatterRow $row + * @param IContextSource $ctx * @return array */ - public function buildLinks( FormatterRow $row ) { + public function buildLinks( FormatterRow $row, IContextSource $ctx ) { $workflowId = $row->workflow->getId(); $boardTitle = $row->workflow->getOwnerTitle(); @@ -120,6 +123,15 @@ ); } + $recentChange = $row->revision->getRecentChange(); + if ( ChangesList::isUnpatrolled( $recentChange, $ctx->getUser() ) ) { + $links['markPatrolled'] = $this->urlGenerator->markRevisionPatrolledAction( + $title, + $workflowId, + $recentChange + ); + } + return $links; } diff --git a/includes/Model/AbstractRevision.php b/includes/Model/AbstractRevision.php index 3a2e5f2..3fac8a6 100644 --- a/includes/Model/AbstractRevision.php +++ b/includes/Model/AbstractRevision.php @@ -8,6 +8,7 @@ use Flow\Parsoid\Utils; use Title; use User; +use RecentChange; abstract class AbstractRevision { const MODERATED_NONE = ''; @@ -700,6 +701,28 @@ } /** + * Finds the RecentChange object associated with this flow revision. + * + * @return null|RecentChange + */ + public function getRecentChange() { + $timestamp = $this->revId->getTimestamp(); + //if ($this->changeType === 'new-topic' ns will be different + $title = $this->getCollection()->getTitle(); + $namespace = $title->getNamespace(); + + // note: there could be more than 1 result with the same exact timestamp + return RecentChange::newFromConds( + array( + 'rc_title' => $title->getDBkey(), + 'rc_timestamp' => $timestamp, + 'rc_namespace' => $namespace + ), + __METHOD__ + ); + } + + /** * @return string */ abstract public function getRevisionType(); diff --git a/includes/UrlGenerator.php b/includes/UrlGenerator.php index f142a26..b1b4bd3 100644 --- a/includes/UrlGenerator.php +++ b/includes/UrlGenerator.php @@ -12,10 +12,10 @@ use Flow\Model\PostRevision; use Flow\Model\PostSummary; use Flow\Model\UUID; -use Flow\Model\Workflow; use SpecialPage; use Title; use RequestContext; +use RecentChange; /** * Provides url generation capabilities for Flow. Ties together an @@ -835,4 +835,25 @@ wfMessage( 'flow-thank-link-title', $sender, $recipient )->text() ); } + + /** + * Mark a revision as patrolled + * + * @param Title|null $title + * @param UUID $workflowId + * @param RecentChange $rc + * @return Anchor + * @throws FlowException + * @throws InvalidInputException + */ + public function markRevisionPatrolledAction( Title $title = null, UUID $workflowId, RecentChange $rc ) { + return new Anchor( + wfMessage( 'flow-mark-revision-patrolled-link-text' )->text(), + $this->resolveTitle( $title, $workflowId ), + array( + 'action' => 'markpatrolled', + 'rcid' => $rc->getAttribute( 'rc_id' ) + ) + ); + } } diff --git a/modules/engine/components/board/flow-board.js b/modules/engine/components/board/flow-board.js index 621324b..b239ec8 100644 --- a/modules/engine/components/board/flow-board.js +++ b/modules/engine/components/board/flow-board.js @@ -185,7 +185,7 @@ var _notify = mw.notify; mw.notify = function ( message, options ) { // override message when we've just watched the board - if ( options.tag === 'watch-self' && $( '#ca-watch' ).length ) { + if ( options && options.tag === 'watch-self' && $( '#ca-watch' ).length ) { // Render a div telling the user that they have subscribed message = $( mw.flow.TemplateEngine.processTemplateGetFragment( 'flow_subscribed.partial', -- To view, visit https://gerrit.wikimedia.org/r/216312 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I04dcba1248a60f67385f736934207c90048b8ee3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Sbisson <sbis...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits