Skip to content

Commit

Permalink
fix:desktop usedriver & tempalte yml (#4432)
Browse files Browse the repository at this point in the history
Signed-off-by: jingyang <3161362058@qq.com>
  • Loading branch information
zjy365 committed Dec 18, 2023
1 parent a5be5cb commit 258e565
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
6 changes: 5 additions & 1 deletion frontend/desktop/src/hooks/useDriver.tsx
Expand Up @@ -4,6 +4,7 @@ import { formatMoney } from '@/utils/format';
import { Box, Button, Flex, FlexProps, Icon, Image, Text } from '@chakra-ui/react';
import { driver } from '@sealos/driver';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';

export function DriverStarIcon() {
Expand Down Expand Up @@ -43,6 +44,7 @@ export default function useDriver({ openDesktopApp }: { openDesktopApp: any }) {
const { t, i18n } = useTranslation();
const [showGuide, setShowGuide] = useState(false);
const [giftAmount, setGiftAmount] = useState(8);
const router = useRouter();

const handleSkipGuide = () => {
console.log('handleSkipGuide');
Expand All @@ -65,7 +67,8 @@ export default function useDriver({ openDesktopApp }: { openDesktopApp: any }) {
);
setGiftAmount(rewardBalance);
}
if (env?.guideEnabled && data?.metadata?.annotations) {

if (env?.guideEnabled && data?.metadata?.annotations && !router.query?.openapp) {
const isGuidedDesktop = !!data.metadata.annotations?.[GUIDE_DESKTOP_INDEX_KEY];
!isGuidedDesktop ? setShowGuide(true) : '';
}
Expand All @@ -74,6 +77,7 @@ export default function useDriver({ openDesktopApp }: { openDesktopApp: any }) {
}
};
handleUserGuide();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const PopoverBodyInfo = (props: FlexProps) => (
Expand Down
3 changes: 2 additions & 1 deletion frontend/providers/template/src/pages/api/updateRepo.ts
Expand Up @@ -22,7 +22,8 @@ const readFileList = (targetPath: string, fileList: unknown[] = [], handlePath:
// ok:path-join-resolve-traversal
const filePath = path.join(sanitizePath(targetPath), sanitizePath(item));
const stats = fs.statSync(filePath);
if (stats.isFile() && path.extname(item) === '.yaml' && item !== 'template.yaml') {
const isYamlFile = path.extname(item) === '.yaml' || path.extname(item) === '.yml';
if (stats.isFile() && isYamlFile && item !== 'template.yaml') {
fileList.push(filePath);
} else if (stats.isDirectory() && item === handlePath) {
readFileList(filePath, fileList, handlePath);
Expand Down
7 changes: 4 additions & 3 deletions service/license/src/pages/api/payment/create.ts
Expand Up @@ -8,7 +8,8 @@ import type { NextApiRequest, NextApiResponse } from 'next';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const { amount, currency, payMethod, stripeCallBackUrl } = req.body as PaymentParams;
const { amount, currency, payMethod, stripeSuccessCallBackUrl, stripeErrorCallBackUrl } =
req.body as PaymentParams;
const STRIPE_CALLBACK_URL = process.env.STRIPE_CALLBACK_URL;
const userInfo = await authSession(req.headers);
if (!userInfo) return jsonRes(res, { code: 401, message: 'token verify error' });
Expand All @@ -25,8 +26,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
currency: currency,
user: userInfo.uid,
payMethod: payMethod,
stripeSuccessUrl: `${STRIPE_CALLBACK_URL}${stripeCallBackUrl}`,
stripeCancelUrl: `${STRIPE_CALLBACK_URL}${stripeCallBackUrl}?stripeState=error`
stripeSuccessUrl: `${STRIPE_CALLBACK_URL}${stripeSuccessCallBackUrl}`,
stripeCancelUrl: `${STRIPE_CALLBACK_URL}${stripeErrorCallBackUrl}`
})
}).then((res) => res.json());

Expand Down
5 changes: 4 additions & 1 deletion service/license/src/pages/cluster/components/Recharge.tsx
Expand Up @@ -96,7 +96,8 @@ export default forwardRef(function RechargeComponent(props, ref) {
amount: deFormatMoney(selectAmount).toString(),
payMethod: payType,
currency: 'CNY',
stripeCallBackUrl: `/cluster?clusterId=${clusterDetail?.clusterId}&stripeState=success&tab=license`
stripeSuccessCallBackUrl: `/cluster?clusterId=${clusterDetail?.clusterId}&tab=license&stripeState=success`,
stripeErrorCallBackUrl: `/cluster?clusterId=${clusterDetail?.clusterId}&tab=license&stripeState=error`
}),
{
async onSuccess(data) {
Expand Down Expand Up @@ -212,6 +213,7 @@ export default forwardRef(function RechargeComponent(props, ref) {
});
setClusterDetail(cluster);
};

useEffect(() => {
const { stripeState, orderID, clusterId, tab } = router.query;
console.log(stripeState, orderID, clusterId);
Expand All @@ -229,6 +231,7 @@ export default forwardRef(function RechargeComponent(props, ref) {
setOrderID(orderID as string);
setTimeout(clearQuery, 0);
} else if (stripeState === 'error') {
clusterId ? getCluster(clusterId as string) : '';
toast({
status: 'error',
duration: 3000,
Expand Down
3 changes: 2 additions & 1 deletion service/license/src/pages/pricing/components/Product.tsx
Expand Up @@ -107,7 +107,8 @@ export default function Product() {
amount: amount,
payMethod: payType,
currency: 'CNY',
stripeCallBackUrl: '/pricing?stripeState=success'
stripeSuccessCallBackUrl: '/pricing?stripeState=success',
stripeErrorCallBackUrl: '/pricing?stripeState=error'
}),
{
async onSuccess(data) {
Expand Down
4 changes: 2 additions & 2 deletions service/license/src/types/payment.ts
Expand Up @@ -29,8 +29,8 @@ export type PaymentParams = {
amount: string;
currency: 'CNY';
payMethod: TPayMethod;
stripeCallBackUrl: string;
// clusterId: string;
stripeSuccessCallBackUrl: string;
stripeErrorCallBackUrl: string;
};

export type PaymentResultParams = {
Expand Down

0 comments on commit 258e565

Please sign in to comment.