1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00

fix: Refresh after import (#3108)

This commit is contained in:
Mateusz Kwasniewski 2023-02-14 14:25:44 +01:00 committed by GitHub
parent a9121150ff
commit 39d09a0f88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

@ -14,11 +14,6 @@ import {
import { ValidationStage } from './validate/ValidationStage';
import { ImportStage } from './import/ImportStage';
import { ImportOptions } from './configure/ImportOptions';
import {
IMPORT_BUTTON,
IMPORT_CONFIGURATION_BUTTON,
VALIDATE_BUTTON,
} from '../../../../utils/testIds';
const ModalContentContainer = styled('div')(({ theme }) => ({
minHeight: '100vh',

View File

@ -10,6 +10,8 @@ import { PulsingAvatar } from '../PulsingAvatar';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { Box } from '@mui/system';
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
import useProject from 'hooks/api/getters/useProject/useProject';
import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests';
export const ImportStatusArea = styled(Box)(({ theme }) => ({
padding: theme.spacing(4, 2, 2, 2),
@ -61,18 +63,24 @@ export const ImportStage: FC<{
onClose: () => void;
}> = ({ environment, project, payload, onClose }) => {
const { createImport, loading, errors } = useImportApi();
const { refetch: refreshProject } = useProject(project);
const { refetch: refreshChangeRequests } =
usePendingChangeRequests(project);
const { setToastData } = useToast();
const { isChangeRequestConfigured } = useChangeRequestsEnabled(project);
useEffect(() => {
createImport({ environment, project, data: JSON.parse(payload) }).catch(
error => {
createImport({ environment, project, data: JSON.parse(payload) })
.then(() => {
refreshProject();
refreshChangeRequests();
})
.catch(error => {
setToastData({
type: 'error',
title: formatUnknownError(error),
});
}
);
});
}, []);
const importStatus = toApiStatus(loading, errors);