-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create PR page * Integrate List API * Fix Creation function * Extract BranchesSelection to a component * Fix dates * Improve error handling * Update page width * Fix error handling
- Loading branch information
Showing
8 changed files
with
225 additions
and
143 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
74 changes: 74 additions & 0 deletions
74
webui/src/lib/components/repository/compareBranchesSelection.jsx
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,74 @@ | ||
import React, {useCallback} from "react"; | ||
import {useRouter} from "../../hooks/router"; | ||
import RefDropdown from "./refDropdown"; | ||
import {ArrowLeftIcon, ArrowSwitchIcon} from "@primer/octicons-react"; | ||
import OverlayTrigger from "react-bootstrap/OverlayTrigger"; | ||
import Tooltip from "react-bootstrap/Tooltip"; | ||
import Button from "react-bootstrap/Button"; | ||
|
||
const CompareBranchesSelection = ( | ||
{repo, reference, compareReference, baseSelectURL, withCommits, withWorkspace, withTags} | ||
) => { | ||
const router = useRouter(); | ||
|
||
const handleSwitchRefs = useCallback((e) => { | ||
e.preventDefault(); | ||
router.push({ | ||
pathname: baseSelectURL, | ||
params: {repoId: repo.id}, | ||
query: {ref: compareReference.id, compare: reference.id} | ||
}); | ||
}, []); | ||
|
||
const route = query => router.push({ | ||
pathname: baseSelectURL, | ||
params: {repoId: repo.id}, | ||
query | ||
}); | ||
|
||
const onSelectRef = reference => route(compareReference ? | ||
{ref: reference.id, compare: compareReference.id} : | ||
{ref: reference.id} | ||
); | ||
const onSelectCompare = compareReference => route(reference ? | ||
{ref: reference.id, compare: compareReference.id} : | ||
{compare: compareReference.id} | ||
); | ||
|
||
|
||
return <> | ||
<RefDropdown | ||
prefix={'Base '} | ||
repo={repo} | ||
selected={(reference) ? reference : null} | ||
withCommits={withCommits} | ||
withWorkspace={withWorkspace} | ||
withTags={withTags} | ||
selectRef={onSelectRef}/> | ||
|
||
<ArrowLeftIcon className="me-2 mt-2" size="small" verticalAlign="middle"/> | ||
|
||
<RefDropdown | ||
prefix={'Compared to '} | ||
emptyText={'Compare with...'} | ||
repo={repo} | ||
selected={(compareReference) ? compareReference : null} | ||
withCommits={withCommits} | ||
withWorkspace={withWorkspace} | ||
withTags={withTags} | ||
selectRef={onSelectCompare}/> | ||
|
||
<OverlayTrigger placement="bottom" overlay={ | ||
<Tooltip>Switch directions</Tooltip> | ||
}> | ||
<span> | ||
<Button variant={"link"} | ||
onClick={handleSwitchRefs}> | ||
<ArrowSwitchIcon className="me-2 mt-2" size="small" verticalAlign="middle"/> | ||
</Button> | ||
</span> | ||
</OverlayTrigger> | ||
</>; | ||
}; | ||
|
||
export default CompareBranchesSelection; |
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.