Skip to content

Commit

Permalink
SetupDoctorScreen non-modal option
Browse files Browse the repository at this point in the history
Summary:
The Setup Doctor screen was hard-set into a modal window. Instead, make this an optional that defaults to yes.

This will allow the usage of the screen in non-modal container.

Reviewed By: antonk52

Differential Revision: D47629528

fbshipit-source-id: c5248df1358f1b14775b90c9bf12fd63b8885caf
  • Loading branch information
lblasa authored and facebook-github-bot committed Jul 20, 2023
1 parent f566fed commit 2958d9d
Showing 1 changed file with 39 additions and 8 deletions.
47 changes: 39 additions & 8 deletions desktop/flipper-ui-core/src/sandy-chrome/SetupDoctorScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@

import React, {useEffect, useCallback, useMemo, useState} from 'react';
import {useDispatch, useStore} from '../utils/useStore';
import {Typography, Collapse, Button, Modal, Checkbox, Alert} from 'antd';
import {
Typography,
Collapse,
Button,
Modal,
Checkbox,
Alert,
Space,
} from 'antd';
import {
CheckCircleFilled,
CloseCircleFilled,
Expand Down Expand Up @@ -167,6 +175,7 @@ const FooterContainer = styled(Layout.Horizontal)({
});

function SetupDoctorFooter(props: {
closable: boolean;
onClose: () => void;
onRerunDoctor: () => Promise<void>;
showAcknowledgeCheckbox: boolean;
Expand All @@ -190,7 +199,7 @@ function SetupDoctorFooter(props: {
<Layout.Container />
)}
<Layout.Horizontal>
<Button onClick={props.onClose}>Close</Button>
{props.closable && <Button onClick={props.onClose}>Close</Button>}
<Button
type="primary"
onClick={() => props.onRerunDoctor()}
Expand All @@ -202,10 +211,17 @@ function SetupDoctorFooter(props: {
);
}

export default function SetupDoctorScreen(props: {
type Props = {
visible: boolean;
modal?: boolean;
onClose: () => void;
}) {
};

export default function SetupDoctorScreen({
visible,
modal = true,
onClose,
}: Props) {
const healthcheckReport = useStore(
(state) => state.healthchecks.healthcheckReport,
);
Expand Down Expand Up @@ -234,8 +250,8 @@ export default function SetupDoctorScreen(props: {
reportUsage('doctor:report:closed:notAcknowledged');
dispatch(resetAcknowledgedProblems());
}
props.onClose();
}, [healthcheckReport.result, acknowlodgeProblem, props, dispatch]);
onClose();
}, [healthcheckReport.result, acknowlodgeProblem, onClose, dispatch]);
const runDoctor = useCallback(async () => {
await runHealthchecks({
settings,
Expand All @@ -255,15 +271,16 @@ export default function SetupDoctorScreen(props: {
runDoctor();
}, []); // eslint-disable-line react-hooks/exhaustive-deps

return (
return modal ? (
<Modal
centered
width={570}
title="Setup Doctor"
visible={props.visible}
visible={visible}
destroyOnClose
footer={
<SetupDoctorFooter
closable
onClose={onCloseModal}
onRerunDoctor={runDoctor}
showAcknowledgeCheckbox={hasProblem}
Expand All @@ -275,5 +292,19 @@ export default function SetupDoctorScreen(props: {
onCancel={onCloseModal}>
<HealthCheckList report={healthcheckReport} />
</Modal>
) : (
<Layout.Container pad grow>
<HealthCheckList report={healthcheckReport} />
<Space direction="vertical" size="middle" />
<SetupDoctorFooter
closable={false}
onClose={onCloseModal}
onRerunDoctor={runDoctor}
showAcknowledgeCheckbox={hasProblem}
acknowledgeCheck={acknowlodgeProblem}
onAcknowledgeCheck={(checked) => setAcknowlodgeProblem(checked)}
disableRerun={healthcheckReport.result.status === 'IN_PROGRESS'}
/>
</Layout.Container>
);
}

0 comments on commit 2958d9d

Please sign in to comment.