jenkins-bot has submitted this change and it was merged. Change subject: Set suggestions as active tab for new users ......................................................................
Set suggestions as active tab for new users A simple check of whether the URL contains campaign parameter and not having a previous CX source language is done. Checking if there is an ongoing translation is the perfect way to determine the active tab. But that is an asynchrounous api call. Swapping the tabs few seconds after page load does not look good. Bug: T112822 Change-Id: I0a4bae9bb03dea2c6f66ccf3eb43e8b4db9e7a64 --- M modules/dashboard/ext.cx.dashboard.js 1 file changed, 29 insertions(+), 4 deletions(-) Approvals: Nikerabbit: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/dashboard/ext.cx.dashboard.js b/modules/dashboard/ext.cx.dashboard.js index b8acc7e..abd0165 100644 --- a/modules/dashboard/ext.cx.dashboard.js +++ b/modules/dashboard/ext.cx.dashboard.js @@ -42,11 +42,29 @@ * Initialize the components */ CXDashboard.prototype.initLists = function () { + var storedSourceLanguage, + query = new mw.Uri().query; + this.renderTranslations(); if ( mw.config.get( 'wgContentTranslationEnableSuggestions' ) ) { this.renderTranslationSuggestions(); + } else { + return; } - this.setActiveList( 'draft' ); + + try { + storedSourceLanguage = localStorage.getItem( 'cxSourceLanguage' ); + } catch ( e ) { + // Local storage disabled? + } + + // Show suggestions tab by default when user is coming from a campaign + // entry point and does not have any previous cx source language. + if ( query.campaign && !storedSourceLanguage ) { + this.setActiveList( 'suggestions' ); + } else { + this.setActiveList( 'draft' ); + } }; /** @@ -164,12 +182,12 @@ if ( mw.config.get( 'wgContentTranslationEnableSuggestions' ) ) { $filterTabs.push( $( '<span>' ) - .addClass( 'cx-filter cx-suggestions mw-ui-input' ) + .addClass( 'cx-filter cx-filter--suggestions mw-ui-input' ) .text( mw.msg( 'cx-translation-filter-suggested-translations' ) ) ); } $filterTabs.push( $( '<span>' ) - .addClass( 'cx-filter cx-filter--draft cx-filter--selected mw-ui-input' ) + .addClass( 'cx-filter cx-filter--draft mw-ui-input' ) .text( mw.msg( 'cx-translation-filter-draft-translations' ) ) ); $filterTabs.push( $( '<span>' ) @@ -219,7 +237,14 @@ CXDashboard.prototype.setActiveList = function ( type ) { var self = this; + this.activeList = type; + this.$filter + .find( '.cx-filter--selected' ) + .removeClass( 'cx-filter--selected' ); + this.$filter + .find( '.cx-filter--' + type ) + .addClass( 'cx-filter--selected' ); $.each( this.lists, function ( name, list ) { if ( name === type ) { list.show(); @@ -255,7 +280,7 @@ self.setActiveList( 'draft' ); } else if ( $filter.is( '.cx-filter--published' ) ) { self.setActiveList( 'published' ); - } else if ( $filter.is( '.cx-suggestions' ) ) { + } else if ( $filter.is( '.cx-filter--suggestions' ) ) { self.setActiveList( 'suggestions' ); } } ); -- To view, visit https://gerrit.wikimedia.org/r/244114 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0a4bae9bb03dea2c6f66ccf3eb43e8b4db9e7a64 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/ContentTranslation Gerrit-Branch: master Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Santhosh <santhosh.thottin...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits