Cenarium has uploaded a new change for review. https://gerrit.wikimedia.org/r/315280
Change subject: Add toggle to show/hide protection log in edit window ...................................................................... Add toggle to show/hide protection log in edit window This adds a toggle to show/hide the protection log excerpt displayed when editing a protected page. It is collapsed by default. Bug: T147807 Change-Id: Ib25dc730411ad8c95a8dbaf2426a2d1b36ef05e6 --- M includes/EditPage.php M includes/logging/LogEventsList.php M languages/i18n/en.json M languages/i18n/qqq.json M resources/Resources.php A resources/src/mediawiki/mediawiki.protectLogExcerptToggle.js A resources/src/mediawiki/mediawiki.toggle.css 7 files changed, 108 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/80/315280/1 diff --git a/includes/EditPage.php b/includes/EditPage.php index 8226da5..644eb87 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -3024,8 +3024,20 @@ # Then it must be protected based on static groups (regular) $noticeMsg = 'protectedpagewarning'; } + // create a toggle to show/hide the log extract + $innerToggle = '<a class="toggle-text" title="' . + $this->context->msg( 'log-toggle-protect-title' )->escaped() . '" >' . + $this->context->msg( 'log-toggle-protect-show' )->escaped() . '</a>'; + $toggle = ' <span id="mw-protectlogtoggle" class="logexcerpt-toggle" + style="display:none;">' . + $this->context->msg( 'parentheses' )->rawParams( $innerToggle )->escaped() . + '</span>'; + // show the protection log extract with a toggle LogEventsList::showLogExtract( $wgOut, 'protect', $this->mTitle, '', - [ 'lim' => 1, 'msgKey' => [ $noticeMsg ] ] ); + [ 'lim' => 1, 'msgKey' => [ $noticeMsg ], 'toggle' => $toggle, + 'spanId' => 'mw-protectlogexcerpt' ] ); + // add module for toggle + $wgOut->addModules( 'mediawiki.protectLogExcerptToggle' ); } if ( $this->mTitle->isCascadeProtected() ) { # Is this page under cascading protection from some source pages? diff --git a/includes/logging/LogEventsList.php b/includes/logging/LogEventsList.php index 0cf584b..be0667e 100644 --- a/includes/logging/LogEventsList.php +++ b/includes/logging/LogEventsList.php @@ -569,6 +569,8 @@ 'useRequestParams' => false, 'useMaster' => false, 'extraUrlParams' => false, + 'spanId' => '', + 'toggle' => '', ]; # The + operator appends elements of remaining keys from the right # handed array to the left handed, whereas duplicated keys are NOT overwritten. @@ -632,12 +634,23 @@ ] ); if ( count( $msgKey ) == 1 ) { - $s .= $context->msg( $msgKey[0] )->parseAsBlock(); + $msgText = $context->msg( $msgKey[0] )->parseAsBlock(); } else { // Process additional arguments $args = $msgKey; array_shift( $args ); - $s .= $context->msg( $msgKey[0], $args )->parseAsBlock(); + $msgText = $context->msg( $msgKey[0], $args )->parseAsBlock(); } + if ( $param['toggle'] ) { + // append toggle at the end of the message + $s .= Parser::stripOuterParagraph( $msgText ); + $s .= $param['toggle']; + } else { + $s .= $msgText; + } + } + if ( $param['spanId'] ) { + // wrap log extract in specified span id + $s .= '<span id="' . $param['spanId'] . '" > '; } $s .= $loglist->beginLogEventsList() . $logBody . @@ -680,8 +693,13 @@ ); } - if ( $logBody && $msgKey[0] ) { - $s .= '</div>'; + if ( $logBody ) { + if ( $param['spanId'] ) { + $s .= '</span>'; + } + if ( $msgKey[0] ) { + $s .= '</div>'; + } } if ( $wrap != '' ) { // Wrap message in html diff --git a/languages/i18n/en.json b/languages/i18n/en.json index d10749d..fe3c82a 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -4226,5 +4226,8 @@ "usercssispublic": "Please note: CSS subpages should not contain confidential data as they are viewable by other users.", "restrictionsfield-badip": "Invalid IP address or range: $1", "restrictionsfield-label": "Allowed IP ranges:", - "restrictionsfield-help": "One IP address or CIDR range per line. To enable everything, use<br><code>0.0.0.0/0</code><br><code>::/0</code>" + "restrictionsfield-help": "One IP address or CIDR range per line. To enable everything, use<br><code>0.0.0.0/0</code><br><code>::/0</code>", + "log-toggle-protect-title": "Toggle display of protection log excerpt", + "log-toggle-protect-show": "show protection log", + "log-toggle-protect-hide": "hide protection log" } diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 96f8c38..9e8f1b3 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -4410,5 +4410,8 @@ "usercssispublic": "A reminder to users that CSS subpages are not preferences but normal pages, and thus can be viewed by other users and the general public. This message is shown to a user whenever they are editing a subpage in their own user-space that ends in .css. See also {{msg-mw|userjsispublic}}", "restrictionsfield-badip": "An error message shown when one entered an invalid IP address or range in a restrictions field (such as Special:BotPassword). $1 is the IP address.", "restrictionsfield-label": "Field label shown for restriction fields (e.g. on Special:BotPassword).", - "restrictionsfield-help": "Placeholder text displayed in restriction fields (e.g. on Special:BotPassword)." + "restrictionsfield-help": "Placeholder text displayed in restriction fields (e.g. on Special:BotPassword).", + "log-toggle-protect-title": "This message is shown as an attribute title to the protection log toggle.", + "log-toggle-protect-show": "Used as the name of a toggle to uncollapse the protection log", + "log-toggle-protect-hide": "Used as the name of a toggle to collapse the protection log" } diff --git a/resources/Resources.php b/resources/Resources.php index e7c8e49..e69b808 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -2191,6 +2191,20 @@ ], 'targets' => [ 'desktop', 'mobile' ], ], + 'mediawiki.protectLogExcerptToggle' => [ + 'scripts' => [ + 'resources/src/mediawiki/mediawiki.protectLogExcerptToggle.js' + ], + 'skinStyles' => [ + 'default' => [ + 'resources/src/mediawiki/mediawiki.toggle.css' + ], + ], + 'messages' => [ + 'log-toggle-protect-show', 'log-toggle-protect-hide', + ], + 'dependencies' => [ 'jquery.accessKeyLabel' ], + ], 'mediawiki.widgets' => [ 'scripts' => [ diff --git a/resources/src/mediawiki/mediawiki.protectLogExcerptToggle.js b/resources/src/mediawiki/mediawiki.protectLogExcerptToggle.js new file mode 100644 index 0000000..f8cb668 --- /dev/null +++ b/resources/src/mediawiki/mediawiki.protectLogExcerptToggle.js @@ -0,0 +1,46 @@ +/** + * + */ +( function ( mw, $ ) { + "use strict"; + +var logHandler = { + /** + * Toggles log excerpts + */ + toggleLog: function () { + var hideMsg, showMsg, + log = $( '#mw-protectlogexcerpt' ), + toggle = $( '#mw-protectlogtoggle' ); + + if ( log.length && toggle.length ) { + hideMsg = mw.msg( 'log-toggle-protect-hide' ); + showMsg = mw.msg( 'log-toggle-protect-show' ); + + if ( log.css( 'display' ) === 'none' ) { + log.show(); + toggle.children( 'a' ).text( hideMsg ); + } else { + log.hide(); + toggle.children( 'a' ).text( showMsg ); + } + } + }, + + /* Startup function */ + init: function () { + + // Enables log detail box and toggle + var toggle = $( '#mw-protectlogtoggle' ); + if ( toggle.length ) { + toggle.css( 'display', 'inline' ); // show toggle control + $( '#mw-protectlogexcerpt' ).hide(); // hide log excerpt + } + toggle.children( 'a' ).click( logHandler.toggleLog ); + } +}; + +// Perform some onload events: +$( logHandler.init ); + +}( mediaWiki, jQuery ) ); diff --git a/resources/src/mediawiki/mediawiki.toggle.css b/resources/src/mediawiki/mediawiki.toggle.css new file mode 100644 index 0000000..33cce88 --- /dev/null +++ b/resources/src/mediawiki/mediawiki.toggle.css @@ -0,0 +1,5 @@ +a.toggle-text { + color: blue; + font-weight: bold; + cursor: pointer; +} -- To view, visit https://gerrit.wikimedia.org/r/315280 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib25dc730411ad8c95a8dbaf2426a2d1b36ef05e6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Cenarium <cenarium.sy...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits