-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #349 from dolthub/liuliu/commit-comparison
Graphql, Web: compare commits, tags, branches and show diffs
- Loading branch information
Showing
25 changed files
with
267 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
web/renderer/components/DiffSelector/ForBranchCommitAndTag.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { RefParams } from "@lib/params"; | ||
import BranchCommitAndTagSelector from "@components/FormSelectForRefs/BranchCommitAndTagSelector"; | ||
import { useState } from "react"; | ||
import { BsArrowLeft } from "@react-icons/all-files/bs/BsArrowLeft"; | ||
import Link from "@components/links/Link"; | ||
import { diff } from "@lib/urls"; | ||
import { Button } from "@dolthub/react-components"; | ||
import DiffSelector from "./component"; | ||
import css from "./index.module.css"; | ||
|
||
type Props = { | ||
params: RefParams; | ||
}; | ||
|
||
export default function ForBranchCommitAndTag({ params }: Props) { | ||
const [fromRef, setFromRef] = useState(""); | ||
const [toRef, setToRef] = useState(""); | ||
|
||
return ( | ||
<DiffSelector> | ||
<div className={css.container}> | ||
<div className={css.top}> | ||
<div className={css.title}>Pick to revision</div> | ||
<div className={css.title}>Pick from revision</div> | ||
</div> | ||
<div className={css.selectors}> | ||
<div className={css.branchCommitTag}> | ||
<BranchCommitAndTagSelector | ||
params={params} | ||
selectedValue={toRef} | ||
onChangeValue={s => setToRef(s || "")} | ||
/> | ||
</div> | ||
<div className={css.arrow}> | ||
<BsArrowLeft /> | ||
</div> | ||
<div className={css.branchCommitTag}> | ||
<BranchCommitAndTagSelector | ||
params={params} | ||
selectedValue={fromRef} | ||
onChangeValue={s => setFromRef(s || "")} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
{fromRef && toRef && ( | ||
<Link | ||
{...diff({ | ||
...params, | ||
fromCommitId: fromRef, | ||
toCommitId: toRef, | ||
})} | ||
className={css.viewDiffButton} | ||
> | ||
<Button disabled={fromRef === toRef} className={css.button}> | ||
View Diff | ||
</Button> | ||
</Link> | ||
)} | ||
</DiffSelector> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import DiffSelector from "./component"; | ||
import ForBranch from "./ForBranch"; | ||
import ForBranchCommitAndTag from "./ForBranchCommitAndTag"; | ||
import ForPull from "./ForPull"; | ||
|
||
export default Object.assign(DiffSelector, { | ||
ForBranch, | ||
ForPull, | ||
ForBranchCommitAndTag, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
web/renderer/components/FormSelectForRefs/BranchCommitAndTagSelector.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { FormSelect } from "@dolthub/react-components"; | ||
import { Maybe } from "@dolthub/web-utils"; | ||
import { OptionalRefParams } from "@lib/params"; | ||
import useGetBranchOptionsForSelect from "@components/FormSelectForRefs/useGetBranchOptionsForSelect"; | ||
import useGetCommitOptionsForSelect from "@components/FormSelectForRefs/useGetCommitOptionsForSelect"; | ||
import getGroupOption from "./getGroupOption"; | ||
import useGetTagOptionsForSelect from "./useGetTagOptionsForSelect"; | ||
import css from "./index.module.css"; | ||
|
||
type Props = { | ||
params: OptionalRefParams; | ||
selectedValue: Maybe<string>; | ||
onChangeValue: (s: Maybe<string>) => void; | ||
}; | ||
|
||
export default function BranchCommitAndTagSelector(props: Props) { | ||
const { | ||
branchOptions, | ||
error: branchErr, | ||
loading: branchLoading, | ||
} = useGetBranchOptionsForSelect(props.params); | ||
const { | ||
commitOptions, | ||
error: commitErr, | ||
loading: commitLoading, | ||
} = useGetCommitOptionsForSelect(props.params); | ||
const { | ||
tagOptions, | ||
error: tagErr, | ||
loading: tagLoading, | ||
} = useGetTagOptionsForSelect(props.params); | ||
|
||
const handleChangeRef = async (refName: Maybe<string>) => { | ||
if (!refName) return; | ||
props.onChangeValue(refName); | ||
}; | ||
|
||
const options = [ | ||
getGroupOption(branchOptions, "Branches", undefined, branchErr), | ||
getGroupOption(commitOptions, "Commits", undefined, commitErr), | ||
getGroupOption(tagOptions, "Tags", undefined, tagErr), | ||
]; | ||
|
||
return ( | ||
<FormSelect.Grouped | ||
isLoading={branchLoading || commitLoading || tagLoading} | ||
value={[...branchOptions, ...commitOptions, ...tagOptions].find( | ||
t => t.value === props.selectedValue, | ||
)} | ||
onChange={async e => handleChangeRef(e?.value)} | ||
options={options} | ||
placeholder="select a branch, commit or tag..." | ||
className={css.branchAndCommitSelect} | ||
selectedOptionFirst | ||
light | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,3 +69,7 @@ | |
.iconGray { | ||
@apply fill-storm-200; | ||
} | ||
|
||
.button { | ||
@apply mr-4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.