Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:desktop usedriver & tempalte yml #4432

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion frontend/desktop/src/hooks/useDriver.tsx
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading