[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Extract ConstraintReportPanel element into ui module

2017-07-18 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/365616 )

Change subject: Extract ConstraintReportPanel element into ui module
..


Extract ConstraintReportPanel element into ui module

The code to create an OO.ui PanelLayout for a constraint report is
extracted from gadget.js into a new OO.ui class, ConstraintReportPanel,
which resides in the ui module (since it can be used independently of
the gadget).

The idea is to similarly extract the StackLayout into a new element
(probably ConstraintReportStack), and to implement T169971 there. The
gadget is then left only with the task of creating these elements and
appending them to statements.

Change-Id: Ic7143092eb91cc47e98b50cb4538745ef0e01c76
---
M .eslintrc.json
M extension.json
M modules/gadget.js
A modules/ui/ConstraintReportPanel.js
A modules/ui/module.js
5 files changed, 107 insertions(+), 31 deletions(-)

Approvals:
  Jonas Kress (WMDE): Looks good to me, approved
  jenkins-bot: Verified



diff --git a/.eslintrc.json b/.eslintrc.json
index a03258b..bd8174d 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -6,6 +6,7 @@
},
"globals": {
"mediaWiki": false,
+   "wikibase": false,
"OO": false
},
"rules": {
diff --git a/extension.json b/extension.json
index edad5d6..3029c4f 100644
--- a/extension.json
+++ b/extension.json
@@ -50,11 +50,20 @@
"scripts": "modules/SpecialConstraintReportPage.js"
},
"wikibase.quality.constraints.ui": {
+   "dependencies": [
+   "oojs-ui-core",
+   "oojs-ui-widgets",
+   "wikibase"
+   ],
"messages": [
"wbqc-potentialissues-short",
"wbqc-potentialissues-long",
"wbqc-badparameters-short",
"wbqc-badparameters-long"
+   ],
+   "scripts": [
+   "modules/ui/module.js",
+   "modules/ui/ConstraintReportPanel.js"
]
},
"wikibase.quality.constraints.gadget": {
diff --git a/modules/gadget.js b/modules/gadget.js
index bf62e2c..69c6c0e 100644
--- a/modules/gadget.js
+++ b/modules/gadget.js
@@ -1,4 +1,4 @@
-( function( mw, $, OO ) {
+( function( mw, wb, $, OO ) {
'use strict';
 
var entityId;
@@ -29,36 +29,11 @@
}
 
function buildReport( result ) {
-   var $report, $heading, $helpButton;
-
if ( result.status === 'violation' || result.status === 
'bad-parameters' ) {
-   $report = $( '' )
-   .addClass( 'wbqc-report' )
-   .addClass( 'wbqc-report-status-' + 
result.status );
-   $heading = $( '' ).append(
-   $( '' )
-   .text( result.constraint.typeLabel )
-   .attr( 'href', result.constraint.link )
-   .attr( 'target', '_blank' )
-   );
-   $helpButton = new OO.ui.ButtonWidget( {
-   icon: 'help',
-   framed: false,
-   classes: [ 'wbqc-constraint-type-help' ],
-   href: 
'https://www.wikidata.org/wiki/Help:Property_constraints_portal/' + 
result.constraint.type,
-   target: '_blank'
-   } ).$element;
-   $heading.append( $helpButton );
-   $report.append( $heading );
-   if ( result[ 'message-html' ] ) {
-   $report.append(
-   $( '' ).html( result[ 'message-html' 
] )
-   );
-   }
-
-   return new OO.ui.PanelLayout( {
-   expanded: false,
-   $content: $report
+   return new 
wb.quality.constraints.ui.ConstraintReportPanel( {
+   status: result.status,
+   constraint: result.constraint,
+   message: result[ 'message-html' ]
} );
} else {
return null;
@@ -203,4 +178,4 @@
} );
} );
} );
-} )( mediaWiki, jQuery, OO );
+} )( mediaWiki, wikibase, jQuery, OO );
diff --git a/modules/ui/ConstraintReportPanel.js 

[MediaWiki-commits] [Gerrit] mediawiki...WikibaseQualityConstraints[master]: Extract ConstraintReportPanel element into ui module

2017-07-17 Thread Lucas Werkmeister (WMDE) (Code Review)
Lucas Werkmeister (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/365616 )

Change subject: Extract ConstraintReportPanel element into ui module
..

Extract ConstraintReportPanel element into ui module

The code to create an OO.ui PanelLayout for a constraint report is
extracted from gadget.js into a new OO.ui class, ConstraintReportPanel,
which resides in the ui module (since it can be used independently of
the gadget).

The idea is to similarly extract the StackLayout into a new element
(probably ConstraintReportStack), and to implement T169971 there. The
gadget is then left only with the task of creating these elements and
appending them to statements.

Change-Id: Ic7143092eb91cc47e98b50cb4538745ef0e01c76
---
M .eslintrc.json
M extension.json
M modules/gadget.js
A modules/ui/ConstraintReportPanel.js
A modules/ui/module.js
5 files changed, 107 insertions(+), 31 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityConstraints
 refs/changes/16/365616/1

diff --git a/.eslintrc.json b/.eslintrc.json
index a03258b..bd8174d 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -6,6 +6,7 @@
},
"globals": {
"mediaWiki": false,
+   "wikibase": false,
"OO": false
},
"rules": {
diff --git a/extension.json b/extension.json
index edad5d6..3029c4f 100644
--- a/extension.json
+++ b/extension.json
@@ -50,11 +50,20 @@
"scripts": "modules/SpecialConstraintReportPage.js"
},
"wikibase.quality.constraints.ui": {
+   "dependencies": [
+   "oojs-ui-core",
+   "oojs-ui-widgets",
+   "wikibase"
+   ],
"messages": [
"wbqc-potentialissues-short",
"wbqc-potentialissues-long",
"wbqc-badparameters-short",
"wbqc-badparameters-long"
+   ],
+   "scripts": [
+   "modules/ui/module.js",
+   "modules/ui/ConstraintReportPanel.js"
]
},
"wikibase.quality.constraints.gadget": {
diff --git a/modules/gadget.js b/modules/gadget.js
index bf62e2c..69c6c0e 100644
--- a/modules/gadget.js
+++ b/modules/gadget.js
@@ -1,4 +1,4 @@
-( function( mw, $, OO ) {
+( function( mw, wb, $, OO ) {
'use strict';
 
var entityId;
@@ -29,36 +29,11 @@
}
 
function buildReport( result ) {
-   var $report, $heading, $helpButton;
-
if ( result.status === 'violation' || result.status === 
'bad-parameters' ) {
-   $report = $( '' )
-   .addClass( 'wbqc-report' )
-   .addClass( 'wbqc-report-status-' + 
result.status );
-   $heading = $( '' ).append(
-   $( '' )
-   .text( result.constraint.typeLabel )
-   .attr( 'href', result.constraint.link )
-   .attr( 'target', '_blank' )
-   );
-   $helpButton = new OO.ui.ButtonWidget( {
-   icon: 'help',
-   framed: false,
-   classes: [ 'wbqc-constraint-type-help' ],
-   href: 
'https://www.wikidata.org/wiki/Help:Property_constraints_portal/' + 
result.constraint.type,
-   target: '_blank'
-   } ).$element;
-   $heading.append( $helpButton );
-   $report.append( $heading );
-   if ( result[ 'message-html' ] ) {
-   $report.append(
-   $( '' ).html( result[ 'message-html' 
] )
-   );
-   }
-
-   return new OO.ui.PanelLayout( {
-   expanded: false,
-   $content: $report
+   return new 
wb.quality.constraints.ui.ConstraintReportPanel( {
+   status: result.status,
+   constraint: result.constraint,
+   message: result[ 'message-html' ]
} );
} else {
return null;
@@ -203,4 +178,4 @@
} );
} );
} );
-} )( mediaWiki, jQuery, OO );
+} )( mediaWiki, wikibase, jQuery, OO );
diff --git