-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graphql, Web: compare commits, tags, branches and show diffs #349
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
876cebc
commit selectors, show diff
liuliu-dev 4b7941b
view diff of remote and local branches
liuliu-dev 40fe949
diff for tags
liuliu-dev b34b9dc
branches diff, ui
liuliu-dev ec3f037
use commit id instead of tag name to avoid url decoding error
liuliu-dev c8b46d5
Merge remote-tracking branch 'origin/main' into liuliu/commit-comparison
liuliu-dev f09baaf
move diff selectors to compare page
liuliu-dev 18483ec
clean up
liuliu-dev 6533788
move selectors to white section
liuliu-dev 7202722
ui fixes
liuliu-dev 857d69c
test
liuliu-dev 41bf601
center
liuliu-dev 6c76133
center align
liuliu-dev f19c1bc
nav, upload page
liuliu-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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].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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import Page404 from "@components/Page404"; | ||
import { Loader } from "@dolthub/react-components"; | ||
import { Button, Loader } from "@dolthub/react-components"; | ||
import { useAnchorTag, useReactiveWidth } from "@dolthub/react-hooks"; | ||
import { CommitForHistoryFragment } from "@gen/graphql-types"; | ||
import Link from "@components/links/Link"; | ||
import { useCommitListForBranch } from "@hooks/useCommitListForBranch"; | ||
import { RefParams } from "@lib/params"; | ||
import { compare } from "@lib/urls"; | ||
import { useRouter } from "next/router"; | ||
import { useEffect, useState } from "react"; | ||
import InfiniteScroll from "react-infinite-scroller"; | ||
|
@@ -50,7 +52,12 @@ function Inner({ commits, ...props }: InnerProps) { | |
<div className={css.container}> | ||
<div className={css.top}> | ||
<h1 className={css.title}>Commit Log</h1> | ||
<CommitGraphButton params={props.params} /> | ||
<div className={css.buttons}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can use |
||
<Link {...compare(props.params)}> | ||
<Button className={css.button}>Diff Commits</Button> | ||
</Link> | ||
<CommitGraphButton params={props.params} /> | ||
</div> | ||
</div> | ||
<InfiniteScroll | ||
loadMore={props.loadMore} | ||
|
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 |
---|---|---|
|
@@ -108,3 +108,7 @@ | |
@apply block ml-2; | ||
} | ||
} | ||
|
||
.button { | ||
@apply mr-4; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot
tagOptions
?