Move useRefetchContext to Dialog
Signed-off-by: Erik Engervall <erik.engervall@gmail.com>
This commit is contained in:
@@ -15,11 +15,17 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { DialogTitle, Dialog as MaterialDialog } from '@material-ui/core';
|
||||
import {
|
||||
Button,
|
||||
Dialog as MaterialDialog,
|
||||
DialogActions,
|
||||
DialogTitle,
|
||||
} from '@material-ui/core';
|
||||
|
||||
import { LinearProgressWithLabel } from './LinearProgressWithLabel';
|
||||
import { ResponseStep } from '../types/types';
|
||||
import { ResponseStepList } from './ResponseStepList/ResponseStepList';
|
||||
import { useRefetchContext } from '../contexts/RefetchContext';
|
||||
|
||||
interface DialogProps {
|
||||
progress: number;
|
||||
@@ -27,12 +33,27 @@ interface DialogProps {
|
||||
title: string;
|
||||
}
|
||||
|
||||
export const Dialog = ({ progress, responseSteps, title }: DialogProps) => (
|
||||
<MaterialDialog open maxWidth="md" fullWidth>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
export const Dialog = ({ progress, responseSteps, title }: DialogProps) => {
|
||||
const { setRefetchTrigger } = useRefetchContext();
|
||||
|
||||
<LinearProgressWithLabel value={progress} />
|
||||
return (
|
||||
<MaterialDialog open maxWidth="md" fullWidth>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
|
||||
<ResponseStepList responseSteps={responseSteps} />
|
||||
</MaterialDialog>
|
||||
);
|
||||
<ResponseStepList responseSteps={responseSteps} />
|
||||
|
||||
<LinearProgressWithLabel value={progress} />
|
||||
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setRefetchTrigger(Date.now())}
|
||||
color="primary"
|
||||
variant="contained"
|
||||
size="large"
|
||||
>
|
||||
Ok
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</MaterialDialog>
|
||||
);
|
||||
};
|
||||
|
||||
-4
@@ -20,10 +20,6 @@ import { render } from '@testing-library/react';
|
||||
import { ResponseStepList } from './ResponseStepList';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
|
||||
jest.mock('../../contexts/RefetchContext', () => ({
|
||||
useRefetchContext: () => jest.fn(),
|
||||
}));
|
||||
|
||||
describe('ResponseStepList', () => {
|
||||
it('should render loading state when loading', () => {
|
||||
const { getByTestId } = render(
|
||||
|
||||
+1
-14
@@ -15,13 +15,12 @@
|
||||
*/
|
||||
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
import { Button, DialogActions, DialogContent, List } from '@material-ui/core';
|
||||
import { DialogContent, List } from '@material-ui/core';
|
||||
|
||||
import { CenteredCircularProgress } from '../CenteredCircularProgress';
|
||||
import { ResponseStep } from '../../types/types';
|
||||
import { ResponseStepListItem } from './ResponseStepListItem';
|
||||
import { TEST_IDS } from '../../test-helpers/test-ids';
|
||||
import { useRefetchContext } from '../../contexts/RefetchContext';
|
||||
|
||||
interface ResponseStepListProps {
|
||||
responseSteps: (ResponseStep | undefined)[];
|
||||
@@ -38,8 +37,6 @@ export const ResponseStepList = ({
|
||||
denseList = false,
|
||||
children,
|
||||
}: PropsWithChildren<ResponseStepListProps>) => {
|
||||
const { setRefetchTrigger } = useRefetchContext();
|
||||
|
||||
return (
|
||||
<>
|
||||
{loading || responseSteps.length === 0 ? (
|
||||
@@ -72,16 +69,6 @@ export const ResponseStepList = ({
|
||||
|
||||
{children}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
onClick={() => setRefetchTrigger(Date.now())}
|
||||
color="primary"
|
||||
variant="contained"
|
||||
size="large"
|
||||
>
|
||||
Ok
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user