Skip to content

Commit e78c69a

Browse files
authored
Merge pull request #1155 from mikeller/add_expert_mode_to_firmware_flasher
Added expert mode to firmware flasher to hide unstable builds.
2 parents 2b51e2e + ae5603a commit e78c69a

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

locales/en/messages.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
"expertMode": {
5858
"message": "Enable Expert Mode"
5959
},
60+
"expertModeDescription": {
61+
"message": "Show unreleased and potentially unstable builds"
62+
},
6063
"permanentExpertMode": {
6164
"message": "Permanently enable Expert Mode"
6265
},
@@ -2323,10 +2326,10 @@
23232326
"message": "Baud Rate"
23242327
},
23252328
"firmwareFlasherShowDevelopmentReleases":{
2326-
"message": "Show unstable and additional releases"
2329+
"message": "Show unstable releases"
23272330
},
23282331
"firmwareFlasherShowDevelopmentReleasesDescription":{
2329-
"message": "Show Release-Candidates and Development Releases."
2332+
"message": "Show release candidates in addition to stable releases"
23302333
},
23312334
"firmwareFlasherOptionLoading": {
23322335
"message": "Loading ..."

src/js/tabs/firmware_flasher.js

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -227,17 +227,6 @@ TABS.firmware_flasher.initialize = function (callback) {
227227
}
228228
};
229229

230-
function showOrHideBuildTypeSelect() {
231-
var showDevReleases = $(this).is(':checked');
232-
233-
if (showDevReleases) {
234-
$('tr.build_type').show();
235-
} else {
236-
$('tr.build_type').hide();
237-
buildType_e.val(0).trigger('change');
238-
}
239-
}
240-
241230
var buildTypes = [
242231
{
243232
tag: 'firmwareFlasherOptionLabelBuildTypeRelease',
@@ -255,16 +244,48 @@ TABS.firmware_flasher.initialize = function (callback) {
255244
loader: () => self.jenkinsLoader.loadBuilds(job.name, buildJenkinsBoardOptions)
256245
};
257246
})
258-
259-
buildTypes = buildTypes.concat(ciBuildsTypes);
247+
var buildTypesToShow;
260248

261249
var buildType_e = $('select[name="build_type"]');
262-
buildTypes.forEach((build, index) => {
263-
buildType_e.append($("<option value='{0}' selected>{1}</option>".format(index, build.tag ? i18n.getMessage(build.tag) : build.title)))
264-
});
250+
function buildBuildTypeOptionsList() {
251+
buildType_e.empty();
252+
buildTypesToShow.forEach((build, index) => {
253+
buildType_e.append($("<option value='{0}' selected>{1}</option>".format(index, build.tag ? i18n.getMessage(build.tag) : build.title)))
254+
});
255+
}
256+
257+
function showOrHideBuildTypes() {
258+
var showExtraReleases = $(this).is(':checked');
259+
260+
if (showExtraReleases) {
261+
$('tr.build_type').show();
262+
$('tr.expert_mode').show();
263+
} else {
264+
$('tr.build_type').hide();
265+
$('tr.expert_mode').hide();
266+
buildType_e.val(0).trigger('change');
267+
}
268+
}
269+
270+
var globalExpertMode_e = $('input[name="expertModeCheckbox"]');
271+
function showOrHideBuildTypeSelect() {
272+
var expertModeChecked = $(this).is(':checked');
273+
274+
globalExpertMode_e.prop('checked', expertModeChecked);
275+
if (expertModeChecked) {
276+
buildTypesToShow = buildTypes.concat(ciBuildsTypes);
277+
buildBuildTypeOptionsList();
278+
} else {
279+
buildTypesToShow = buildTypes;
280+
buildBuildTypeOptionsList();
281+
buildType_e.val(0).trigger('change');
282+
}
283+
}
265284

266-
showOrHideBuildTypeSelect();
267-
$('input.show_development_releases').change(showOrHideBuildTypeSelect);
285+
var expertMode_e = $('.tab-firmware_flasher input.expert_mode');
286+
expertMode_e.prop('checked', globalExpertMode_e.is(':checked'));
287+
$('input.show_development_releases').change(showOrHideBuildTypes).change();
288+
expertMode_e.change(showOrHideBuildTypeSelect).change();
268289

269290
// translate to user-selected language
270291
i18n.localizePage();
@@ -282,7 +303,7 @@ TABS.firmware_flasher.initialize = function (callback) {
282303
.append($("<option value='0'>{0}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersion'))));
283304

284305
if (!GUI.connect_lock) {
285-
buildTypes[build_type].loader();
306+
buildTypesToShow[build_type].loader();
286307
}
287308

288309
chrome.storage.local.set({'selected_build_type': build_type});

src/tabs/firmware_flasher.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
</label></td>
1010
<td><span class="description" i18n="firmwareFlasherShowDevelopmentReleasesDescription"></span></td>
1111
</tr>
12+
<tr class="expert_mode option">
13+
<td><label><input class="expert_mode toggle" type="checkbox" /><span i18n="expertMode"></span>
14+
</label></td>
15+
<td><span class="description" i18n="expertModeDescription"></span></td>
16+
</tr>
1217
<tr class="build_type">
1318
<td>
1419
<select name="build_type">

0 commit comments

Comments
 (0)