|
8 | 8 | Textarea, |
9 | 9 | HStack |
10 | 10 | } from '@chakra-ui/react'; |
11 | | -import React, { useCallback, useEffect, useMemo } from 'react'; |
| 11 | +import React, { useCallback, useEffect } from 'react'; |
12 | 12 | import MyIcon from '@fastgpt/web/components/common/Icon'; |
13 | 13 | import { useTranslation } from 'next-i18next'; |
14 | 14 | import QuestionTip from '@fastgpt/web/components/common/MyTooltip/QuestionTip'; |
@@ -61,105 +61,91 @@ const ScheduledTriggerConfig = ({ |
61 | 61 | } |
62 | 62 | }, []); |
63 | 63 |
|
64 | | - const Render = useMemo(() => { |
65 | | - return ( |
66 | | - <> |
67 | | - <Flex alignItems={'center'}> |
68 | | - <MyIcon name={'core/app/schedulePlan'} w={'20px'} /> |
69 | | - <HStack ml={2} flex={1} spacing={1}> |
70 | | - <FormLabel color={'myGray.600'}>{t('common:core.app.Interval timer run')}</FormLabel> |
71 | | - <QuestionTip label={t('common:core.app.Interval timer tip')} /> |
72 | | - </HStack> |
73 | | - <MyTooltip label={t('common:core.app.Config schedule plan')}> |
74 | | - <Button |
75 | | - variant={'transparentBase'} |
76 | | - iconSpacing={1} |
77 | | - size={'sm'} |
78 | | - mr={'-5px'} |
79 | | - color={'myGray.600'} |
80 | | - onClick={onOpen} |
81 | | - > |
82 | | - {cronString2Label(value?.cronString ?? '', t)} |
83 | | - </Button> |
84 | | - </MyTooltip> |
85 | | - </Flex> |
| 64 | + return ( |
| 65 | + <> |
| 66 | + <Flex alignItems={'center'}> |
| 67 | + <MyIcon name={'core/app/schedulePlan'} w={'20px'} /> |
| 68 | + <HStack ml={2} flex={1} spacing={1}> |
| 69 | + <FormLabel color={'myGray.600'}>{t('common:core.app.Interval timer run')}</FormLabel> |
| 70 | + <QuestionTip label={t('common:core.app.Interval timer tip')} /> |
| 71 | + </HStack> |
| 72 | + <MyTooltip label={t('common:core.app.Config schedule plan')}> |
| 73 | + <Button |
| 74 | + variant={'transparentBase'} |
| 75 | + iconSpacing={1} |
| 76 | + size={'sm'} |
| 77 | + mr={'-5px'} |
| 78 | + color={'myGray.600'} |
| 79 | + onClick={onOpen} |
| 80 | + > |
| 81 | + {cronString2Label(value?.cronString ?? '', t)} |
| 82 | + </Button> |
| 83 | + </MyTooltip> |
| 84 | + </Flex> |
86 | 85 |
|
87 | | - <MyModal |
88 | | - isOpen={isOpen} |
89 | | - onClose={onClose} |
90 | | - iconSrc={'core/app/schedulePlan'} |
91 | | - title={t('common:core.app.Interval timer config')} |
92 | | - overflow={'unset'} |
93 | | - > |
94 | | - <ModalBody> |
95 | | - <Flex justifyContent={'space-between'} alignItems={'center'}> |
96 | | - <FormLabel flex={'0 0 80px'}>{t('common:core.app.schedule.Open schedule')}</FormLabel> |
97 | | - <Switch |
98 | | - isChecked={isOpenSchedule} |
99 | | - onChange={(e) => { |
100 | | - if (e.target.checked) { |
101 | | - onUpdate({ cronString: defaultCronString }); |
102 | | - } else { |
103 | | - onUpdate({ cronString: '' }); |
104 | | - } |
105 | | - }} |
106 | | - /> |
107 | | - </Flex> |
108 | | - {isOpenSchedule && ( |
109 | | - <> |
110 | | - <Flex alignItems={'center'} mt={5}> |
111 | | - <FormLabel flex={'0 0 80px'}>{t('app:execute_time')}</FormLabel> |
112 | | - <Box flex={'1 0 0'}> |
113 | | - <ScheduleTimeSelect |
114 | | - cronString={value?.cronString} |
115 | | - onChange={(e) => { |
116 | | - onUpdate({ cronString: e }); |
117 | | - }} |
118 | | - /> |
119 | | - </Box> |
120 | | - </Flex> |
121 | | - <Flex alignItems={'center'} mt={5}> |
122 | | - <FormLabel flex={'0 0 80px'}>{t('app:time_zone')}</FormLabel> |
123 | | - <Box flex={'1 0 0'}> |
124 | | - <TimezoneSelect |
125 | | - value={timezone} |
126 | | - onChange={(e) => { |
127 | | - onUpdate({ timezone: e }); |
128 | | - }} |
129 | | - /> |
130 | | - </Box> |
131 | | - </Flex> |
132 | | - <Box mt={5}> |
133 | | - <FormLabel mb={1}>{t('common:core.app.schedule.Default prompt')}</FormLabel> |
134 | | - <Textarea |
135 | | - value={defaultPrompt} |
136 | | - rows={8} |
137 | | - bg={'myGray.50'} |
138 | | - placeholder={t('common:core.app.schedule.Default prompt placeholder')} |
| 86 | + <MyModal |
| 87 | + isOpen={isOpen} |
| 88 | + onClose={onClose} |
| 89 | + iconSrc={'core/app/schedulePlan'} |
| 90 | + title={t('common:core.app.Interval timer config')} |
| 91 | + overflow={'unset'} |
| 92 | + > |
| 93 | + <ModalBody> |
| 94 | + <Flex justifyContent={'space-between'} alignItems={'center'}> |
| 95 | + <FormLabel flex={'0 0 80px'}>{t('common:core.app.schedule.Open schedule')}</FormLabel> |
| 96 | + <Switch |
| 97 | + isChecked={isOpenSchedule} |
| 98 | + onChange={(e) => { |
| 99 | + if (e.target.checked) { |
| 100 | + onUpdate({ cronString: defaultCronString }); |
| 101 | + } else { |
| 102 | + onUpdate({ cronString: '' }); |
| 103 | + } |
| 104 | + }} |
| 105 | + /> |
| 106 | + </Flex> |
| 107 | + {isOpenSchedule && ( |
| 108 | + <> |
| 109 | + <Flex alignItems={'center'} mt={5}> |
| 110 | + <FormLabel flex={'0 0 80px'}>{t('app:execute_time')}</FormLabel> |
| 111 | + <Box flex={'1 0 0'}> |
| 112 | + <ScheduleTimeSelect |
| 113 | + cronString={value?.cronString} |
139 | 114 | onChange={(e) => { |
140 | | - onUpdate({ defaultPrompt: e.target.value }); |
| 115 | + onUpdate({ cronString: e }); |
141 | 116 | }} |
142 | 117 | /> |
143 | 118 | </Box> |
144 | | - </> |
145 | | - )} |
146 | | - </ModalBody> |
147 | | - </MyModal> |
148 | | - </> |
149 | | - ); |
150 | | - }, [ |
151 | | - defaultPrompt, |
152 | | - isOpen, |
153 | | - isOpenSchedule, |
154 | | - onClose, |
155 | | - onOpen, |
156 | | - onUpdate, |
157 | | - t, |
158 | | - timezone, |
159 | | - value?.cronString |
160 | | - ]); |
161 | | - |
162 | | - return Render; |
| 119 | + </Flex> |
| 120 | + <Flex alignItems={'center'} mt={5}> |
| 121 | + <FormLabel flex={'0 0 80px'}>{t('app:time_zone')}</FormLabel> |
| 122 | + <Box flex={'1 0 0'}> |
| 123 | + <TimezoneSelect |
| 124 | + value={timezone} |
| 125 | + onChange={(e) => { |
| 126 | + onUpdate({ timezone: e }); |
| 127 | + }} |
| 128 | + /> |
| 129 | + </Box> |
| 130 | + </Flex> |
| 131 | + <Box mt={5}> |
| 132 | + <FormLabel mb={1}>{t('common:core.app.schedule.Default prompt')}</FormLabel> |
| 133 | + <Textarea |
| 134 | + value={defaultPrompt} |
| 135 | + rows={8} |
| 136 | + bg={'myGray.50'} |
| 137 | + placeholder={t('common:core.app.schedule.Default prompt placeholder')} |
| 138 | + onChange={(e) => { |
| 139 | + onUpdate({ defaultPrompt: e.target.value }); |
| 140 | + }} |
| 141 | + /> |
| 142 | + </Box> |
| 143 | + </> |
| 144 | + )} |
| 145 | + </ModalBody> |
| 146 | + </MyModal> |
| 147 | + </> |
| 148 | + ); |
163 | 149 | }; |
164 | 150 |
|
165 | 151 | export default React.memo(ScheduledTriggerConfig); |
0 commit comments