Skip to content

Commit

Permalink
feat:standard cluster purchase process (labring#4225)
Browse files Browse the repository at this point in the history
* feat:standard cluster purchase process

Signed-off-by: jingyang <[email protected]>

* fix cronjob

Signed-off-by: jingyang <[email protected]>

---------

Signed-off-by: jingyang <[email protected]>
  • Loading branch information
zjy365 committed Nov 2, 2023
1 parent d8d3877 commit 41a17d8
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 3 deletions.
2 changes: 2 additions & 0 deletions frontend/providers/cronjob/src/utils/json2Yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export const json2CronJob = (data: CronJobEditType) => {
metadata: metadata,
spec: {
schedule: data.schedule,
concurrencyPolicy: 'Forbid',
startingDeadlineSeconds: 60,
successfulJobsHistoryLimit: 3,
failedJobsHistoryLimit: 3,
timeZone: timeZone,
Expand Down
91 changes: 91 additions & 0 deletions service/license/src/hooks/useConfirm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import {
Center,
Flex,
Modal,
ModalCloseButton,
ModalContent,
ModalOverlay,
Text,
useDisclosure
} from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';
import { useCallback, useRef } from 'react';

export const useConfirm = () => {
const { isOpen, onOpen, onClose } = useDisclosure();
const { t } = useTranslation();
const confirmCb = useRef<any>();
const cancelCb = useRef<any>();

return {
openConfirm: useCallback(
(confirm?: any, cancel?: any) => {
return function () {
onOpen();
confirmCb.current = confirm;
cancelCb.current = cancel;
};
},
[onOpen]
),
ConfirmChild: useCallback(
() => (
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalCloseButton />
<Flex
flexDirection={'column'}
px="37px"
pt="90px"
pb="42px"
alignItems={'center'}
justifyContent={'center'}
>
<Text color={'#24282C'} fontWeight={500} fontSize={'24px'}>
将为您新建一个标准版集群
</Text>
<Text mt="28px" fontSize={'14px'} fontWeight={400} color={'#7B838B'}>
点击立即开始后将会新建一个集群
</Text>
<Center
mt="62px"
w="218px"
h="44px"
bg={'#24282C'}
color={'white'}
fontSize={'14px'}
fontWeight={500}
borderRadius={'4px'}
cursor={'pointer'}
onClick={() => {
onClose();
typeof confirmCb.current === 'function' && confirmCb.current();
}}
>
立即开始
</Center>
<Center
mt="16px"
w="218px"
h="20px"
bg={'white'}
color={'#7B838B'}
fontSize={'14px'}
fontWeight={400}
cursor={'pointer'}
onClick={() => {
onClose();
typeof cancelCb.current === 'function' && cancelCb.current();
}}
>
已有集群
</Center>
</Flex>
</ModalContent>
</Modal>
),
[isOpen, onClose]
)
};
};
14 changes: 11 additions & 3 deletions service/license/src/pages/pricing/components/Product.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ import ServicePackage from './ServicePackage';
import useRouteParamsStore from '@/stores/routeParams';
import useSessionStore from '@/stores/session';
import usePaymentDataStore from '@/stores/payment';
import { useConfirm } from '@/hooks/useConfirm';

export default function Product() {
const { t } = useTranslation();
const queryClient = useQueryClient();
const router = useRouter();
const { isOpen, onOpen, onClose } = useDisclosure();
// const { isOpen: isOpenStatus, onOpen: onOpenSuccess, onClose: onCloseSuccess } = useDisclosure();
const { openConfirm, ConfirmChild } = useConfirm();
const toast = useToast({ position: 'top', duration: 2000 });
// 整个流程跑通需要状态管理, 0 初始态, 1 创建支付单, 2 支付中, 3 支付成功
const [complete, setComplete] = useState<0 | 1 | 2 | 3>(0);
Expand Down Expand Up @@ -73,8 +74,14 @@ export default function Product() {
const handleProductByType = (type: ClusterType) => {
setClusterType(type);
if (type === ClusterType.Standard) {
onOpen();
clusterMutation.mutate({ type: ClusterType.Standard });
openConfirm(
() => {
clusterMutation.mutate({ type: ClusterType.Standard });
},
() => {
router.push('/cluster');
}
)();
}
if (type === ClusterType.Enterprise) {
openPayModal();
Expand Down Expand Up @@ -462,6 +469,7 @@ export default function Product() {
)}
</ModalContent>
</Modal>
<ConfirmChild />
</>
);
}

0 comments on commit 41a17d8

Please sign in to comment.