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

Change subject: Open help dialogue the first time a user sees TwoColConflict
......................................................................


Open help dialogue the first time a user sees TwoColConflict

Bug: T163783
Change-Id: I6e3d90fd574209e7edd645c14a39a1b96695d461
---
M extension.json
A modules/ext.TwoColConflict.Settings.js
M modules/ext.TwoColConflict.init.js
M tests/browser/features/base_selection.feature
M tests/browser/features/filter_options.feature
M tests/browser/features/help.feature
M tests/browser/features/support/pages/edit_conflict_page.rb
M tests/browser/features/support/step_definitions/common_steps.rb
M tests/browser/features/support/step_definitions/help_steps.rb
9 files changed, 137 insertions(+), 5 deletions(-)

Approvals:
  Addshore: Looks good to me, approved
  WMDE-Fisch: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 518460e..6479bac 100644
--- a/extension.json
+++ b/extension.json
@@ -53,11 +53,22 @@
                                "modules/ext.TwoColConflict.init.js"
                        ],
                        "dependencies": [
+                               "ext.TwoColConflict.Settings",
                                "ext.TwoColConflict.AutoScroll",
                                "ext.TwoColConflict.BaseVersionSelector",
                                "ext.TwoColConflict.HelpDialog"
                        ]
                },
+               "ext.TwoColConflict.Settings": {
+                       "scripts": [
+                               "modules/ext.TwoColConflict.Settings.js"
+                       ],
+                       "dependencies": [
+                               "mediawiki.storage",
+                               "mediawiki.cookie",
+                               "mediawiki.api.options"
+                       ]
+               },
                "ext.TwoColConflict.filterOptionsJs": {
                        "scripts": [
                                "modules/ext.TwoColConflict.filterOptions.js"
diff --git a/modules/ext.TwoColConflict.Settings.js 
b/modules/ext.TwoColConflict.Settings.js
new file mode 100644
index 0000000..afd4c2e
--- /dev/null
+++ b/modules/ext.TwoColConflict.Settings.js
@@ -0,0 +1,85 @@
+( function ( mw, $ ) {
+       /**
+        * @constructor
+        */
+       var Settings = function () {
+               this.hideHelpDialogue = this.loadBoolean( 'hide-help-dialogue' 
);
+       };
+
+       $.extend( Settings.prototype, {
+               /**
+                * @type {boolean}
+                */
+               hideHelpDialogue: null,
+
+               /**
+                * @return {boolean}
+                */
+               shouldHideHelpDialogue: function () {
+                       return this.hideHelpDialogue;
+               },
+
+               /**
+                * @param {boolean} newSetting
+                */
+               setHideHelpDialogue: function ( newSetting ) {
+                       if ( newSetting !== this.hideHelpDialogue ) {
+                               this.saveBoolean( 'hide-help-dialogue', 
newSetting );
+                               this.hideHelpDialogue = newSetting;
+                       }
+               },
+
+               /**
+                * @param {string} name
+                * @param {string} defaultValue
+                * @return {string|boolean}
+                */
+               loadSetting: function ( name, defaultValue ) {
+                       var setting;
+                       if ( !mw.user.isAnon() ) {
+                               setting = mw.user.options.get( 
'userjs-twocolconflict-' + name );
+                       } else {
+                               setting = mw.storage.get( 'mw-twocolconflict-' 
+ name );
+                               if ( !setting ) {
+                                       setting = mw.cookie.get( 
'-twocolconflict-' + name );
+                               }
+                       }
+
+                       return setting !== null && setting !== false ? setting 
: defaultValue;
+               },
+
+               /**
+                * @param {string} name
+                * @param {boolean} defaultValue
+                * @return {boolean}
+                */
+               loadBoolean: function ( name, defaultValue ) {
+                       return this.loadSetting( name, defaultValue ? '1' : '0' 
) === '1';
+               },
+
+               /**
+                * @param {string} name
+                * @param {string} value
+                */
+               saveSetting: function ( name, value ) {
+                       if ( !mw.user.isAnon() ) {
+                               ( new mw.Api() ).saveOption( 
'userjs-twocolconflict-' + name, value );
+                       } else {
+                               if ( !mw.storage.set( 'mw-twocolconflict-' + 
name, value ) ) {
+                                       mw.cookie.set( '-twocolconflict-' + 
name, value ); // use cookie when localStorage is not available
+                               }
+                       }
+               },
+
+               /**
+                * @param {string} name
+                * @param {boolean} value
+                */
+               saveBoolean: function ( name, value ) {
+                       this.saveSetting( name, value ? '1' : '0' );
+               }
+       } );
+
+       mw.libs.twoColConflict = mw.libs.twoColConflict || {};
+       mw.libs.twoColConflict.Settings = Settings;
+}( mediaWiki, jQuery ) );
diff --git a/modules/ext.TwoColConflict.init.js 
b/modules/ext.TwoColConflict.init.js
index 49ab9ff..1920124 100644
--- a/modules/ext.TwoColConflict.init.js
+++ b/modules/ext.TwoColConflict.init.js
@@ -1,5 +1,6 @@
 ( function ( mw, $ ) {
-       var autoScroll = new mw.libs.twoColConflict.AutoScroll(),
+       var settings = new mw.libs.twoColConflict.Settings(),
+               autoScroll = new mw.libs.twoColConflict.AutoScroll(),
                helpDialog = mw.libs.twoColConflict.HelpDialog,
                BaseVersionSelector = 
mw.libs.twoColConflict.BaseVersionSelector;
 
@@ -159,5 +160,10 @@
                } else {
                        adjustEditorColSpacing();
                }
+
+               if ( !settings.shouldHideHelpDialogue() ) {
+                       helpDialog.show();
+                       settings.setHideHelpDialogue( true );
+               }
        } );
 }( mediaWiki, jQuery ) );
diff --git a/tests/browser/features/base_selection.feature 
b/tests/browser/features/base_selection.feature
index afb8ec4..6167bd9 100644
--- a/tests/browser/features/base_selection.feature
+++ b/tests/browser/features/base_selection.feature
@@ -7,9 +7,9 @@
 
   Scenario: The base selection dialog shows with the correct preselection
     When I handle an edit conflict
+    And I have dismissed the help dialog
     Then The base version selections screen should show
     And The use currently published version option should be selected
-
 
   Scenario: Using the currently published version in the selection dialog 
shows that version
     When I go to the "TwoColConflict Test Page" page with content "I am a 
sentence."
@@ -17,6 +17,7 @@
     And Another user changes content of the "TwoColConflict Test Page" page to 
"I am a longer sentence than before."
     And I edit the page with "Adding some random content."
     And I save the edit
+    And I have dismissed the help dialog
     And I click the ok button in the base selection dialog
     Then The base version selections screen should hide
     And The editor should contain "I am a longer sentence than before."
@@ -27,6 +28,7 @@
     And Another user changes content of the "TwoColConflict Test Page" page to 
"I am a longer sentence than before."
     And I edit the page with "Adding some random content."
     And I save the edit
+    And I have dismissed the help dialog
     And I select the my text option in the base selection dialog
     And I click the ok button in the base selection dialog
     Then The base version selections screen should hide
diff --git a/tests/browser/features/filter_options.feature 
b/tests/browser/features/filter_options.feature
index 3c1bb7d..fcda18c 100644
--- a/tests/browser/features/filter_options.feature
+++ b/tests/browser/features/filter_options.feature
@@ -7,6 +7,7 @@
 
   Scenario: Hide common changes filter collapses common changes
     When I handle a multi line edit conflict
+    And I have dismissed the help dialog
     And I select the show unchanged text option
     Then The two column edit conflict screen should be shown
     And Section for full common changes should be there
@@ -14,6 +15,7 @@
 
   Scenario: Hide common changes when clicking a collapse changes button
     When I handle a multi line edit conflict
+    And I have dismissed the help dialog
     And I select the show unchanged text option
     And I click on a collapse changes button
     Then The two column edit conflict screen should be shown
@@ -23,6 +25,7 @@
 
   Scenario: Show hidden common changes when clicking an expand changes button
     When I handle a multi line edit conflict
+    And I have dismissed the help dialog
     And I select the hide unchanged text option
     And I click on an expand changes button
     Then The two column edit conflict screen should be shown
diff --git a/tests/browser/features/help.feature 
b/tests/browser/features/help.feature
index 25aa4bd..14b38ad 100644
--- a/tests/browser/features/help.feature
+++ b/tests/browser/features/help.feature
@@ -6,12 +6,17 @@
     And TwoColConflict is enabled as a beta feature
     And I handle an edit conflict
 
-  Scenario: Two column edit conflict tutorial shows
-    When I click on the show help button
+  Scenario: Two column edit conflict tutorial is present on first load
     Then The help dialog should be visible
 
+  Scenario: RevisionSlider tutorial is not present after it was dismissed once
+    When I have dismissed the help dialog
+    And I refresh the edit conflict page
+    And I dismiss the refresh dialogs
+    Then The help dialog should not be present
+
   Scenario: Two column edit conflict sequence works
-    When I click on the show help button
+    When The help dialog is visible
     And I have moved to the next step
     And I have moved to the next step
     And I have moved to the next step
diff --git a/tests/browser/features/support/pages/edit_conflict_page.rb 
b/tests/browser/features/support/pages/edit_conflict_page.rb
index c0cde8a..f34078d 100644
--- a/tests/browser/features/support/pages/edit_conflict_page.rb
+++ b/tests/browser/features/support/pages/edit_conflict_page.rb
@@ -49,4 +49,10 @@
   hidden_field(:twocolconflict_base_option,  name: 
'mw-twocolconflict-base-version')
   label(:twocolconflict_base_mine_label, css: 
'.mw-twocolconflict-base-dialog-radio label:nth-of-type(2)')
   link(:twocolconflict_base_submit, css: '.mw-twocolconflict-base-dialog 
.oo-ui-buttonElement-button')
+
+  def wait_for_help_dialog_to_hide
+    wait_until do
+      !twocolconflict_help_dialog_element.visible?
+    end
+  end
 end
diff --git a/tests/browser/features/support/step_definitions/common_steps.rb 
b/tests/browser/features/support/step_definitions/common_steps.rb
index 1b86a12..416d364 100644
--- a/tests/browser/features/support/step_definitions/common_steps.rb
+++ b/tests/browser/features/support/step_definitions/common_steps.rb
@@ -5,3 +5,13 @@
 Then(/^TwoColConflict is disabled as a beta feature$/) do
   visit(SpecialPreferencesPage).disable_twocolconflict
 end
+
+Given(/^I refresh the edit conflict page$/) do
+  on(EditConflictPage) do |page|
+    page.refresh
+  end
+end
+
+And(/^I dismiss the refresh dialogs$/) do
+  browser.alert.ok
+end
diff --git a/tests/browser/features/support/step_definitions/help_steps.rb 
b/tests/browser/features/support/step_definitions/help_steps.rb
index 71e65e3..6d7828e 100644
--- a/tests/browser/features/support/step_definitions/help_steps.rb
+++ b/tests/browser/features/support/step_definitions/help_steps.rb
@@ -27,6 +27,10 @@
   on(EditConflictPage).wait_for_help_dialog_to_hide
 end
 
+When(/^The help dialog is visible$/) do
+  step 'The help dialog should be visible'
+end
+
 Then(/^The help dialog should be visible/) do
   
expect(on(EditConflictPage).twocolconflict_help_dialog_element.when_present).to 
be_visible
 end

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6e3d90fd574209e7edd645c14a39a1b96695d461
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/TwoColConflict
Gerrit-Branch: master
Gerrit-Owner: Andrew-WMDE <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: WMDE-Fisch <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to