[MediaWiki-commits] [Gerrit] mediawiki...Collection[master]: Disable the Download section on Manage Books page

2017-09-27 Thread jenkins-bot (Code Review)
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,
'

[MediaWiki-commits] [Gerrit] mediawiki...Collection[master]: Disable the Download section on Manage Books page

2017-09-25 Thread Pmiazga (Code Review)
Pmiazga has uploaded a new change for review. ( 
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

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, 30 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection 
refs/changes/72/380572/1

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..8fe5c5c 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 = false;
+
 # 
==
 
 # register Special:Book:
diff --git a/resources/ext.collection.bookcreator.styles/bookcreator.css 
b/resources/ext.collection.bookcreator.styles/bookcreator.css
index 42c9dde..57faa0c 100644
--- a/resources/ext.collection.bookcreator.styles/bookcreator.css
+++ b/resources/ext.collection.bookcreator.styles/bookcreator.css
@@ -126,3 +126,12 @@
 #coll-orderbox ul {
list-style: none;
 }
+
+.collection-box-disabled {
+   color: #d2d2d2;
+   border-color: #eee;
+}
+.collection-box-disabled h2 {
+   color: #d2d2d2;
+   border-bottom-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' => $de