Skip to content

Commit dce1eb1

Browse files
committed
revert(devbox): discard devbox related changes
Signed-off-by: Nixieboluo <[email protected]>
1 parent 4b0842c commit dce1eb1

File tree

72 files changed

+644
-822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+644
-822
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Env for dev
2+
3+
4+
# kubeconfig: login sealos->Console-application->session.state.session.kubeconfig->copy as JSON string.
5+
NEXT_PUBLIC_MOCK_USER=
6+
# stop verifying SSL certificates in development.
7+
NODE_TLS_REJECT_UNAUTHORIZED='0'
8+
# white list for metrics url,use NEXT_PUBLIC_MOCK_USER's cluster server
9+
WHITELIST_KUBERNETES_HOSTS=''
10+
# Env for dev and prod
11+
12+
13+
# you develop sealos domain,such as hzh.sealos.run
14+
SEALOS_DOMAIN=
15+
# ssh domain for devbox connection, fallback to SEALOS_DOMAIN if not set
16+
SSH_DOMAIN=
17+
# domain for ingress(public domain use),such as saeloshzh.site
18+
INGRESS_DOMAIN=
19+
# domain for image registry,such as hub.hzh.sealos.run
20+
REGISTRY_ADDR=
21+
22+
# K8S Secret name for ingress TLC cert,default is "wildcard-cert"
23+
INGRESS_SECRET="wildcard-cert"
24+
# boolean for devbox tolerations,default is true
25+
DEVBOX_AFFINITY_ENABLE="true"
26+
27+
# devbox storage limit,default is 10Gi
28+
STORAGE_LIMIT="10Gi"
29+
30+
31+
# for auth
32+
# -nsealos cm desktop-frontend-config ->jwt->Internal
33+
JWT_SECRET=
34+
# region cluster uid,for datatbase to auth
35+
REGION_UID=
36+
37+
# !!!IMPORTANT: for the following url,you need to port forward.
38+
# metrics for devbox (Victoria Metrics / Prometheus API base URL)
39+
# in dev: http://127.0.0.1:8429
40+
# in prod: http://vmselect-vm-stack-victoria-metrics-k8s-stack.vm.svc.cluster.local:8481/select/0/prometheus
41+
METRICS_URL=
42+
# legacy monitor service (deprecated)
43+
# MONITOR_URL=
44+
# url for get resource price
45+
# in dev: not set
46+
# in prod: http://account-service.account-system.svc.cluster.local:2333
47+
ACCOUNT_URL=
48+
# template store database url
49+
# -nsealos cm desktop-frontend-config ->database->global + devbox
50+
# the following is just an example
51+
# in dev: postgresql://username:[email protected]:26257/devboxdb?connection_limit=50&pool_timeout=20
52+
# in prod: postgresql://username:[email protected]:26257/devboxdb?connection_limit=50&pool_timeout=20
53+
DATABASE_URL=
54+
# url for template retag
55+
# in dev: http://127.0.0.1:8092
56+
# in prod: http://devbox-service.devbox-system.svc.cluster.local:8092
57+
RETAG_SVC_URL=
58+
# privacy document url(for user to create template)
59+
PRIVACY_URL_ZH="https://sealos.run/docs/msa/privacy-policy"
60+
PRIVACY_URL_EN="https://sealos.io/docs/msa/privacy-policy"
61+
# document url
62+
DOCUMENT_URL_ZH="https://sealos.run/docs/overview/intro"
63+
DOCUMENT_URL_EN="https://sealos.io/docs/overview/intro"
64+
65+
# sealos coin style for ui,['shellCoin','cny','usd']
66+
# in China: shellCoin,in other region: usd
67+
CURRENCY_SYMBOL='usd'
68+
# if open GPU ui,used for some environemnt which has GPU,default is false
69+
GPU_ENABLE= "false"
70+
# enable git import and local upload features, default is false
71+
ENABLE_IMPORT_FEATURE="false"
72+
# enable web IDE feature, default is false
73+
ENABLE_WEBIDE_FEATURE="false"
74+
# enable advanced config feature(env, configmap, nfs), default is false
75+
ENABLE_ADVANCED_CONFIG="false"
76+
77+
# CPU and Memory slider configuration (comma-separated numbers)
78+
CPU_SLIDE_MARK_LIST='1,2,4,8,16'
79+
MEMORY_SLIDE_MARK_LIST='2,4,8,16,32'
80+
81+
# Domain challenge secret for domain ownership verification
82+
# Change this secret in production for security
83+
DEVBOX_DOMAIN_CHALLENGE_SECRET='default-dev-secret-change-in-production'
84+
85+
# NFS storage class name for template store and user data, default is 'nfs-csi',every cluster should have their own storage class
86+
NFS_STORAGE_CLASS_NAME='nfs-csi'
87+
88+
# WEBIDE port,default is 9999
89+
WEBIDE_PORT=9999
90+
91+
92+
93+
# deprecated env,this env is used before template store,now is deprecated
94+
ROOT_RUNTIME_NAMESPACE='devbox-system'
95+
96+
# Track
97+
CUSTOM_SCRIPTS='[{"src": "http://www.example.com/example.js"}]'

frontend/providers/devbox/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ next-env.d.ts
3737

3838
prisma/generated
3939

40-
data/*
41-
!data/config.example.yaml
40+
!.env.template

frontend/providers/devbox/api/platform.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { GET, POST } from '@/services/request';
22
import type { UserTask } from '@/types/user';
3+
import type { Env } from '@/types/static';
34
import { AuthCnamePrams, AuthDomainChallengeParams } from '@/types/params';
45
import { useUserStore } from '@/stores/user';
6+
export const getAppEnv = () => GET<Env>('/api/getEnv');
57

68
export const getUserIsOutStandingPayment = () =>
79
GET<{

frontend/providers/devbox/app/[lang]/(platform)/(home)/components/Header.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import {
1414
import { useSearchParams } from 'next/navigation';
1515

1616
import { useRouter } from '@/i18n';
17+
import { useEnvStore } from '@/stores/env';
1718
import { useGuideStore } from '@/stores/guide';
1819
import { useClientSideValue } from '@/hooks/useClientSideValue';
1920
import { destroyDriver, startDriver, startGuide2 } from '@/hooks/driver';
20-
import { useClientAppConfig } from '@/hooks/useClientAppConfig';
2121

2222
import { Input } from '@sealos/shadcn-ui/input';
2323
import { Button } from '@sealos/shadcn-ui/button';
@@ -37,7 +37,7 @@ export default function Header({ onSearch }: { onSearch: (value: string) => void
3737
const locale = useLocale();
3838
const t = useTranslations();
3939
const searchParams = useSearchParams();
40-
const appConfig = useClientAppConfig();
40+
const { env } = useEnvStore();
4141
const { guide2, setGuide2 } = useGuideStore();
4242
const isClientSide = useClientSideValue(true);
4343
const [importDrawerType, setImportDrawerType] = useState<ImportType | null>(null);
@@ -60,9 +60,9 @@ export default function Header({ onSearch }: { onSearch: (value: string) => void
6060

6161
const handleGotoDocs: any = () => {
6262
if (locale === 'zh') {
63-
window.open(appConfig.devbox.ui.docUrls.docs.zh, '_blank');
63+
window.open(env.documentUrlZH, '_blank');
6464
} else {
65-
window.open(appConfig.devbox.ui.docUrls.docs.en, '_blank');
65+
window.open(env.documentUrlEN, '_blank');
6666
}
6767
};
6868

@@ -159,7 +159,7 @@ export default function Header({ onSearch }: { onSearch: (value: string) => void
159159
<LayoutTemplate className="h-4 w-4" />
160160
<span className="leading-5"> {t('scan_templates')}</span>
161161
</Button>
162-
{appConfig.devbox.features.importTemplate ? (
162+
{env.enableImportFeature === 'true' ? (
163163
<DropdownMenu>
164164
<DropdownMenuTrigger asChild>
165165
<Button className="list-create-app-button h-10 gap-2">

frontend/providers/devbox/app/[lang]/(platform)/devbox/create/components/Cpu.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import { Label } from '@sealos/shadcn-ui/label';
88
import { Slider } from '@sealos/shadcn-ui/slider';
99

1010
import { DevboxEditTypeV2 } from '@/types/devbox';
11-
import { useClientAppConfig } from '@/hooks/useClientAppConfig';
11+
import { useEnvStore } from '@/stores/env';
1212

1313
export default function Cpu() {
1414
const t = useTranslations();
15-
const appConfig = useClientAppConfig();
15+
const { env } = useEnvStore();
1616
const { watch, setValue } = useFormContext<DevboxEditTypeV2>();
1717

1818
const CpuSlideMarkList = useMemo(() => {
19-
if (!appConfig.devbox.resources.cpuMarks.length) {
19+
if (!env.cpuSlideMarkList) {
2020
return [
2121
{ label: 1, value: 1000 },
2222
{ label: 2, value: 2000 },
@@ -27,10 +27,8 @@ export default function Cpu() {
2727
}
2828

2929
try {
30-
return appConfig.devbox.resources.cpuMarks.map((cpu) => ({
31-
label: cpu,
32-
value: cpu * 1000
33-
}));
30+
const cpuList = env.cpuSlideMarkList.split(',').map((v) => Number(v.trim()));
31+
return cpuList.map((cpu) => ({ label: cpu, value: cpu * 1000 }));
3432
} catch (error) {
3533
console.error('Failed to parse CPU list from env:', error);
3634
return [
@@ -41,7 +39,7 @@ export default function Cpu() {
4139
{ label: 16, value: 16000 }
4240
];
4341
}
44-
}, [appConfig.devbox.resources.cpuMarks]);
42+
}, [env.cpuSlideMarkList]);
4543

4644
const currentValue = watch('cpu');
4745
const currentIndex = CpuSlideMarkList.findIndex((item) => item.value === currentValue);

frontend/providers/devbox/app/[lang]/(platform)/devbox/create/components/Form.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import AdvancedConfig from './AdvancedConfig';
2222
import { Tabs, TabsList, TabsTrigger } from '@sealos/shadcn-ui/tabs';
2323
import { useUserQuota, resourcePropertyMap } from '@sealos/shared';
2424
import { sealosApp } from 'sealos-desktop-sdk/app';
25-
import { useClientAppConfig } from '@/hooks/useClientAppConfig';
25+
import { useEnvStore } from '@/stores/env';
2626

2727
interface FormProps {
2828
isEdit: boolean;
@@ -35,9 +35,10 @@ const Form = ({ isEdit, countGpuInventory, oldDevboxData }: FormProps) => {
3535
const searchParams = useSearchParams();
3636
const t = useTranslations();
3737
const { watch } = useFormContext<DevboxEditTypeV2>();
38-
const appConfig = useClientAppConfig();
38+
const { env } = useEnvStore();
3939

4040
const formValues = watch();
41+
const showAdvancedConfig = env.enableAdvancedConfig === 'true';
4142
const requirements = useMemo(() => {
4243
const currentGpuAmount = formValues.gpu?.amount || 0;
4344
const oldGpuAmount = oldDevboxData?.gpu?.amount || 0;
@@ -213,7 +214,7 @@ const Form = ({ isEdit, countGpuInventory, oldDevboxData }: FormProps) => {
213214
</div>
214215

215216
{/* Advanced Configurations */}
216-
{appConfig.devbox.features.advancedSettings && <AdvancedConfig />}
217+
{showAdvancedConfig && <AdvancedConfig />}
217218
</div>
218219
</div>
219220
);

frontend/providers/devbox/app/[lang]/(platform)/devbox/create/components/Memory.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import { useTranslations } from 'next-intl';
55
import { useFormContext } from 'react-hook-form';
66

77
import { DevboxEditTypeV2 } from '@/types/devbox';
8-
import { useClientAppConfig } from '@/hooks/useClientAppConfig';
8+
import { useEnvStore } from '@/stores/env';
99

1010
import { Label } from '@sealos/shadcn-ui/label';
1111
import { Slider } from '@sealos/shadcn-ui/slider';
1212

1313
export default function Memory() {
1414
const t = useTranslations();
15-
const appConfig = useClientAppConfig();
15+
const { env } = useEnvStore();
1616
const { watch, setValue } = useFormContext<DevboxEditTypeV2>();
1717

1818
const MemorySlideMarkList = useMemo(() => {
19-
if (!appConfig.devbox.resources.memoryMarks.length) {
19+
if (!env.memorySlideMarkList) {
2020
return [
2121
{ label: '2', value: 2048 },
2222
{ label: '4', value: 4096 },
@@ -27,10 +27,8 @@ export default function Memory() {
2727
}
2828

2929
try {
30-
return appConfig.devbox.resources.memoryMarks.map((memory) => ({
31-
label: String(memory),
32-
value: memory * 1024
33-
}));
30+
const memoryList = env.memorySlideMarkList.split(',').map((v) => Number(v.trim()));
31+
return memoryList.map((memory) => ({ label: String(memory), value: memory * 1024 }));
3432
} catch (error) {
3533
console.error('Failed to parse memory list from env:', error);
3634
return [
@@ -41,7 +39,7 @@ export default function Memory() {
4139
{ label: '32', value: 32768 }
4240
];
4341
}
44-
}, [appConfig.devbox.resources.memoryMarks]);
42+
}, [env.memorySlideMarkList]);
4543

4644
const currentValue = watch('memory');
4745
const currentIndex = MemorySlideMarkList.findIndex((item) => item.value === currentValue);

frontend/providers/devbox/app/[lang]/(platform)/devbox/create/components/Network.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { Plus, Trash2 } from 'lucide-react';
66
import { useFieldArray, useFormContext } from 'react-hook-form';
77

88
import { nanoid } from '@/utils/tools';
9+
import { useEnvStore } from '@/stores/env';
910
import { ProtocolList } from '@/constants/devbox';
1011
import { DevboxEditTypeV2, ProtocolType } from '@/types/devbox';
11-
import { useClientAppConfig } from '@/hooks/useClientAppConfig';
1212

1313
import {
1414
Select,
@@ -34,7 +34,7 @@ export default function Network({
3434
}: React.HTMLAttributes<HTMLDivElement> & { isEdit: boolean }) {
3535
const { register, getValues, control } = useFormContext<DevboxEditTypeV2>();
3636
const [customAccessModalData, setCustomAccessModalData] = useState<CustomAccessModalParams>();
37-
const appConfig = useClientAppConfig();
37+
const { env } = useEnvStore();
3838

3939
const {
4040
fields: networks,
@@ -115,8 +115,7 @@ export default function Network({
115115
{/* Port List */}
116116
{networks.map((network, i) => {
117117
const isReservedPort =
118-
appConfig.devbox.features.webide &&
119-
network.port === appConfig.devbox.runtime.webidePort;
118+
env.enableWebideFeature === 'true' && network.port === env.webIdePort;
120119
return (
121120
<div key={network.id} className="flex w-full flex-col gap-3">
122121
<div className="guide-network-configuration flex w-full items-center gap-4">
@@ -155,10 +154,8 @@ export default function Network({
155154
return !isDuplicate || t('The port number cannot be repeated');
156155
},
157156
reservedPort: (value) => {
158-
if (value === appConfig.devbox.runtime.webidePort) {
159-
return t('port_reserved', {
160-
port: appConfig.devbox.runtime.webidePort
161-
});
157+
if (value === env.webIdePort) {
158+
return t('port_reserved', { port: env.webIdePort });
162159
}
163160
return true;
164161
}
@@ -190,8 +187,7 @@ export default function Network({
190187
protocol: network.protocol || ('HTTP' as ProtocolType),
191188
openPublicDomain: checked,
192189
publicDomain:
193-
network.publicDomain ||
194-
`${nanoid()}.${appConfig.devbox.userDomain.domain}`
190+
network.publicDomain || `${nanoid()}.${env.ingressDomain}`
195191
});
196192
}}
197193
/>

frontend/providers/devbox/app/[lang]/(platform)/devbox/create/components/PriceBox.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { useTranslations } from 'next-intl';
44
import { CircuitBoard, Cpu, MemoryStick } from 'lucide-react';
55

66
import { cn } from '@sealos/shadcn-ui';
7+
import { useEnvStore } from '@/stores/env';
78
import { usePriceStore } from '@/stores/price';
8-
import { useClientAppConfig } from '@/hooks/useClientAppConfig';
99

1010
import { Card, CardContent, CardHeader } from '@sealos/shadcn-ui/card';
1111

@@ -29,7 +29,7 @@ interface PriceBoxProps {
2929
const PriceBox = ({ components = [], className }: PriceBoxProps) => {
3030
const t = useTranslations();
3131
const { sourcePrice } = usePriceStore();
32-
const appConfig = useClientAppConfig();
32+
const { env } = useEnvStore();
3333

3434
const priceList: {
3535
icon?: React.ReactNode;
@@ -106,7 +106,7 @@ const PriceBox = ({ components = [], className }: PriceBoxProps) => {
106106
index === priceList.length - 1 && 'text-blue-600'
107107
)}
108108
>
109-
<CurrencySymbol type={appConfig.devbox.ui.currencySymbol} />
109+
<CurrencySymbol type={env.currencySymbol} />
110110
&nbsp;
111111
{item.value}
112112
</div>

frontend/providers/devbox/app/[lang]/(platform)/devbox/create/components/Runtime.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { useCallback, useEffect, useMemo } from 'react';
1010
import { cn } from '@sealos/shadcn-ui';
1111
import { useRouter } from '@/i18n';
1212
import { nanoid } from '@/utils/tools';
13+
import { useEnvStore } from '@/stores/env';
1314
import { listOfficialTemplateRepository, listTemplate } from '@/api/template';
1415
import { useDevboxStore } from '@/stores/devbox';
1516
import { DevboxEditTypeV2 } from '@/types/devbox';
1617
import { RuntimeIcon } from '@/components/RuntimeIcon';
17-
import { useClientAppConfig } from '@/hooks/useClientAppConfig';
1818

1919
import {
2020
Select,
@@ -35,7 +35,7 @@ interface RuntimeProps {
3535
export default function Runtime({ isEdit = false }: RuntimeProps) {
3636
const router = useRouter();
3737
const t = useTranslations();
38-
const appConfig = useClientAppConfig();
38+
const { env } = useEnvStore();
3939
const { startedTemplate, devboxDetail, setStartedTemplate } = useDevboxStore();
4040
const { getValues, setValue, watch } = useFormContext<DevboxEditTypeV2>();
4141
const searchParams = useSearchParams();
@@ -90,12 +90,12 @@ export default function Runtime({ isEdit = false }: RuntimeProps) {
9090
port: port,
9191
protocol: 'HTTP',
9292
openPublicDomain: true,
93-
publicDomain: `${nanoid()}.${appConfig.devbox.userDomain.domain}`,
93+
publicDomain: `${nanoid()}.${env.ingressDomain}`,
9494
customDomain: ''
9595
}) as const
9696
)
9797
);
98-
}, [getValues, setValue, appConfig.devbox.userDomain.domain]);
98+
}, [getValues, setValue, env]);
9999

100100
const handleVersionChange = (val: string) => {
101101
if (isEdit) return;

0 commit comments

Comments
 (0)