@@ -3,8 +3,8 @@ import { shallowEqual } from "react-redux";
3
3
import { useParams } from "react-router-dom" ;
4
4
import { PageHeader , Result , Button } from "antd" ;
5
5
6
- import { useAppSelector , useAppDispatch } from "../redux/hooks"
7
- import { DeploymentType , Branch , Commit , Tag , RequestStatus , Env } from "../models" ;
6
+ import { useAppSelector , useAppDispatch } from "../../ redux/hooks"
7
+ import { DeploymentType , Branch , Commit , Tag , RequestStatus , Env } from "../../ models" ;
8
8
import {
9
9
fetchConfig ,
10
10
repoDeploySlice ,
@@ -21,20 +21,18 @@ import {
21
21
searchCandidates ,
22
22
fetchUser ,
23
23
deploy
24
- } from "../redux/repoDeploy"
25
-
26
- import DeployForm , { Option } from "../components/DeployForm"
27
- import DynamicPayloadModal from "../components/DynamicPayloadModal" ;
24
+ } from "../../redux/repoDeploy"
25
+ import DeployForm , { DeployFormProps , Option } from "./DeployForm"
26
+ import DynamicPayloadModal , { DynamicPayloadModalProps } from "./DynamicPayloadModal"
28
27
29
28
const { actions } = repoDeploySlice
30
29
31
- interface Params {
32
- namespace : string
33
- name : string
34
- }
30
+ export default ( ) : JSX . Element => {
31
+ const { namespace, name } = useParams < {
32
+ namespace : string
33
+ name : string
34
+ } > ( )
35
35
36
- export default function RepoDeploy ( ) : JSX . Element {
37
- const { namespace, name } = useParams < Params > ( )
38
36
const {
39
37
display,
40
38
config,
@@ -48,9 +46,8 @@ export default function RepoDeploy(): JSX.Element {
48
46
tags,
49
47
tagStatuses,
50
48
deploying } = useAppSelector ( state => state . repoDeploy , shallowEqual )
51
- const dispatch = useAppDispatch ( )
52
49
53
- const [ payloadModalVisible , setPayloadModalVisible ] = useState ( false ) ;
50
+ const dispatch = useAppDispatch ( )
54
51
55
52
useEffect ( ( ) => {
56
53
const f = async ( ) => {
@@ -104,20 +101,11 @@ export default function RepoDeploy(): JSX.Element {
104
101
}
105
102
106
103
const onClickDeploy = ( ) => {
107
- if ( env ?. dynamicPayload ?. enabled ) {
108
- setPayloadModalVisible ( true )
109
- } else {
110
- dispatch ( deploy ( null ) )
111
- }
104
+ dispatch ( deploy ( null ) )
112
105
}
113
106
114
107
const onClickDeployWithPayload = ( values : any ) => {
115
108
dispatch ( deploy ( values ) )
116
- setPayloadModalVisible ( false )
117
- }
118
-
119
- const onClickCancel = ( ) => {
120
- setPayloadModalVisible ( false )
121
109
}
122
110
123
111
if ( ! display ) {
@@ -140,6 +128,81 @@ export default function RepoDeploy(): JSX.Element {
140
128
/>
141
129
)
142
130
}
131
+ return (
132
+ < RepoDeploy
133
+ envs = { envs }
134
+ onSelectEnv = { onSelectEnv }
135
+ onChangeType = { onChangeType }
136
+ currentDeployment = { currentDeployment }
137
+ branches = { branches }
138
+ onSelectBranch = { onSelectBranch }
139
+ onClickAddBranch = { onClickAddBranch }
140
+ branchStatuses = { branchStatuses }
141
+ commits = { commits }
142
+ onSelectCommit = { onSelectCommit }
143
+ onClickAddCommit = { onClickAddCommit }
144
+ commitStatuses = { commitStatuses }
145
+ tags = { tags }
146
+ onSelectTag = { onSelectTag }
147
+ onClickAddTag = { onClickAddTag }
148
+ tagStatuses = { tagStatuses }
149
+ deploying = { deploying === RequestStatus . Pending }
150
+ onClickDeploy = { onClickDeploy }
151
+ env = { env }
152
+ onClickOk = { onClickDeployWithPayload }
153
+ />
154
+ )
155
+ }
156
+
157
+ interface RepoDeployProps extends
158
+ DeployFormProps ,
159
+ Omit < DynamicPayloadModalProps , "visible" | "env" | "onClickCancel" > {
160
+ env ?: Env
161
+ }
162
+
163
+ function RepoDeploy ( {
164
+ // Properities for the DeployForm component.
165
+ envs,
166
+ onSelectEnv,
167
+ onChangeType,
168
+ currentDeployment,
169
+ branches,
170
+ onSelectBranch,
171
+ onClickAddBranch,
172
+ branchStatuses,
173
+ commits,
174
+ onSelectCommit,
175
+ onClickAddCommit,
176
+ commitStatuses,
177
+ tags,
178
+ onSelectTag,
179
+ onClickAddTag,
180
+ tagStatuses,
181
+ deploying,
182
+ onClickDeploy,
183
+ // Properties for the DynamicPayloadModal component.
184
+ env,
185
+ onClickOk,
186
+ } : RepoDeployProps ) : JSX . Element {
187
+
188
+ const [ payloadModalVisible , setPayloadModalVisible ] = useState ( false ) ;
189
+
190
+ const _onClickDeploy = ( ) => {
191
+ if ( env ?. dynamicPayload ?. enabled ) {
192
+ setPayloadModalVisible ( true )
193
+ } else {
194
+ onClickDeploy ( )
195
+ }
196
+ }
197
+
198
+ const _onClickOk = ( values : any ) => {
199
+ onClickOk ( values )
200
+ setPayloadModalVisible ( false )
201
+ }
202
+
203
+ const onClickCancel = ( ) => {
204
+ setPayloadModalVisible ( false )
205
+ }
143
206
144
207
return (
145
208
< div >
@@ -166,14 +229,14 @@ export default function RepoDeploy(): JSX.Element {
166
229
onSelectTag = { onSelectTag }
167
230
onClickAddTag = { onClickAddTag }
168
231
tagStatuses = { tagStatuses }
169
- deploying = { deploying === RequestStatus . Pending }
170
- onClickDeploy = { onClickDeploy }
232
+ deploying = { deploying }
233
+ onClickDeploy = { _onClickDeploy }
171
234
/>
172
235
{ ( env ) ?
173
236
< DynamicPayloadModal
174
237
visible = { payloadModalVisible }
175
238
env = { env }
176
- onClickOk = { onClickDeployWithPayload }
239
+ onClickOk = { _onClickOk }
177
240
onClickCancel = { onClickCancel }
178
241
/>
179
242
:
0 commit comments