@@ -27,6 +27,35 @@ define([], function () {
2727 *
2828 */
2929 function init ( ) {
30+ const warningTab = document . getElementById ( 'warning-tab' ) ;
31+ if ( document . querySelectorAll ( '.var-pane-fail' ) . length ) {
32+ const varTab = document . getElementById ( 'variants-pane-warning' ) ;
33+ varTab . style . display = 'inline' ;
34+ warningTab . style . display = 'inline' ;
35+ }
36+ if ( document . querySelectorAll ( '.test-pane-fail' ) . length ) {
37+ const testTab = document . getElementById ( 'test-pane-warning' ) ;
38+ testTab . style . display = 'inline' ;
39+ warningTab . style . display = 'inline' ;
40+ }
41+ const variantCount = document . getElementById ( 'variant-count' ) . textContent ;
42+ const variantTab = document . getElementById ( 'variants-tab-label' ) ;
43+ variantTab . textContent = variantTab . textContent + ' ' + variantCount ;
44+ document . getElementById ( 'dashboard-tab-content' ) . style . display = 'block' ;
45+
46+ // Prevent page refresh loading old version.
47+ const url = new URL ( location ) ;
48+ if ( url . searchParams . get ( 'historic' ) ) {
49+ url . searchParams . delete ( 'historic' ) ;
50+ history . replaceState ( null , null , url ) ;
51+ } else {
52+ // Page reload will not reset dropdown. We have to do it manually.
53+ var options = document . querySelectorAll ( '.version-dropdown-option' ) ;
54+ for ( var i = 0 , l = options . length ; i < l ; i ++ ) {
55+ options [ i ] . selected = options [ i ] . defaultSelected ;
56+ }
57+ }
58+
3059 // Add simple client-side sorting for the first two columns.
3160 const variantsTable = document . getElementById ( 'deployed-variants-table' ) ;
3261 if ( ! variantsTable ) {
@@ -139,18 +168,6 @@ define([], function () {
139168 } ) ;
140169 } ) ;
141170 }
142-
143- const warningTab = document . getElementById ( 'warning-tab' ) ;
144- if ( document . querySelectorAll ( '.var-pane-fail' ) . length ) {
145- const varTab = document . getElementById ( 'variants-pane-warning' ) ;
146- varTab . style . display = 'inline' ;
147- warningTab . style . display = 'inline' ;
148- }
149- if ( document . querySelectorAll ( '.test-pane-fail' ) . length ) {
150- const testTab = document . getElementById ( 'test-pane-warning' ) ;
151- testTab . style . display = 'inline' ;
152- warningTab . style . display = 'inline' ;
153- }
154171 }
155172
156173 /** Export our entry point. */
0 commit comments