forked from labring/sealos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
861 additions
and
392 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type AuthCnamePrams = { | ||
publicDomain: string; | ||
customDomain: string; | ||
}; |
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
54 changes: 54 additions & 0 deletions
54
frontend/providers/applaunchpad/src/components/MyModal/index.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,54 @@ | ||
import React from 'react'; | ||
import { | ||
Modal, | ||
ModalOverlay, | ||
ModalContent, | ||
ModalHeader, | ||
ModalCloseButton, | ||
ModalContentProps, | ||
Box | ||
} from '@chakra-ui/react'; | ||
|
||
interface Props extends ModalContentProps { | ||
showCloseBtn?: boolean; | ||
title?: any; | ||
isCentered?: boolean; | ||
isOpen: boolean; | ||
onClose: () => void; | ||
} | ||
|
||
const MyModal = ({ | ||
isOpen, | ||
onClose, | ||
title, | ||
children, | ||
showCloseBtn = true, | ||
isCentered, | ||
w = 'auto', | ||
maxW = ['90vw', '600px'], | ||
...props | ||
}: Props) => { | ||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose} autoFocus={false} isCentered={isCentered}> | ||
<ModalOverlay /> | ||
<ModalContent | ||
display={'flex'} | ||
flexDirection={'column'} | ||
w={w} | ||
minW={['90vw', '400px']} | ||
maxW={maxW} | ||
position={'relative'} | ||
maxH={'90vh'} | ||
{...props} | ||
> | ||
{!!title && <ModalHeader>{title}</ModalHeader>} | ||
<Box overflow={'overlay'} h={'100%'}> | ||
{showCloseBtn && <ModalCloseButton />} | ||
{children} | ||
</Box> | ||
</ModalContent> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default MyModal; |
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
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
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,36 @@ | ||
import { useToast } from '@/hooks/useToast'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import type { UseMutationOptions } from '@tanstack/react-query'; | ||
import { getErrText } from '@/utils/tools'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
interface Props extends UseMutationOptions<any, any, any, any> { | ||
successToast?: string | null; | ||
errorToast?: string | null; | ||
} | ||
|
||
export const useRequest = ({ successToast, errorToast, onSuccess, onError, ...props }: Props) => { | ||
const { toast } = useToast(); | ||
const { t } = useTranslation(); | ||
const mutation = useMutation<unknown, unknown, any, unknown>({ | ||
...props, | ||
onSuccess(res, variables: void, context: unknown) { | ||
onSuccess?.(res, variables, context); | ||
successToast && | ||
toast({ | ||
title: successToast, | ||
status: 'success' | ||
}); | ||
}, | ||
onError(err: any, variables: void, context: unknown) { | ||
onError?.(err, variables, context); | ||
errorToast && | ||
toast({ | ||
title: t(getErrText(err, errorToast)), | ||
status: 'error' | ||
}); | ||
} | ||
}); | ||
|
||
return mutation; | ||
}; |
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
Oops, something went wrong.