mirror of
https://github.com/harness/drone.git
synced 2025-05-19 02:20:03 +08:00
feat: [code-475]: add delete reviewers (#169)
This commit is contained in:
parent
2dd4d73da5
commit
d6e6110ba0
@ -12,12 +12,14 @@ import {
|
|||||||
FlexExpander,
|
FlexExpander,
|
||||||
ButtonSize,
|
ButtonSize,
|
||||||
Color,
|
Color,
|
||||||
IconName
|
IconName,
|
||||||
|
useToaster
|
||||||
} from '@harness/uicore'
|
} from '@harness/uicore'
|
||||||
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
|
import { OptionsMenuButton } from 'components/OptionsMenuButton/OptionsMenuButton'
|
||||||
import { useMutate } from 'restful-react'
|
import { useMutate } from 'restful-react'
|
||||||
import { useStrings } from 'framework/strings'
|
import { useStrings } from 'framework/strings'
|
||||||
import type { TypesPullReq, TypesRepository } from 'services/code'
|
import type { TypesPullReq, TypesRepository } from 'services/code'
|
||||||
|
import { getErrorMessage } from 'utils/Utils'
|
||||||
import { ReviewerSelect } from 'components/ReviewerSelect/ReviewerSelect'
|
import { ReviewerSelect } from 'components/ReviewerSelect/ReviewerSelect'
|
||||||
import css from './PullRequestSideBar.module.scss'
|
import css from './PullRequestSideBar.module.scss'
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ const PullRequestSideBar = (props: PullRequestSideBarProps) => {
|
|||||||
// const [page] = usePageIndex(1)
|
// const [page] = usePageIndex(1)
|
||||||
const { getString } = useStrings()
|
const { getString } = useStrings()
|
||||||
const tagArr = []
|
const tagArr = []
|
||||||
|
const { showError } = useToaster()
|
||||||
|
|
||||||
const generateReviewDecisionIcon = (
|
const generateReviewDecisionIcon = (
|
||||||
reviewDecision: string
|
reviewDecision: string
|
||||||
@ -100,7 +103,10 @@ const PullRequestSideBar = (props: PullRequestSideBarProps) => {
|
|||||||
verb: 'PUT',
|
verb: 'PUT',
|
||||||
path: `/api/v1/repos/${repoMetadata.path}/+/pullreq/${pullRequestMetadata.number}/reviewers`
|
path: `/api/v1/repos/${repoMetadata.path}/+/pullreq/${pullRequestMetadata.number}/reviewers`
|
||||||
})
|
})
|
||||||
|
const { mutate: removeReviewer } = useMutate({
|
||||||
|
verb: 'DELETE',
|
||||||
|
path: ({ id }) => `/api/v1/repos/${repoMetadata.path}/+/pullreq/${pullRequestMetadata?.number}/reviewers/${id}`
|
||||||
|
})
|
||||||
// const [isOptionsOpen, setOptionsOpen] = React.useState(false)
|
// const [isOptionsOpen, setOptionsOpen] = React.useState(false)
|
||||||
// const [val, setVal] = useState<SelectOption>()
|
// const [val, setVal] = useState<SelectOption>()
|
||||||
//TODO: add actions when you click the options menu button and also api integration when there's optional and required reviwers
|
//TODO: add actions when you click the options menu button and also api integration when there's optional and required reviwers
|
||||||
@ -151,7 +157,9 @@ const PullRequestSideBar = (props: PullRequestSideBarProps) => {
|
|||||||
text={getString('add')}
|
text={getString('add')}
|
||||||
labelPrefix={getString('add')}
|
labelPrefix={getString('add')}
|
||||||
onSelect={function (id: number): void {
|
onSelect={function (id: number): void {
|
||||||
updateCodeCommentStatus({ reviewer_id: id })
|
updateCodeCommentStatus({ reviewer_id: id }).catch(err => {
|
||||||
|
showError(getErrorMessage(err))
|
||||||
|
})
|
||||||
if (refetchReviewers) {
|
if (refetchReviewers) {
|
||||||
refetchReviewers?.()
|
refetchReviewers?.()
|
||||||
}
|
}
|
||||||
@ -202,7 +210,14 @@ const PullRequestSideBar = (props: PullRequestSideBarProps) => {
|
|||||||
{
|
{
|
||||||
isDanger: true,
|
isDanger: true,
|
||||||
text: getString('remove'),
|
text: getString('remove'),
|
||||||
onClick: noop
|
onClick: () => {
|
||||||
|
removeReviewer({}, { pathParams: { id: reviewer.reviewer.id } }).catch(err => {
|
||||||
|
showError(getErrorMessage(err))
|
||||||
|
})
|
||||||
|
if (refetchReviewers) {
|
||||||
|
refetchReviewers?.()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user