@@ -5,21 +5,16 @@ import { editModeMap } from '@/constants/editApp';
55import { useLoading } from '@/hooks/useLoading' ;
66import { useToast } from '@/hooks/useToast' ;
77import { YamlItemType } from '@/types' ;
8- import { TemplateSourceType , TemplateType } from '@/types/app' ;
8+ import { TemplateSourceType } from '@/types/app' ;
99import { EnvResponse } from '@/types/index' ;
1010import { serviceSideProps } from '@/utils/i18n' ;
11- import {
12- developGenerateYamlList ,
13- handleTemplateToInstanceYaml ,
14- parseTemplateString ,
15- getYamlSource
16- } from '@/utils/json-yaml' ;
17- import { getTemplateInputDefaultValues , getTemplateValues } from '@/utils/template' ;
11+ import { getYamlSource } from '@/utils/json-yaml' ;
12+ import { generateYamlData , getTemplateInputDefaultValues } from '@/utils/template' ;
1813import { downLoadBold } from '@/utils/tools' ;
19- import { Button , Center , Flex , Spinner , Text } from '@chakra-ui/react' ;
14+ import { Button , Flex , Text } from '@chakra-ui/react' ;
2015import { useQuery } from '@tanstack/react-query' ;
2116import dayjs from 'dayjs' ;
22- import { debounce , has , isObject , mapValues } from 'lodash' ;
17+ import { debounce , has , isObject } from 'lodash' ;
2318import { useTranslation } from 'next-i18next' ;
2419import { useCallback , useEffect , useRef , useState } from 'react' ;
2520import { useForm } from 'react-hook-form' ;
@@ -48,25 +43,6 @@ export default function Develop() {
4843 }
4944 ) ;
5045
51- const generateYamlData = useCallback (
52- ( yamlSource : TemplateSourceType , inputs : Record < string , string > = { } ) : YamlItemType [ ] => {
53- const { defaults, defaultInputs } = getTemplateValues ( yamlSource ) ;
54- const data = {
55- ...platformEnvs ,
56- ...yamlSource ?. source ,
57- inputs : {
58- ...defaultInputs ,
59- ...inputs
60- } ,
61- defaults : defaults
62- } ;
63- const generateStr = parseTemplateString ( yamlSource . appYaml , data ) ;
64- const _instanceName = yamlSource ?. source ?. defaults ?. app_name ?. value || '' ;
65- return developGenerateYamlList ( generateStr , _instanceName ) ;
66- } ,
67- [ platformEnvs ]
68- ) ;
69-
7046 const parseTemplate = useCallback (
7147 ( str : string ) => {
7248 if ( ! str || ! str . trim ( ) ) {
@@ -78,7 +54,7 @@ export default function Develop() {
7854 const result = getYamlSource ( str , platformEnvs ) ;
7955 const formInputs = formHook . getValues ( ) ;
8056 setTemplateSource ( result ) ;
81- const correctYamlList = generateYamlData ( result , formInputs ) ;
57+ const correctYamlList = generateYamlData ( result , formInputs , platformEnvs ) ;
8258 setYamlList ( correctYamlList ) ;
8359 } catch ( error : any ) {
8460 toast ( {
@@ -90,7 +66,7 @@ export default function Develop() {
9066 } ) ;
9167 }
9268 } ,
93- [ platformEnvs , generateYamlData ]
69+ [ platformEnvs ]
9470 ) ;
9571
9672 const onYamlChange = useCallback (
0 commit comments