|
| 1 | +import Link from "@components/links/Link"; |
| 2 | +import { Button, ExternalLink, Modal, Radio } from "@dolthub/react-components"; |
| 3 | +import { ConflictResolveType } from "@gen/graphql-types"; |
| 4 | +import { ModalProps } from "@lib/modalProps"; |
| 5 | +import { PullDiffParams } from "@lib/params"; |
| 6 | +import { pullConflicts } from "@lib/urls"; |
| 7 | +import { useState } from "react"; |
| 8 | +import css from "./index.module.css"; |
| 9 | + |
| 10 | +type Props = ModalProps & { |
| 11 | + onClickWithResolve: (resolveType: ConflictResolveType) => Promise<void>; |
| 12 | + params: PullDiffParams; |
| 13 | +}; |
| 14 | + |
| 15 | +export default function ResolveModal(props: Props) { |
| 16 | + const [resType, setResType] = useState<ConflictResolveType>( |
| 17 | + ConflictResolveType.Ours, |
| 18 | + ); |
| 19 | + |
| 20 | + return ( |
| 21 | + <Modal |
| 22 | + title="Resolve Conflicts and Merge" |
| 23 | + isOpen={props.isOpen} |
| 24 | + onRequestClose={() => props.setIsOpen(false)} |
| 25 | + className={css.modal} |
| 26 | + button={ |
| 27 | + <Button onClick={async () => await props.onClickWithResolve(resType)}> |
| 28 | + Choose {resType.toLowerCase()} and merge |
| 29 | + </Button> |
| 30 | + } |
| 31 | + > |
| 32 | + <div> |
| 33 | + <p> |
| 34 | + To merge this pull request, choose a conflict resolution strategy: |
| 35 | + </p> |
| 36 | + <Radio |
| 37 | + label="Use ours" |
| 38 | + name="ours" |
| 39 | + checked={resType === ConflictResolveType.Ours} |
| 40 | + onChange={() => setResType(ConflictResolveType.Ours)} |
| 41 | + /> |
| 42 | + <Radio |
| 43 | + label="Use theirs" |
| 44 | + name="theirs" |
| 45 | + checked={resType === ConflictResolveType.Theirs} |
| 46 | + onChange={() => setResType(ConflictResolveType.Theirs)} |
| 47 | + /> |
| 48 | + <p> |
| 49 | + You can view the table conflicts before merging{" "} |
| 50 | + <Link {...pullConflicts(props.params)}>here</Link>. |
| 51 | + </p> |
| 52 | + <p> |
| 53 | + If you'd like more granular conflict resolution, see{" "} |
| 54 | + <ExternalLink href="https://www.dolthub.com/blog/2021-03-15-programmatic-merge-and-resolve/"> |
| 55 | + this guide |
| 56 | + </ExternalLink> |
| 57 | + . |
| 58 | + </p> |
| 59 | + </div> |
| 60 | + </Modal> |
| 61 | + ); |
| 62 | +} |
0 commit comments