mirror of
https://github.com/balena-io/etcher.git
synced 2025-07-29 22:26:32 +00:00
patch: Show diag buttons if container available
Change-Type: patch
This commit is contained in:
parent
71c5aadeaa
commit
762b51970f
@ -72,7 +72,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps): any {
|
|||||||
const [settingsList, setCurrentSettingsList] = React.useState<Setting[]>([]);
|
const [settingsList, setCurrentSettingsList] = React.useState<Setting[]>([]);
|
||||||
const [showDiagScreen, setShowDiagScreen] = React.useState<Boolean>(false);
|
const [showDiagScreen, setShowDiagScreen] = React.useState<Boolean>(false);
|
||||||
const [showDiagButton, setShowDiagButton] = React.useState<Boolean>(false);
|
const [showDiagButton, setShowDiagButton] = React.useState<Boolean>(false);
|
||||||
let diagClickCount = 0;
|
const [currentSettings, setCurrentSettings] = React.useState<_.Dictionary<boolean>>({});
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
@ -81,9 +81,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps): any {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
const [currentSettings, setCurrentSettings] = React.useState<
|
|
||||||
_.Dictionary<boolean>
|
|
||||||
>({});
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (_.isEmpty(currentSettings)) {
|
if (_.isEmpty(currentSettings)) {
|
||||||
@ -92,6 +90,19 @@ export function SettingsModal({ toggleModal }: SettingsModalProps): any {
|
|||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
(async() => {
|
||||||
|
try {
|
||||||
|
let result = await fetch('http://localhost:3000/api/ping')
|
||||||
|
if (result.ok) {
|
||||||
|
setShowDiagButton(true)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// no diag container
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const toggleSetting = async (
|
const toggleSetting = async (
|
||||||
setting: string,
|
setting: string,
|
||||||
options?: Setting['options'],
|
options?: Setting['options'],
|
||||||
@ -121,12 +132,8 @@ export function SettingsModal({ toggleModal }: SettingsModalProps): any {
|
|||||||
setShowDiagScreen(true);
|
setShowDiagScreen(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const prepareDiag = () => {
|
const removeDiag = async () => {
|
||||||
if (diagClickCount > 5) {
|
// TODO
|
||||||
setShowDiagButton(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
++diagClickCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -165,7 +172,6 @@ export function SettingsModal({ toggleModal }: SettingsModalProps): any {
|
|||||||
openExternal(
|
openExternal(
|
||||||
'https://github.com/balena-io/etcher/blob/master/CHANGELOG.md',
|
'https://github.com/balena-io/etcher/blob/master/CHANGELOG.md',
|
||||||
);
|
);
|
||||||
prepareDiag()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@ -178,6 +184,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps): any {
|
|||||||
</Flex>
|
</Flex>
|
||||||
{showDiagButton ? <Box>
|
{showDiagButton ? <Box>
|
||||||
<Button primary onClick={() => openDiagFrame()}>Open Diagnostics</Button>
|
<Button primary onClick={() => openDiagFrame()}>Open Diagnostics</Button>
|
||||||
|
<Button danger onClick={() => removeDiag()}>Remove container</Button>
|
||||||
</Box> : <></>}
|
</Box> : <></>}
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
@ -201,7 +208,7 @@ export function SettingsModal({ toggleModal }: SettingsModalProps): any {
|
|||||||
/>
|
/>
|
||||||
<iframe
|
<iframe
|
||||||
className="App-frame"
|
className="App-frame"
|
||||||
src={`http://localhost:8000`}
|
src={`http://localhost:3000/diagsteps/start`}
|
||||||
title='screen'
|
title='screen'
|
||||||
key="screen-frame"
|
key="screen-frame"
|
||||||
style={{
|
style={{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user