jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/380572 )

Change subject: Disable the Download section on Manage Books page
......................................................................


Disable the Download section on Manage Books page

Changes:
 - introduced new config variable $wgCollectionDisableDownloadSection
 which allows to dynamically disable/enable download section
 - added new styles to make the box looks like disabled
 - changed the JS/PHP logic to disable the form submit when
 $wgCollectionDisableDownloadSection variable is set to on
 - the download box is disabled by default

Bug: T175996
Change-Id: I06b8c3ac94470b4081b32257483ca5b281b22026
---
M Collection.body.php
M Collection.php
M resources/ext.collection.bookcreator.styles/bookcreator.css
M resources/ext.collection/collection.js
M templates/CollectionPageTemplate.php
M templates/download-box.mustache
6 files changed, 27 insertions(+), 5 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jdlrobson: Looks good to me, approved



diff --git a/Collection.body.php b/Collection.body.php
index 7b4a0d7..6de4a8e 100644
--- a/Collection.body.php
+++ b/Collection.body.php
@@ -467,7 +467,8 @@
        }
 
        public function renderSpecialPage() {
-               global $wgCollectionFormats, $wgCollectionRendererSettings;
+               global $wgCollectionFormats, $wgCollectionRendererSettings,
+                       $wgCollectionDisableDownloadSection;
 
                if ( !CollectionSession::hasSession() ) {
                        CollectionSession::startSession();
@@ -479,6 +480,9 @@
                $out->setPageTitle( $this->msg( 'coll-manage_your_book' 
)->text() );
                $out->addModules( 'ext.collection' );
                $out->addModuleStyles( [ 'mediawiki.hlist', 
'ext.collection.bookcreator.styles' ] );
+               $out->addJsConfigVars( [
+                       'wgCollectionDisableDownloadSection' => 
$wgCollectionDisableDownloadSection
+               ] );
 
                $template = new CollectionPageTemplate();
                $template->set( 'context', $this->getContext() );
diff --git a/Collection.php b/Collection.php
index 8bf64a7..553e504 100644
--- a/Collection.php
+++ b/Collection.php
@@ -170,6 +170,10 @@
        'coll-rendering_finished_note_not_satisfied',
 ];
 
+# Disable the download section
+# see https://phabricator.wikimedia.org/T175996
+$wgCollectionDisableDownloadSection = true;
+
 # 
==============================================================================
 
 # register Special:Book:
diff --git a/resources/ext.collection.bookcreator.styles/bookcreator.css 
b/resources/ext.collection.bookcreator.styles/bookcreator.css
index 42c9dde..6b945c7 100644
--- a/resources/ext.collection.bookcreator.styles/bookcreator.css
+++ b/resources/ext.collection.bookcreator.styles/bookcreator.css
@@ -126,3 +126,9 @@
 #coll-orderbox ul {
        list-style: none;
 }
+
+.collection-box-disabled,
+.collection-box-disabled h2 {
+       color: #d2d2d2;
+       border-color: #eee;
+}
diff --git a/resources/ext.collection/collection.js 
b/resources/ext.collection/collection.js
index b36d51a..f148d0a 100644
--- a/resources/ext.collection/collection.js
+++ b/resources/ext.collection/collection.js
@@ -168,8 +168,10 @@
                        $( '#saveButton, #downloadButton, input.order' ).prop( 
'disabled', true );
                        return;
                } else {
-                       $( '#downloadButton, input.order' ).prop( 'disabled', 
false );
+                       $( 'input.order' ).prop( 'disabled', false );
+                       $( '#downloadButton' ).prop( 'disabled', mw.config.get( 
'wgCollectionDisableDownloadSection' ) );
                }
+
                if ( !$( '#saveButton' ).length ) {
                        return;
                }
diff --git a/templates/CollectionPageTemplate.php 
b/templates/CollectionPageTemplate.php
index e390e2b..262be2d 100644
--- a/templates/CollectionPageTemplate.php
+++ b/templates/CollectionPageTemplate.php
@@ -32,6 +32,7 @@
         * @return string
         */
        public function getDownloadForm( $context, $writers ) {
+               global $wgCollectionDisableDownloadSection;
                $defaultWriter = false;
 
                if ( count( $writers ) == 1 ) {
@@ -53,8 +54,13 @@
                                'label' => wfMessage( 'coll-format-' . 
$writerIdx )->escaped(),
                        ];
                }
+
+               $downloadDisabled = count( $this->data['collection']['items'] ) 
== 0
+                       || $wgCollectionDisableDownloadSection;
+
                $downloadForm = $templateParser->processTemplate( 
'download-box', [
                        'headline' => wfMessage( 'coll-download_title' ),
+                       'sectionDisabled' => 
$wgCollectionDisableDownloadSection === true,
                        'description' => $description,
                        'formAction' => SkinTemplate::makeSpecialUrl( 'Book' ),
                        'formats' => $templateDataFormats,
@@ -62,7 +68,7 @@
                        'formatSelectLabel' => wfMessage( 'coll-format_label' ),
                        'returnTo' => SpecialPage::getTitleFor( 'Book' 
)->getPrefixedText(),
                        'buttonLabel' => $buttonLabel,
-                       'downloadDisabled' => count( 
$this->data['collection']['items'] ),
+                       'downloadDisabled' => $downloadDisabled,
                ] );
                return $downloadForm;
        }
diff --git a/templates/download-box.mustache b/templates/download-box.mustache
index 167d3a7..9c1088d 100644
--- a/templates/download-box.mustache
+++ b/templates/download-box.mustache
@@ -1,4 +1,4 @@
-<div class="collection-column-right-box" id="coll-downloadbox">
+<div class="collection-column-right-box{{#sectionDisabled}} 
collection-box-disabled{{/sectionDisabled}}" id="coll-downloadbox">
        <h2><span class="mw-headline">{{headline}}</span></h2>
        {{{description}}}
        <form id="downloadForm" action="{{formAction}}" method="post">
@@ -11,7 +11,7 @@
                                                {{/writer}}
                                                {{^writer}}
                                                <label 
for="formatSelect">{{formatSelectLabel}}</label>
-                                               <select id="formatSelect" 
name="writer">
+                                               <select id="formatSelect" 
name="writer"{{#sectionDisabled}} disabled="disabled"{{/sectionDisabled}}>
                                                        {{#formats}}
                                                        <option 
value="{{name}}">{{label}}</option>
                                                        {{/formats}}

-- 
To view, visit https://gerrit.wikimedia.org/r/380572
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I06b8c3ac94470b4081b32257483ca5b281b22026
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Collection
Gerrit-Branch: master
Gerrit-Owner: Pmiazga <pmia...@wikimedia.org>
Gerrit-Reviewer: Bmansurov <bmansu...@wikimedia.org>
Gerrit-Reviewer: C. Scott Ananian <canan...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Pmiazga <pmia...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to