Skip to content
This repository was archived by the owner on May 30, 2024. It is now read-only.

Commit e077536

Browse files
author
Noah Hanjun Lee
authored
Add 'Approve and Deploy' button (#214)
1 parent 8031672 commit e077536

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

ui/src/components/ReviewModal.tsx

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { useState } from "react"
22
import { Button, Modal, Space, Input } from "antd"
33

4-
import { Review } from "../models"
4+
import { Review, ReviewStatusEnum } from "../models"
55

66
const { TextArea } = Input
77

88
interface ReviewModalProps {
99
review: Review
1010
onClickApprove(comment: string): void
11+
onClickApproveAndDeploy(comment: string): void
1112
onClickReject(comment: string): void
1213
}
1314

@@ -29,6 +30,11 @@ export default function ReviewModal(props: ReviewModalProps): JSX.Element {
2930
setIsModalVisible(false)
3031
}
3132

33+
const onClickApproveAndDeploy = () => {
34+
props.onClickApproveAndDeploy(comment)
35+
setIsModalVisible(false)
36+
}
37+
3238
const onClickReject = () => {
3339
props.onClickReject(comment)
3440
setIsModalVisible(false)
@@ -46,16 +52,22 @@ export default function ReviewModal(props: ReviewModalProps): JSX.Element {
4652
onCancel={onClickCancel}
4753
footer={
4854
<Space>
49-
<Button onClick={onClickReject}>Reject</Button>
55+
<Button type="primary" danger onClick={onClickReject}>Reject</Button>
56+
<Button type="primary" onClick={onClickApproveAndDeploy}>Approve and Deploy</Button>
5057
<Button type="primary" onClick={onClickApprove}>Approve</Button>
5158
</Space>
5259
}
5360
>
5461
<TextArea rows={3} onChange={onChangeComment} value={comment}/>
5562
</Modal>
56-
<Button type="primary" onClick={showModal}>
57-
Review
58-
</Button>
63+
{(props.review.status === ReviewStatusEnum.Pending)?
64+
<Button type="primary" onClick={showModal}>
65+
Review
66+
</Button> :
67+
<Button onClick={showModal}>
68+
Reviewed
69+
</Button>
70+
}
5971
</>
6072
)
6173

ui/src/views/Deployment.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,20 @@ export default function DeploymentView(): JSX.Element {
7272
dispatch(deployToSCM())
7373
}
7474

75-
const onClickApprove = (comment: string) => {
75+
const onClickApproveAndDeploy = (comment: string) => {
7676
const f = async () => {
7777
await dispatch(approve(comment))
78+
if (deployment?.status === DeploymentStatusEnum.Waiting) {
79+
await dispatch(deployToSCM())
80+
}
7881
}
7982
f()
8083
}
8184

85+
const onClickApprove = (comment: string) => {
86+
dispatch(approve(comment))
87+
}
88+
8289
const onClickReject = (comment: string) => {
8390
dispatch(reject(comment))
8491
}
@@ -112,6 +119,7 @@ export default function DeploymentView(): JSX.Element {
112119
<ReviewModal
113120
key={0}
114121
review={userReview}
122+
onClickApproveAndDeploy={onClickApproveAndDeploy}
115123
onClickApprove={onClickApprove}
116124
onClickReject={onClickReject}
117125
/>:

0 commit comments

Comments
 (0)