Skip to content

Commit 006fd5d

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

File tree

70 files changed

+546
-820
lines changed

Some content is hidden

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

70 files changed

+546
-820
lines changed

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;

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

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ import { createDevbox, updateDevbox } from '@/api/devbox';
1818
import type { DevboxEditTypeV2, DevboxKindsType } from '@/types/devbox';
1919
import { defaultDevboxEditValueV2, editModeMap } from '@/constants/devbox';
2020

21+
import { useEnvStore } from '@/stores/env';
2122
import { useIDEStore } from '@/stores/ide';
2223
import { usePriceStore } from '@/stores/price';
2324
import { useGuideStore } from '@/stores/guide';
2425
import { useDevboxStore } from '@/stores/devbox';
2526
import { useQuotaGuarded } from '@sealos/shared';
2627
import { useDevboxOperation } from '@/hooks/useDevboxOperation';
2728
import ErrorModal from '@/components/ErrorModal';
28-
import { useClientAppConfig } from '@/hooks/useClientAppConfig';
2929

3030
import Form from './components/Form';
3131
import Yaml from './components/Yaml';
@@ -41,7 +41,7 @@ const DevboxCreatePage = () => {
4141
const searchParams = useSearchParams();
4242
const { executeOperation, errorModalState, closeErrorModal } = useDevboxOperation();
4343

44-
const appConfig = useClientAppConfig();
44+
const { env } = useEnvStore();
4545
const { addDevboxIDE } = useIDEStore();
4646
const { setDevboxDetail, setStartedTemplate, startedTemplate } = useDevboxStore();
4747
const { sourcePrice, setSourcePrice } = usePriceStore();
@@ -115,24 +115,14 @@ const DevboxCreatePage = () => {
115115
[templateListQuery.data?.templateList]
116116
);
117117

118-
const yamlEnv = useMemo(
119-
() => ({
120-
devboxAffinityEnable: String(appConfig.devbox.features.affinityScheduling),
121-
storageLimit: appConfig.devbox.resources.storageLimit,
122-
ingressSecret: appConfig.devbox.userDomain.secretName,
123-
nfsStorageClassName: appConfig.devbox.resources.storageClassNfs
124-
}),
125-
[appConfig]
126-
);
127-
128-
const generateDefaultYamlList = () => generateYamlList(defaultDevboxEditValueV2, yamlEnv);
118+
const generateDefaultYamlList = () => generateYamlList(defaultDevboxEditValueV2, env);
129119

130120
// update yamlList every time yamlList change
131121
const debouncedUpdateYaml = useMemo(
132122
() =>
133-
debounce((data: DevboxEditTypeV2, yamlEnv) => {
123+
debounce((data: DevboxEditTypeV2, env) => {
134124
try {
135-
const newYamlList = generateYamlList(data, yamlEnv);
125+
const newYamlList = generateYamlList(data, env);
136126
setYamlList(newYamlList);
137127
} catch (error) {
138128
console.error('Failed to generate yaml:', error);
@@ -153,14 +143,14 @@ const DevboxCreatePage = () => {
153143
useEffect(() => {
154144
const subscription = formHook.watch((value) => {
155145
if (value) {
156-
debouncedUpdateYaml(value as DevboxEditTypeV2, yamlEnv);
146+
debouncedUpdateYaml(value as DevboxEditTypeV2, env);
157147
}
158148
});
159149
return () => {
160150
subscription.unsubscribe();
161151
debouncedUpdateYaml.cancel();
162152
};
163-
}, [debouncedUpdateYaml, yamlEnv, formHook]);
153+
}, [debouncedUpdateYaml, env, formHook]);
164154

165155
const { refetch: refetchPrice } = useQuery(['init-price'], setSourcePrice, {
166156
enabled: !!sourcePrice?.gpu,
@@ -175,16 +165,16 @@ const DevboxCreatePage = () => {
175165
return null;
176166
}
177167
setIsLoading(true);
178-
return setDevboxDetail(devboxName, appConfig.cloud.domain);
168+
return setDevboxDetail(devboxName, env.sealosDomain);
179169
},
180170
{
181171
onSuccess(res) {
182172
if (!res) {
183173
return;
184174
}
185175
oldDevboxEditData.current = res;
186-
formOldYamls.current = generateYamlList(res, yamlEnv);
187-
crOldYamls.current = generateYamlList(res, yamlEnv) as DevboxKindsType[];
176+
formOldYamls.current = generateYamlList(res, env);
177+
crOldYamls.current = generateYamlList(res, env) as DevboxKindsType[];
188178
formHook.reset(res);
189179
},
190180
onError(err) {
@@ -216,7 +206,7 @@ const DevboxCreatePage = () => {
216206

217207
// update
218208
if (isEdit) {
219-
const yamlList = generateYamlList(formData, yamlEnv);
209+
const yamlList = generateYamlList(formData, env);
220210
setYamlList(yamlList);
221211
const parsedNewYamlList = yamlList.map((item) => item.value);
222212
const parsedOldYamlList = formOldYamls.current.map((item) => item.value);

0 commit comments

Comments
 (0)