add setting to flash current user program

This commit is contained in:
David Lechner
2021-01-14 18:03:04 -06:00
parent 9ee24d0b0c
commit f4cb69f995
8 changed files with 103 additions and 6 deletions
+21
View File
@@ -20,12 +20,14 @@ type StateProps = {
open: boolean;
showDocs: boolean;
darkMode: boolean;
flashCurrentProgram: boolean;
};
type DispatchProps = {
onClose: () => void;
onShowDocsChanged: (checked: boolean) => void;
onDarkModeChanged: (checked: boolean) => void;
onFlashCurrentProgramChanged: (checked: boolean) => void;
};
type SettingsProps = StateProps & DispatchProps & WithI18nProps;
@@ -40,6 +42,8 @@ class SettingsDrawer extends React.PureComponent<SettingsProps> {
onShowDocsChanged,
darkMode,
onDarkModeChanged,
flashCurrentProgram,
onFlashCurrentProgramChanged,
} = this.props;
return (
<Drawer
@@ -85,6 +89,20 @@ class SettingsDrawer extends React.PureComponent<SettingsProps> {
}
/>
</FormGroup>
<FormGroup label={i18n.translate(SettingsStringId.FirmwareTitle)}>
<Switch
label={i18n.translate(
SettingsStringId.FirmwareCurrentProgramLabel,
)}
large={true}
checked={flashCurrentProgram}
onChange={(e) =>
onFlashCurrentProgramChanged(
(e.target as HTMLInputElement).checked,
)
}
/>
</FormGroup>
</div>
</Drawer>
);
@@ -95,6 +113,7 @@ const mapStateToProps = (state: RootState): StateProps => ({
open: state.app.showSettings,
showDocs: state.settings.showDocs,
darkMode: state.settings.darkMode,
flashCurrentProgram: state.settings.flashCurrentProgram,
});
const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({
@@ -103,6 +122,8 @@ const mapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({
dispatch(setBoolean(SettingId.ShowDocs, checked)),
onDarkModeChanged: (checked): Action =>
dispatch(setBoolean(SettingId.DarkMode, checked)),
onFlashCurrentProgramChanged: (checked): Action =>
dispatch(setBoolean(SettingId.FlashCurrentProgram, checked)),
});
export default connect(
+6
View File
@@ -12,6 +12,12 @@
"zoom": {
"help": "Use {in} and {out} to zoom."
}
},
"firmware": {
"title": "Firmware",
"flash-current-program": {
"label": "Flash my program"
}
}
}
}
+2
View File
@@ -9,4 +9,6 @@ export enum SettingsStringId {
AppearanceDocumentationLabel = 'settings.appearance.documentation.label',
AppearanceDarkModeLabel = 'settings.appearance.dark-mode.label',
AppearanceZoomHelp = 'settings.appearance.zoom.help',
FirmwareTitle = 'settings.firmware.title',
FirmwareCurrentProgramLabel = 'settings.firmware.flash-current-program.label',
}
+1 -1
View File
@@ -3,7 +3,7 @@
// Custom styling for the Settings* controls.
.pb-settings {
.pb-settings .bp3-form-group {
margin: 25px;
}