Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## About the changes Redesigned/refactored integrations form. ![image](https://github.com/Unleash/unleash/assets/2625371/9f3ad019-e367-4f89-932d-539d7a370f88) Closes [1-1298/resesign-of-integrations-form](https://linear.app/unleash/issue/1-1298/resesign-of-integrations-form)
- Loading branch information
Showing
16 changed files
with
409 additions
and
279 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
frontend/src/component/integrations/IntegrationForm/IntegrationDelete/IntegrationDelete.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { useState, type VFC } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import { styled } from '@mui/material'; | ||
import { Dialogue } from 'component/common/Dialogue/Dialogue'; | ||
import type { AddonSchema } from 'openapi'; | ||
import useAddonsApi from 'hooks/api/actions/useAddonsApi/useAddonsApi'; | ||
import useAddons from 'hooks/api/getters/useAddons/useAddons'; | ||
import useToast from 'hooks/useToast'; | ||
import { formatUnknownError } from 'utils/formatUnknownError'; | ||
import PermissionButton from 'component/common/PermissionButton/PermissionButton'; | ||
import { DELETE_ADDON } from 'component/providers/AccessProvider/permissions'; | ||
import { StyledHelpText, StyledTitle } from '../IntegrationForm.styles'; | ||
|
||
interface IIntegrationDeleteProps { | ||
id: AddonSchema['id']; | ||
} | ||
|
||
const StyledContainer = styled('div')(({ theme }) => ({ | ||
margin: theme.spacing(1, 0, 6), | ||
display: 'flex', | ||
justifyContent: 'flex-end', | ||
})); | ||
|
||
export const IntegrationDelete: VFC<IIntegrationDeleteProps> = ({ id }) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const { removeAddon } = useAddonsApi(); | ||
const { refetchAddons } = useAddons(); | ||
const { setToastData, setToastApiError } = useToast(); | ||
const navigate = useNavigate(); | ||
const onSubmit = async () => { | ||
try { | ||
await removeAddon(id); | ||
refetchAddons(); | ||
setToastData({ | ||
type: 'success', | ||
title: 'Success', | ||
text: 'Deleted addon successfully', | ||
}); | ||
} catch (error: unknown) { | ||
setToastApiError(formatUnknownError(error)); | ||
} | ||
navigate('/integrations'); | ||
}; | ||
|
||
return ( | ||
<> | ||
<StyledTitle>Delete integration</StyledTitle> | ||
<StyledHelpText> | ||
Deleting an integration it will delete the entire configuration | ||
and it will automatically disable the integration | ||
</StyledHelpText> | ||
<StyledContainer> | ||
<PermissionButton | ||
type="button" | ||
variant="outlined" | ||
color="error" | ||
permission={DELETE_ADDON} | ||
onClick={e => { | ||
e.preventDefault(); | ||
setIsOpen(true); | ||
}} | ||
> | ||
Delete integration | ||
</PermissionButton> | ||
</StyledContainer> | ||
<Dialogue | ||
open={isOpen} | ||
onClick={onSubmit} | ||
onClose={() => setIsOpen(false)} | ||
title="Confirm deletion" | ||
> | ||
<div>Are you sure you want to delete this Addon?</div> | ||
</Dialogue> | ||
</> | ||
); | ||
}; |
51 changes: 0 additions & 51 deletions
51
...omponent/integrations/IntegrationForm/IntegrationDeleteDialog/IntegrationDeleteDialog.tsx
This file was deleted.
Oops, something went wrong.
98 changes: 69 additions & 29 deletions
98
frontend/src/component/integrations/IntegrationForm/IntegrationForm.styles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,98 @@ | ||
import { styled } from '@mui/system'; | ||
import { FormControlLabel, TextField } from '@mui/material'; | ||
import { Paper, styled } from '@mui/material'; | ||
import { FormControlLabel, TextField, Typography } from '@mui/material'; | ||
import { forwardRef, type FC, type ReactNode, ComponentProps } from 'react'; | ||
|
||
export const StyledForm = styled('form')({ | ||
export const StyledForm = styled('form')(({ theme }) => ({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
height: '100%', | ||
gap: '1rem', | ||
}); | ||
|
||
export const StyledFormSection = styled('section')({ | ||
marginBottom: '36px', | ||
}); | ||
gap: theme.spacing(2), | ||
marginTop: theme.spacing(1), | ||
})); | ||
|
||
export const StyledAlerts = styled(StyledFormSection)(({ theme }) => ({ | ||
export const StyledAlerts = styled('section')(({ theme }) => ({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: theme.spacing(2), | ||
})); | ||
|
||
export const StyledHelpText = styled('p')({ | ||
marginBottom: '0.5rem', | ||
}); | ||
export const StyledHelpText = styled('p')(({ theme }) => ({ | ||
marginBottom: theme.spacing(1), | ||
color: theme.palette.text.secondary, | ||
fontSize: theme.typography.body2.fontSize, | ||
})); | ||
|
||
export const StyledContainer = styled('div')({ | ||
maxWidth: '600px', | ||
}); | ||
export const StyledContainer = styled('div')(({ theme }) => ({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: theme.spacing(4), | ||
})); | ||
|
||
export const StyledButtonContainer = styled('div')({ | ||
marginTop: 'auto', | ||
display: 'flex', | ||
justifyContent: 'flex-end', | ||
}); | ||
|
||
export const StyledButtonSection = styled('section')(({ theme }) => ({ | ||
display: 'flex', | ||
justifyContent: 'flex-end', | ||
paddingTop: theme.spacing(2), | ||
gap: theme.spacing(1), | ||
gap: theme.spacing(2), | ||
})); | ||
|
||
export const StyledTextField = styled(TextField)({ | ||
export const StyledTextField = styled(TextField)(({ theme }) => ({ | ||
width: '100%', | ||
marginBottom: '1rem', | ||
marginTop: '0px', | ||
}); | ||
})); | ||
|
||
export const StyledSelectAllFormControlLabel = styled(FormControlLabel)({ | ||
paddingBottom: '16px', | ||
}); | ||
export const StyledSelectAllFormControlLabel = styled(FormControlLabel)( | ||
({ theme }) => ({ | ||
paddingBottom: theme.spacing(1), | ||
}) | ||
); | ||
|
||
export const StyledTitle = styled('h4')({ | ||
marginBottom: '8px', | ||
}); | ||
export const StyledTitle = forwardRef< | ||
HTMLHeadingElement, | ||
{ children: ReactNode } | ||
>(({ children }, ref) => ( | ||
<Typography | ||
ref={ref} | ||
component="h4" | ||
variant="h4" | ||
sx={theme => ({ | ||
margin: theme.spacing(1, 0), | ||
})} | ||
> | ||
{children} | ||
</Typography> | ||
)); | ||
|
||
export const StyledAddonParameterContainer = styled('div')({ | ||
marginTop: '25px', | ||
}); | ||
|
||
export const StyledConfigurationSection = styled('section')(({ theme }) => ({ | ||
borderWidth: '1px', | ||
borderStyle: 'solid', | ||
borderColor: theme.palette.neutral.border, | ||
borderRadius: `${theme.shape.borderRadiusLarge}px`, | ||
padding: theme.spacing(3), | ||
display: 'flex', | ||
flexDirection: 'column', | ||
gap: theme.spacing(3), | ||
})); | ||
|
||
export const StyledRaisedSection: FC<ComponentProps<typeof Paper>> = ({ | ||
...props | ||
}) => ( | ||
<Paper | ||
elevation={0} | ||
sx={theme => ({ | ||
background: theme.palette.background.elevation1, | ||
padding: theme.spacing(2, 3), | ||
display: 'flex', | ||
flexDirection: 'column', | ||
width: '100%', | ||
borderRadius: `${theme.shape.borderRadiusLarge}px`, | ||
})} | ||
{...props} | ||
/> | ||
); |
Oops, something went wrong.