From 8a19709832c998a872561f8d6cb7384e2808c8d4 Mon Sep 17 00:00:00 2001 From: Peter Makra <6892971+mcraa@users.noreply.github.com> Date: Fri, 12 Nov 2021 10:43:48 +0100 Subject: [PATCH] patch: add hw-diag button to settings --- lib/gui/app/components/settings/settings.tsx | 78 ++++++++++++++++++-- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/lib/gui/app/components/settings/settings.tsx b/lib/gui/app/components/settings/settings.tsx index 6ade247b..e4c9bf15 100644 --- a/lib/gui/app/components/settings/settings.tsx +++ b/lib/gui/app/components/settings/settings.tsx @@ -18,7 +18,9 @@ import GithubSvg from '@fortawesome/fontawesome-free/svgs/brands/github.svg'; import * as _ from 'lodash'; import * as os from 'os'; import * as React from 'react'; -import { Flex, Checkbox, Txt } from 'rendition'; +import { Box, Button, Flex, Checkbox, Txt } from 'rendition'; +import { faTimes } from '@fortawesome/free-solid-svg-icons' + import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { version, packageType } from '../../../../../package.json'; import * as settings from '../../models/settings'; @@ -66,8 +68,12 @@ interface SettingsModalProps { toggleModal: (value: boolean) => void; } -export function SettingsModal({ toggleModal }: SettingsModalProps) { +export function SettingsModal({ toggleModal }: SettingsModalProps): any { const [settingsList, setCurrentSettingsList] = React.useState([]); + const [showDiagScreen, setShowDiagScreen] = React.useState(false); + const [showDiagButton, setShowDiagButton] = React.useState(false); + let diagClickCount = 0; + React.useEffect(() => { (async () => { if (settingsList.length === 0) { @@ -107,6 +113,22 @@ export function SettingsModal({ toggleModal }: SettingsModalProps) { return; }; + const closeDiagFrame = () => { + setShowDiagScreen(false); + } + + const openDiagFrame = () => { + setShowDiagScreen(true); + } + + const prepareDiag = () => { + if (diagClickCount > 5) { + setShowDiagButton(true) + } + + ++diagClickCount; + } + return ( + onClick={() => { openExternal( 'https://github.com/balena-io/etcher/blob/master/CHANGELOG.md', - ) + ); + prepareDiag() + } } > - {version} + {version} + {showDiagButton ? + + : <>} + + {showDiagScreen ? <> +