Minor change to disable Review changes button (#197)

* Minor change to disable Review changes button

* Update PR listing icons
This commit is contained in:
Tan Nhu 2023-01-12 21:04:08 -08:00 committed by GitHub
parent 517166965b
commit b7e0f6cce5
12 changed files with 106 additions and 41 deletions

View File

@ -99,7 +99,7 @@ export const ReviewDecisionButton: React.FC<ReviewDecisionButtonProps> = ({
text={getString('submitReview')}
size={ButtonSize.SMALL}
onClick={submitReview}
disabled={!(comment || '').trim().length}
disabled={!(comment || '').trim().length && decision === PullReqReviewDecision.PENDING}
loading={loading}
/>
</Container>

View File

@ -6,7 +6,7 @@ import { useAppContext } from 'AppContext'
import { useGetRepositoryMetadata } from 'hooks/useGetRepositoryMetadata'
import { useStrings } from 'framework/strings'
import { RepositoryPageHeader } from 'components/RepositoryPageHeader/RepositoryPageHeader'
import { getErrorMessage } from 'utils/Utils'
import { getErrorMessage, LIST_FETCHING_LIMIT } from 'utils/Utils'
import emptyStateImage from 'images/empty-state.svg'
import { makeDiffRefs } from 'utils/GitUtils'
import { CommitsView } from 'components/CommitsView/CommitsView'
@ -22,6 +22,7 @@ export default function Compare() {
const { repoMetadata, error, loading, diffRefs } = useGetRepositoryMetadata()
const [sourceGitRef, setSourceGitRef] = useState(diffRefs.sourceGitRef)
const [targetGitRef, setTargetGitRef] = useState(diffRefs.targetGitRef)
const [after] = useState('')
const {
data: commits,
error: commitsError,
@ -30,7 +31,10 @@ export default function Compare() {
} = useGet<RepoCommit[]>({
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
queryParams: {
git_ref: sourceGitRef
limit: LIST_FETCHING_LIMIT,
page: 1,
git_ref: sourceGitRef,
after
},
lazy: !repoMetadata
})

View File

@ -39,6 +39,7 @@ export function CompareContentHeader({
onSelect={onTargetGitRefChanged}
labelPrefix={getString('prefixBase')}
placeHolder={getString('selectBranchPlaceHolder')}
style={{ '--background-color': 'var(--white)' } as React.CSSProperties}
/>
<Icon name="arrow-left" size={14} />
<BranchTagSelect
@ -49,6 +50,7 @@ export function CompareContentHeader({
onSelect={onSourceGitRefChanged}
labelPrefix={getString('prefixCompare')}
placeHolder={getString('selectBranchPlaceHolder')}
style={{ '--background-color': 'var(--white)' } as React.CSSProperties}
/>
<MergeableLabel mergeable />
<FlexExpander />

View File

@ -12,9 +12,41 @@
font-weight: 600;
}
}
.titleRow {
padding-left: var(--spacing-medium);
align-items: center;
}
}
.noData > div {
height: calc(100vh - var(--page-header-height, 64px) - 120px) !important;
}
}
.rowImg {
padding: 4px;
width: 28px;
height: 28px;
border-radius: 4px;
&.open {
background-color: var(--green-50);
}
&.merged {
background-color: var(--blue-50);
}
&.closed {
background-color: var(--grey-50);
}
&.rejected {
background-color: var(--red-50);
}
&.draft {
background-color: var(--orange-100);
}
}

View File

@ -5,6 +5,13 @@ declare const styles: {
readonly table: string
readonly row: string
readonly title: string
readonly titleRow: string
readonly noData: string
readonly rowImg: string
readonly open: string
readonly merged: string
readonly closed: string
readonly rejected: string
readonly draft: string
}
export default styles

View File

@ -11,6 +11,7 @@ import {
StringSubstitute,
NoDataCard
} from '@harness/uicore'
import cx from 'classnames'
import { useHistory } from 'react-router-dom'
import { useGet } from 'restful-react'
import type { CellProps, Column } from 'react-table'
@ -29,6 +30,7 @@ import prImgOpen from './pull-request-open.svg'
import prImgMerged from './pull-request-merged.svg'
import prImgClosed from './pull-request-closed.svg'
import prImgRejected from './pull-request-rejected.svg'
import prImgDraft from './pull-request-draft.svg'
import css from './PullRequests.module.scss'
export default function PullRequests() {
@ -80,8 +82,8 @@ export default function PullRequests() {
width: '100%',
Cell: ({ row }: CellProps<TypesPullReq>) => {
return (
<Layout.Horizontal spacing="medium" padding={{ left: 'medium' }}>
<img src={stateToImage(row.original)} title={row.original.state} />
<Layout.Horizontal className={css.titleRow} spacing="medium">
<img {...stateToImageProps(row.original)} />
<Container padding={{ left: 'small' }}>
<Layout.Vertical spacing="small">
<Text icon="success-tick" color={Color.GREY_800} className={css.title}>
@ -179,17 +181,32 @@ export default function PullRequests() {
)
}
const stateToImage = (pr: TypesPullReq) => {
const stateToImageProps = (pr: TypesPullReq) => {
let src = prImgClosed
let clazz = css.open
switch (pr.state) {
case PullRequestFilterOption.OPEN:
return prImgOpen
src = prImgOpen
clazz = css.open
break
case PullRequestFilterOption.MERGED:
return prImgMerged
src = prImgMerged
clazz = css.merged
break
case PullRequestFilterOption.CLOSED:
return prImgClosed
src = prImgClosed
clazz = css.closed
break
case PullRequestFilterOption.REJECTED:
return prImgRejected
src = prImgRejected
clazz = css.rejected
break
case PullRequestFilterOption.DRAFT:
src = prImgDraft
clazz = css.draft
break
}
return prImgClosed
return { src, title: pr.state, className: cx(css.rowImg, clazz) }
}

View File

@ -1,7 +1,7 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="4.64844" cy="4.65039" r="2.25" stroke="#383946"/>
<path d="M4.64844 6.84475V12.4926V17.1981" stroke="#383946"/>
<circle cx="4.64844" cy="19.1768" r="2.25" stroke="#383946"/>
<path d="M19.3438 3.92676V16.9268" stroke="#383946" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="2 2"/>
<circle cx="19.3438" cy="19.1768" r="2.25" stroke="#383946"/>
<svg viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.349 4.88354C4.349 6.41873 5.57572 7.66324 7.08895 7.66324H8.31234" stroke="#4F5162"/>
<ellipse cx="9.60742" cy="7.7561" rx="1.3125" ry="1.3125" stroke="#4F5162"/>
<ellipse cx="4.34033" cy="3.104" rx="1.3125" ry="1.3125" stroke="#4F5162"/>
<path d="M4.34033 4.4165V10.4321" stroke="#4F5162"/>
<ellipse cx="4.34033" cy="11.8535" rx="1.3125" ry="1.3125" stroke="#4F5162"/>
</svg>

Before

Width:  |  Height:  |  Size: 475 B

After

Width:  |  Height:  |  Size: 462 B

View File

@ -0,0 +1,7 @@
<svg viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<ellipse cx="2.71155" cy="2.7124" rx="1.3125" ry="1.3125" stroke="#C05809"/>
<path d="M2.71155 3.99244V7.28702V10.0319" stroke="#C05809"/>
<ellipse cx="2.71155" cy="11.1858" rx="1.3125" ry="1.3125" stroke="#C05809"/>
<path d="M11.2838 2.28996V9.87329" stroke="#C05809" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="2 2"/>
<ellipse cx="11.2838" cy="11.1858" rx="1.3125" ry="1.3125" stroke="#C05809"/>
</svg>

After

Width:  |  Height:  |  Size: 499 B

View File

@ -1,8 +1,7 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<ellipse cx="4.51611" cy="4.2373" rx="2.25" ry="2.25" stroke="#592baa"/>
<path d="M4.51611 6.43166V12.0795V16.785" stroke="#592baa"/>
<ellipse cx="4.51611" cy="19.2373" rx="2.25" ry="2.25" stroke="#592baa"/>
<path d="M14.506 7.60547L10.7088 4.7207M10.7088 4.7207L14.506 1.82822M10.7088 4.7207H16.7878" stroke="#592baa" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M13.7483 4.71635H18.8538C19.1299 4.71635 19.3538 4.9402 19.3538 5.21635V16.5127" stroke="#592baa" stroke-linecap="round" stroke-linejoin="round"/>
<ellipse cx="19.4841" cy="19.2373" rx="2.25" ry="2.25" stroke="#592baa"/>
</svg>
<svg viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.349 4.88354C4.349 6.41873 5.57572 7.66324 7.08895 7.66324H8.31234" stroke="#3A39B1"/>
<ellipse cx="9.60742" cy="7.7561" rx="1.3125" ry="1.3125" stroke="#3A39B1"/>
<ellipse cx="4.34033" cy="3.104" rx="1.3125" ry="1.3125" stroke="#3A39B1"/>
<path d="M4.34033 4.4165V10.4321" stroke="#3A39B1"/>
<ellipse cx="4.34033" cy="11.8535" rx="1.3125" ry="1.3125" stroke="#3A39B1"/>
</svg>

Before

Width:  |  Height:  |  Size: 700 B

After

Width:  |  Height:  |  Size: 462 B

View File

@ -1,8 +1,3 @@
<svg width="24" height="24" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="3.01074" cy="2.82495" r="1.5" stroke="#1B841D"/>
<path d="M3.01074 4.28779V8.05302V11.19" stroke="#1B841D"/>
<circle cx="3.01074" cy="12.825" r="1.5" stroke="#1B841D"/>
<path d="M9.67068 5.07043L7.13925 3.14726M7.13925 3.14726L9.67068 1.21893M7.13925 3.14726H11.1919" stroke="#1B841D" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M9.16538 3.14468H12.4023C12.6785 3.14468 12.9023 3.36854 12.9023 3.64468V11.0089" stroke="#1B841D" stroke-linecap="round" stroke-linejoin="round"/>
<circle cx="12.9893" cy="12.825" r="1.5" stroke="#1B841D"/>
<svg viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.50975 3.2073H9.51617C9.78309 3.2073 10.0391 3.3169 10.2278 3.51198C10.4166 3.70706 10.5226 3.97164 10.5226 4.24752V8.49683C10.8585 8.61952 11.1416 8.86101 11.3219 9.17859C11.5022 9.49618 11.568 9.86941 11.5078 10.2323C11.4476 10.5952 11.2652 10.9245 10.9928 11.1618C10.7204 11.3991 10.3756 11.5293 10.0194 11.5293C9.66313 11.5293 9.31835 11.3991 9.04599 11.1618C8.77362 10.9245 8.5912 10.5952 8.53098 10.2323C8.47076 9.86941 8.53661 9.49618 8.71689 9.17859C8.89718 8.86101 9.18028 8.61952 9.51617 8.49683V4.24752H8.50975V5.80786L6.2453 3.72741L8.50975 1.64697V3.2073ZM3.47763 5.19933C3.14174 5.07663 2.85864 4.83515 2.67835 4.51756C2.49807 4.19998 2.43222 3.82674 2.49244 3.46383C2.55266 3.10091 2.73508 2.77169 3.00745 2.53435C3.27981 2.29701 3.62459 2.16683 3.98084 2.16683C4.3371 2.16683 4.68188 2.29701 4.95424 2.53435C5.22661 2.77169 5.40903 3.10091 5.46925 3.46383C5.52947 3.82674 5.46362 4.19998 5.28334 4.51756C5.10305 4.83515 4.81995 5.07663 4.48406 5.19933V8.49683C4.81995 8.61952 5.10305 8.86101 5.28334 9.17859C5.46362 9.49618 5.52947 9.86941 5.46925 10.2323C5.40903 10.5952 5.22661 10.9245 4.95424 11.1618C4.68188 11.3991 4.3371 11.5293 3.98084 11.5293C3.62459 11.5293 3.27981 11.3991 3.00745 11.1618C2.73508 10.9245 2.55266 10.5952 2.49244 10.2323C2.43222 9.86941 2.49807 9.49618 2.67835 9.17859C2.85864 8.86101 3.14174 8.61952 3.47763 8.49683V5.19933ZM3.98084 4.24752C4.1143 4.24752 4.2423 4.19273 4.33667 4.09519C4.43104 3.99765 4.48406 3.86536 4.48406 3.72741C4.48406 3.58947 4.43104 3.45718 4.33667 3.35964C4.2423 3.2621 4.1143 3.2073 3.98084 3.2073C3.84738 3.2073 3.71939 3.2621 3.62502 3.35964C3.53065 3.45718 3.47763 3.58947 3.47763 3.72741C3.47763 3.86536 3.53065 3.99765 3.62502 4.09519C3.71939 4.19273 3.84738 4.24752 3.98084 4.24752ZM3.98084 10.4889C4.1143 10.4889 4.2423 10.4341 4.33667 10.3365C4.43104 10.239 4.48406 10.1067 4.48406 9.96874C4.48406 9.8308 4.43104 9.69851 4.33667 9.60097C4.2423 9.50343 4.1143 9.44863 3.98084 9.44863C3.84738 9.44863 3.71939 9.50343 3.62502 9.60097C3.53065 9.69851 3.47763 9.8308 3.47763 9.96874C3.47763 10.1067 3.53065 10.239 3.62502 10.3365C3.71939 10.4341 3.84738 10.4889 3.98084 10.4889ZM10.0194 10.4889C10.1528 10.4889 10.2808 10.4341 10.3752 10.3365C10.4696 10.239 10.5226 10.1067 10.5226 9.96874C10.5226 9.8308 10.4696 9.69851 10.3752 9.60097C10.2808 9.50343 10.1528 9.44863 10.0194 9.44863C9.88593 9.44863 9.75793 9.50343 9.66356 9.60097C9.56919 9.69851 9.51617 9.8308 9.51617 9.96874C9.51617 10.1067 9.56919 10.239 9.66356 10.3365C9.75793 10.4341 9.88593 10.4889 10.0194 10.4889Z" fill="#299B2C"/>
</svg>

Before

Width:  |  Height:  |  Size: 666 B

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -1,8 +1,9 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<ellipse cx="4.51611" cy="4.2373" rx="2.25" ry="2.25" stroke="#4F5162"/>
<path d="M4.51611 6.43166V12.0795V16.785" stroke="#4F5162"/>
<ellipse cx="4.51611" cy="19.2373" rx="2.25" ry="2.25" stroke="#4F5162"/>
<path d="M14.506 7.60547L10.7088 4.7207M10.7088 4.7207L14.506 1.82822M10.7088 4.7207H16.7878" stroke="#4F5162" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M13.7483 4.71635H18.8538C19.1299 4.71635 19.3538 4.9402 19.3538 5.21635V16.5127" stroke="#4F5162" stroke-linecap="round" stroke-linejoin="round"/>
<ellipse cx="19.4841" cy="19.2373" rx="2.25" ry="2.25" stroke="#4F5162"/>
</svg>
<svg viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="3.0625" cy="2.47925" r="1.3125" stroke="#CF2318"/>
<path d="M3.0625 3.75929V7.05386V9.79877" stroke="#CF2318"/>
<circle cx="3.0625" cy="10.9526" r="1.3125" stroke="#CF2318"/>
<path d="M11.0514 4.97371V9.64038" stroke="#CF2318" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="2 2"/>
<ellipse cx="11.0514" cy="10.9529" rx="1.3125" ry="1.3125" stroke="#CF2318"/>
<path d="M9.68445 1.51685L11.2209 3.0533L12.501 4.33341" stroke="#CF2318" stroke-linecap="round"/>
<path d="M12.5007 1.51685L10.9643 3.0533L9.68417 4.33341" stroke="#CF2318" stroke-linecap="round"/>
</svg>

Before

Width:  |  Height:  |  Size: 700 B

After

Width:  |  Height:  |  Size: 668 B

View File

@ -52,7 +52,8 @@ export enum PullRequestState {
OPEN = 'open',
MERGED = 'merged',
CLOSED = 'closed',
REJECTED = 'rejected'
REJECTED = 'rejected',
DRAFT = 'draft'
}
export const PullRequestFilterOption = {