Skip to content
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
18 changes: 12 additions & 6 deletions frontend/desktop/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,18 @@ export default function Home({ sealos_cloud_domain }: { sealos_cloud_domain: str
setInviterId(query.uid);
}
// sealos_inside=true internal call
if (whitelistApps.includes(appkey) && appQuery.indexOf('sealos_inside=true') === -1) {
sessionStorage.setItem(
'accessTemplatesNoLogin',
`https://template.${sealos_cloud_domain}/deploy?${appQuery}`
);
return;
if (whitelistApps.includes(appkey)) {
if (appQuery.indexOf('sealos_inside=true') === -1) {
sessionStorage.setItem(
'accessTemplatesNoLogin',
`https://template.${sealos_cloud_domain}/deploy?${appQuery}`
);
return;
} else {
// If sealos_inside=true, redirect to login page to avoid guest mode
router.replace('/signin');
return;
}
}

// save autolaunch info (for guest and logged in user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}

const result = await testCname(customDomain, publicDomain).catch((e) => {
console.log('Invalid resolve result for CNAME record on ' + customDomain + ': ', e);
// console.log('Invalid resolve result for CNAME record on ' + customDomain + ': ', e);
throw e;
});

Expand Down
21 changes: 17 additions & 4 deletions frontend/providers/template/src/pages/deploy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,21 @@ export default function EditApp({

const { createCompleted } = useGuideStore();

const handleOutside = useCallback(() => {
const handleOutside = useCallback(async () => {
setCached(JSON.stringify({ ...formHook.getValues(), cachedKey: templateName }));

// Ensure platformEnvs is loaded
let envs = platformEnvs;
if (!envs?.DESKTOP_DOMAIN) {
try {
envs = await getPlatformEnv({ insideCloud });
setEnvs(envs);
} catch (error) {
console.error('Failed to get platform envs:', error);
return;
}
}

const params = new URLSearchParams();
['k', 's', 'bd_vid'].forEach((param) => {
const value = router.query[param];
Expand All @@ -164,7 +176,7 @@ export default function EditApp({

const queryString = params.toString();

const baseUrl = `https://${platformEnvs?.DESKTOP_DOMAIN}/`;
const baseUrl = `https://${envs.DESKTOP_DOMAIN}/`;
const encodedTemplateQuery = encodeURIComponent(
`?templateName=${templateName}&sealos_inside=true`
);
Expand All @@ -174,7 +186,7 @@ export default function EditApp({
}`;

window.open(href, '_self');
}, [router, templateName, platformEnvs, setCached, formHook]);
}, [router, templateName, platformEnvs, setCached, formHook, insideCloud, setEnvs]);

const handleInside = useCallback(async () => {
const yamls = yamlList.map((item) => item.value);
Expand Down Expand Up @@ -213,7 +225,7 @@ export default function EditApp({

try {
if (!insideCloud) {
handleOutside();
await handleOutside();
} else {
await handleInside();
}
Expand All @@ -240,6 +252,7 @@ export default function EditApp({
}, [yamlList]);

const handleCreateApp = useCallback(() => {
// console.log('usage', usage);
// Check quota before creating app
const exceededQuotaItems = checkExceededQuotas({
cpu: usage.cpu.max,
Expand Down
4 changes: 2 additions & 2 deletions frontend/providers/template/src/store/cached.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const useCachedStore = create<State>()(
},
setInsideCloud(e: boolean) {
set((state) => {
state.insideCloud = process.env.NODE_ENV === 'development' ? true : e;
// state.insideCloud = e;
// state.insideCloud = process.env.NODE_ENV === 'development' ? true : e;
state.insideCloud = e;
});
}
})),
Expand Down
7 changes: 7 additions & 0 deletions frontend/providers/template/src/store/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { sealosApp } from 'sealos-desktop-sdk/app';
import { create } from 'zustand';
import { devtools } from 'zustand/middleware';
import { immer } from 'zustand/middleware/immer';
import { useCachedStore } from './cached';

type State = {
userSourcePrice: userPriceType | undefined;
Expand Down Expand Up @@ -42,6 +43,12 @@ export const useUserStore = create<State>()(
},
userQuota: [],
loadUserQuota: async () => {
// Skip loading quota when not inside cloud
const insideCloud = useCachedStore.getState().insideCloud;
if (!insideCloud) {
return null;
}

const response = await sealosApp.getWorkspaceQuota();

set((state) => {
Expand Down
Loading