Simplify Expert Mode (#3301)

master
Mark Haslinghuis 2023-02-02 20:26:45 +01:00 committed by GitHub
parent fc6bcc2bf9
commit 799b587ac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 43 additions and 67 deletions

View File

@ -90,10 +90,7 @@
"message": "Enable Expert Mode" "message": "Enable Expert Mode"
}, },
"expertModeDescription": { "expertModeDescription": {
"message": "Show development builds that are potentially unstable" "message": "Enable Expert Mode options"
},
"permanentExpertMode": {
"message": "Permanently enable Expert Mode"
}, },
"warningSettings": { "warningSettings": {
"message": "Show warnings" "message": "Show warnings"

View File

@ -539,14 +539,14 @@ function startProcess() {
$("#showlog").trigger('click'); $("#showlog").trigger('click');
} }
result = getConfig('permanentExpertMode'); result = getConfig('expertMode').expertMode ?? false;
const expertModeCheckbox = 'input[name="expertModeCheckbox"]';
if (result.permanentExpertMode) { const expertModeCheckbox = $('input[name="expertModeCheckbox"]');
$(expertModeCheckbox).prop('checked', true); expertModeCheckbox.prop('checked', result).trigger('change');
}
expertModeCheckbox.on("change", () => {
const checked = expertModeCheckbox.is(':checked');
$(expertModeCheckbox).on("change", () => {
const checked = $(expertModeCheckbox).is(':checked');
checkSetupAnalytics(function (analyticsService) { checkSetupAnalytics(function (analyticsService) {
analyticsService.setDimension(analyticsService.DIMENSIONS.CONFIGURATOR_EXPERT_MODE, checked ? 'On' : 'Off'); analyticsService.setDimension(analyticsService.DIMENSIONS.CONFIGURATOR_EXPERT_MODE, checked ? 'On' : 'Off');
}); });
@ -558,9 +558,9 @@ function startProcess() {
if (GUI.active_tab) { if (GUI.active_tab) {
TABS[GUI.active_tab]?.expertModeChanged?.(checked); TABS[GUI.active_tab]?.expertModeChanged?.(checked);
} }
});
$(expertModeCheckbox).trigger("change"); setConfig({'expertMode': checked});
});
result = getConfig('cliAutoComplete'); result = getConfig('cliAutoComplete');
CliAutoComplete.setEnabled(typeof result.cliAutoComplete === "undefined" || result.cliAutoComplete); // On by default CliAutoComplete.setEnabled(typeof result.cliAutoComplete === "undefined" || result.cliAutoComplete); // On by default

View File

@ -259,10 +259,8 @@ function onOpen(openInfo) {
} }
// reset expert mode // reset expert mode
result = getConfig('permanentExpertMode'); result = getConfig('expertMode')?.expertMode ?? false;
if (result.permanentExpertMode) { $('input[name="expertModeCheckbox"]').prop('checked', result).trigger('change');
$('input[name="expertModeCheckbox"]').prop('checked', result.permanentExpertMode).trigger('change');
}
serial.onReceive.addListener(read_serial); serial.onReceive.addListener(read_serial);
setConnectionTimeout(); setConnectionTimeout();

View File

@ -221,35 +221,39 @@ firmware_flasher.initialize = function (callback) {
if (showExtraReleases) { if (showExtraReleases) {
$('tr.build_type').show(); $('tr.build_type').show();
$('tr.expert_mode').show();
} else { } else {
$('tr.build_type').hide(); $('tr.build_type').hide();
$('tr.expert_mode').hide();
buildType_e.val(0).trigger('change'); buildType_e.val(0).trigger('change');
} }
} }
const globalExpertMode_e = $('input[name="expertModeCheckbox"]');
function showOrHideExpertMode() { function showOrHideExpertMode() {
const expertModeChecked = $(this).is(':checked'); const expertModeChecked = $(this).is(':checked');
globalExpertMode_e.prop('checked', expertModeChecked).trigger('change');
if (expertModeChecked) { if (expertModeChecked) {
buildTypesToShow = buildTypes; buildTypesToShow = buildTypes;
} else { } else {
buildTypesToShow = buildTypes.slice(0,2); buildTypesToShow = buildTypes.slice(0,2);
} }
buildBuildTypeOptionsList(); buildBuildTypeOptionsList();
buildType_e.val(0).trigger('change'); buildType_e.val(0).trigger('change');
setConfig({'selected_expert_mode': expertModeChecked}); setTimeout(() => {
$('tr.expertOptions').toggle(expertModeChecked);
$('div.expertOptions').toggle(expertModeChecked);
}, 0);
setConfig({'expertMode': expertModeChecked});
} }
const expertMode_e = $('.tab-firmware_flasher input.expert_mode'); const expertMode_e = $('.tab-firmware_flasher input.expert_mode');
const expertMode = getConfig('selected_expert_mode'); const expertMode = getConfig('expertMode').expertMode;
expertMode_e.prop('checked', expertMode.selected_expert_mode ?? false);
expertMode_e.prop('checked', expertMode);
expertMode_e.on('change', showOrHideExpertMode).trigger('change');
$('input.show_development_releases').change(showOrHideBuildTypes).change(); $('input.show_development_releases').change(showOrHideBuildTypes).change();
expertMode_e.change(showOrHideExpertMode).change();
// translate to user-selected language // translate to user-selected language
i18n.localizePage(); i18n.localizePage();
@ -302,8 +306,6 @@ firmware_flasher.initialize = function (callback) {
const expertMode = $('.tab-firmware_flasher input.expert_mode').is(':checked'); const expertMode = $('.tab-firmware_flasher input.expert_mode').is(':checked');
if (expertMode) { if (expertMode) {
$('div.expertOptions').show();
if (response.releaseType === 'Unstable') { if (response.releaseType === 'Unstable') {
self.releaseLoader.loadCommits(response.release, (commits) => { self.releaseLoader.loadCommits(response.release, (commits) => {
const select_e = $('select[name="commits"]'); const select_e = $('select[name="commits"]');
@ -317,9 +319,9 @@ firmware_flasher.initialize = function (callback) {
} else { } else {
$('div.commitSelection').hide(); $('div.commitSelection').hide();
} }
} else {
$('div.expertOptions').hide();
} }
$('div.expertOptions').toggle(expertMode);
} }
if (response.configuration && !self.isConfigLocal) { if (response.configuration && !self.isConfigLocal) {
@ -489,11 +491,12 @@ firmware_flasher.initialize = function (callback) {
} }
const portPickerElement = $('div#port-picker #port'); const portPickerElement = $('div#port-picker #port');
function flashFirmware(firmware) { function flashFirmware(firmware) {
const options = {}; const options = {};
let eraseAll = false; let eraseAll = false;
if ($('input.erase_chip').is(':checked')) { if ($('input.erase_chip').is(':checked') || $('.tab-firmware_flasher input.expert_mode').not(':checked')) {
options.erase_chip = true; options.erase_chip = true;
eraseAll = true; eraseAll = true;

View File

@ -16,7 +16,6 @@ options.initialize = function (callback) {
$('#content').load("./tabs/options.html", function () { $('#content').load("./tabs/options.html", function () {
i18n.localizePage(); i18n.localizePage();
TABS.options.initPermanentExpertMode();
TABS.options.initRememberLastTab(); TABS.options.initRememberLastTab();
TABS.options.initCheckForConfiguratorUnstableVersions(); TABS.options.initCheckForConfiguratorUnstableVersions();
TABS.options.initAnalyticsOptOut(); TABS.options.initAnalyticsOptOut();
@ -50,21 +49,6 @@ options.initShowWarnings = function () {
}).change(); }).change();
}; };
options.initPermanentExpertMode = function () {
const result = getConfig('permanentExpertMode');
if (result.permanentExpertMode) {
$('div.permanentExpertMode input').prop('checked', true);
}
$('div.permanentExpertMode input').change(function () {
const checked = $(this).is(':checked');
setConfig({'permanentExpertMode': checked});
$('input[name="expertModeCheckbox"]').prop('checked', checked).change();
}).change();
};
options.initRememberLastTab = function () { options.initRememberLastTab = function () {
const result = getConfig('rememberLastTab'); const result = getConfig('rememberLastTab');
$('div.rememberLastTab input') $('div.rememberLastTab input')

View File

@ -8,17 +8,6 @@
<div class="spacer" style="margin-bottom: 10px;"> <div class="spacer" style="margin-bottom: 10px;">
<div class="margin-bottom"> <div class="margin-bottom">
<table class="cf_table" style="margin-top: 10px;"> <table class="cf_table" style="margin-top: 10px;">
<tr class="option">
<td>
<label>
<input class="show_development_releases toggle" type="checkbox" />
<span i18n="firmwareFlasherShowDevelopmentReleases"></span>
</label>
<div class="helpicon cf_tip_wide" i18n_title="firmwareFlasherShowDevelopmentReleasesDescription"></div>
</td>
<td>
</td>
</tr>
<tr class="expert_mode option"> <tr class="expert_mode option">
<td> <td>
<label> <label>
@ -30,6 +19,17 @@
<td> <td>
</td> </td>
</tr> </tr>
<tr class="option">
<td>
<label>
<input class="show_development_releases toggle" type="checkbox" />
<span i18n="firmwareFlasherShowDevelopmentReleases"></span>
</label>
<div class="helpicon cf_tip_wide" i18n_title="firmwareFlasherShowDevelopmentReleasesDescription"></div>
</td>
<td>
</td>
</tr>
<tr class="build_type"> <tr class="build_type">
<td> <td>
<select name="build_type"> <select name="build_type">
@ -64,7 +64,7 @@
<td> <td>
</td> </td>
</tr> </tr>
<tr> <tr class="expertOptions option">
<td> <td>
<label> <label>
<input class="updating toggle" type="checkbox" /> <input class="updating toggle" type="checkbox" />
@ -75,7 +75,7 @@
<td> <td>
</td> </td>
</tr> </tr>
<tr class="option flash_on_connect_wrapper"> <tr class="expertOptions option flash_on_connect_wrapper">
<td> <td>
<label> <label>
<input class="flash_on_connect toggle" type="checkbox" /> <input class="flash_on_connect toggle" type="checkbox" />
@ -86,7 +86,7 @@
<td> <td>
</td> </td>
</tr> </tr>
<tr class="option"> <tr class="expertOptions option">
<td> <td>
<label> <label>
<input class="erase_chip toggle" type="checkbox" /> <input class="erase_chip toggle" type="checkbox" />
@ -97,7 +97,7 @@
<td> <td>
</td> </td>
</tr> </tr>
<tr class="option manual_baud_rate noboarder"> <tr class="expertOptions option manual_baud_rate noboarder">
<td> <td>
<label> <label>
<input class="flash_manual_baud toggle" type="checkbox" /> <input class="flash_manual_baud toggle" type="checkbox" />

View File

@ -5,12 +5,6 @@
<div class="spacer_box_title" i18n="tabOptions"></div> <div class="spacer_box_title" i18n="tabOptions"></div>
</div> </div>
<div class="spacer"> <div class="spacer">
<div class="permanentExpertMode margin-bottom">
<div>
<input type="checkbox" class="toggle" />
</div>
<span class="freelabel" i18n="permanentExpertMode"></span>
</div>
<div class="checkForConfiguratorUnstableVersions margin-bottom"> <div class="checkForConfiguratorUnstableVersions margin-bottom">
<div> <div>
<input type="checkbox" class="toggle" /> <input type="checkbox" class="toggle" />