From bec8b471563e682927b9f3b99bfa7e6f65be9058 Mon Sep 17 00:00:00 2001 From: Allen Bai Date: Jan 20 2020 19:24:37 +0000 Subject: [PATCH 1/2] coreos-download: fix navbar and stream dropdown Fixes a bug that when the page re-renders, the navbar and stream selection dropdown are not consistent with the content shown in the main content section. To reproduce, select a platform in the navbar and select a different stream from dropdown. When the page re-renders, while the main content remains the same as user selected previously, the selected dropdown and navbar are refreshed with default values. The expected behaviour is that the refreshed value is consistent with the content selected by user. Signed-off-by: Allen Bai --- diff --git a/sites/static/js/coreos-download.js b/sites/static/js/coreos-download.js index 4c57436..3ee7e03 100644 --- a/sites/static/js/coreos-download.js +++ b/sites/static/js/coreos-download.js @@ -149,15 +149,15 @@ var coreos_download_app = new Vue({ }, getNavbar: function(h) { cloud_icon = h('i', { class: "fas fa-cloud mr-2" }) - nav_cloud_launchable_btn = h('button', { class: "nav-link active col-12 h-100 overflow-hidden", attrs: { "data-toggle": "tab" }, on: { click: this.toggleHidden } }, [ cloud_icon, tabInnerText.cloud_launchable ]); + nav_cloud_launchable_btn = h('button', { class: "nav-link col-12 h-100 overflow-hidden".concat(this.shownId === IdPool.cloud_launchable ? " active" : ""), attrs: { "data-toggle": "tab" }, on: { click: this.toggleHidden } }, [ cloud_icon, tabInnerText.cloud_launchable ]); nav_cloud_launchable = h('li', { class: "nav-item col-4" }, [ nav_cloud_launchable_btn ]); server_icon = h('i', { class: "fas fa-server mr-2" }) - nav_metal_virt_btn = h('button', { class: "nav-link col-12 h-100 overflow-hidden", attrs: { "data-toggle": "tab" }, on: { click: this.toggleHidden } }, [ server_icon, tabInnerText.metal_virt ]); + nav_metal_virt_btn = h('button', { class: "nav-link col-12 h-100 overflow-hidden".concat(this.shownId === IdPool.metal_virt ? " active" : ""), attrs: { "data-toggle": "tab" }, on: { click: this.toggleHidden } }, [ server_icon, tabInnerText.metal_virt ]); nav_metal_virt = h('li', { class: "nav-item col-4" }, [ nav_metal_virt_btn ]); cloud_upload_icon = h('i', { class: "fas fa-cloud-upload-alt mr-2" }) - nav_cloud_operator_btn = h('button', { class: "nav-link col-12 h-100 overflow-hidden", attrs: { "data-toggle": "tab" }, on: { click: this.toggleHidden } }, [ cloud_upload_icon, tabInnerText.cloud_operator ]); + nav_cloud_operator_btn = h('button', { class: "nav-link col-12 h-100 overflow-hidden".concat(this.shownId === IdPool.cloud_operator ? " active" : ""), attrs: { "data-toggle": "tab" }, on: { click: this.toggleHidden } }, [ cloud_upload_icon, tabInnerText.cloud_operator ]); nav_cloud_operator = h('li', { class: "nav-item col-4" }, [ nav_cloud_operator_btn ]); navbar = h('ul', { class: "nav nav-tabs" }, [ nav_cloud_launchable, nav_metal_virt, nav_cloud_operator ]); @@ -166,8 +166,8 @@ var coreos_download_app = new Vue({ // Add dropdown options of streams getStreamName: function(h) { if (this.streamData === null) return; - option_default = h('option', { attrs: { value: "stable", selected: "selected" }}, "stable"); - option_testing = h('option', { attrs: { value: "testing" }}, "testing"); + option_default = h('option', { attrs: { value: "stable", selected: this.stream === "stable" ? "selected" : null }}, "stable"); + option_testing = h('option', { attrs: { value: "testing", selected: this.stream === "testing" ? "selected" : null }}, "testing"); selectOptions = h('select', { class: "mx-1", on: { From 0fccbd14f51589621ad3333c46276edffcc08f28 Mon Sep 17 00:00:00 2001 From: Allen Bai Date: Jan 20 2020 19:31:35 +0000 Subject: [PATCH 2/2] coreos-download: rename option_default to option_stable Signed-off-by: Allen Bai --- diff --git a/sites/static/js/coreos-download.js b/sites/static/js/coreos-download.js index 3ee7e03..c55d60e 100644 --- a/sites/static/js/coreos-download.js +++ b/sites/static/js/coreos-download.js @@ -166,7 +166,7 @@ var coreos_download_app = new Vue({ // Add dropdown options of streams getStreamName: function(h) { if (this.streamData === null) return; - option_default = h('option', { attrs: { value: "stable", selected: this.stream === "stable" ? "selected" : null }}, "stable"); + option_stable = h('option', { attrs: { value: "stable", selected: this.stream === "stable" ? "selected" : null }}, "stable"); option_testing = h('option', { attrs: { value: "testing", selected: this.stream === "testing" ? "selected" : null }}, "testing"); selectOptions = h('select', { class: "mx-1", @@ -176,7 +176,7 @@ var coreos_download_app = new Vue({ } } }, [ - option_default, + option_stable, option_testing ]); streamName = h('p', {}, [