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

Add 'Approve and Deploy' button #214

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions ui/src/components/ReviewModal.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useState } from "react"
import { Button, Modal, Space, Input } from "antd"

import { Review } from "../models"
import { Review, ReviewStatusEnum } from "../models"

const { TextArea } = Input

interface ReviewModalProps {
review: Review
onClickApprove(comment: string): void
onClickApproveAndDeploy(comment: string): void
onClickReject(comment: string): void
}

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

const onClickApproveAndDeploy = () => {
props.onClickApproveAndDeploy(comment)
setIsModalVisible(false)
}

const onClickReject = () => {
props.onClickReject(comment)
setIsModalVisible(false)
Expand All @@ -46,16 +52,22 @@ export default function ReviewModal(props: ReviewModalProps): JSX.Element {
onCancel={onClickCancel}
footer={
<Space>
<Button onClick={onClickReject}>Reject</Button>
<Button type="primary" danger onClick={onClickReject}>Reject</Button>
<Button type="primary" onClick={onClickApproveAndDeploy}>Approve and Deploy</Button>
<Button type="primary" onClick={onClickApprove}>Approve</Button>
</Space>
}
>
<TextArea rows={3} onChange={onChangeComment} value={comment}/>
</Modal>
<Button type="primary" onClick={showModal}>
Review
</Button>
{(props.review.status === ReviewStatusEnum.Pending)?
<Button type="primary" onClick={showModal}>
Review
</Button> :
<Button onClick={showModal}>
Reviewed
</Button>
}
</>
)

Expand Down
10 changes: 9 additions & 1 deletion ui/src/views/Deployment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,20 @@ export default function DeploymentView(): JSX.Element {
dispatch(deployToSCM())
}

const onClickApprove = (comment: string) => {
const onClickApproveAndDeploy = (comment: string) => {
const f = async () => {
await dispatch(approve(comment))
if (deployment?.status === DeploymentStatusEnum.Waiting) {
await dispatch(deployToSCM())
}
Comment on lines +78 to +80
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy it when the status is waiting.

}
f()
}

const onClickApprove = (comment: string) => {
dispatch(approve(comment))
}

const onClickReject = (comment: string) => {
dispatch(reject(comment))
}
Expand Down Expand Up @@ -112,6 +119,7 @@ export default function DeploymentView(): JSX.Element {
<ReviewModal
key={0}
review={userReview}
onClickApproveAndDeploy={onClickApproveAndDeploy}
onClickApprove={onClickApprove}
onClickReject={onClickReject}
/>:
Expand Down