Skip to content

Commit

Permalink
fix: Update Repo.File.tsx to use DefaultBranch in Select component
Browse files Browse the repository at this point in the history
  • Loading branch information
lazhenyi committed Feb 24, 2025
1 parent 3e23543 commit 1dbc1e0
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions vite-project/src/app/repo/Repo.File.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,35 +299,39 @@ const RepoFile = (props: RepoFileProps) => {
<Card>
<CardHeader className="repo-file-body-main-header">
<div className="repo-file-body-main-header-left">
<Select
showScrollIndicators={false}
isRequired
disallowEmptySelection
defaultSelectedKeys={[DefaultBranch!.name]}
selectedKeys={[DefaultBranch!.name]} value={DefaultBranch!.name}
className="branch-select"
onSelectionChange={(key) => {
const currentKey = key.currentKey;
if (currentKey) {
const default_branches = Branches.find((value) => value.name === currentKey);
if (default_branches) {
setDafaultBranch(default_branches);
UpdateTree(default_branches).then(() => {
}).catch(() => {
})
}
}
}}>
{
Branches.map(value => {
return (
<SelectItem key={value.name}>
{value.name}
</SelectItem>
)
})
}
</Select>
{
DefaultBranch && (
<Select
showScrollIndicators={false}
isRequired
disallowEmptySelection
defaultSelectedKeys={[DefaultBranch!.name]}
selectedKeys={[DefaultBranch!.name]} value={DefaultBranch!.name}
className="branch-select"
onSelectionChange={(key) => {
const currentKey = key.currentKey;
if (currentKey) {
const default_branches = Branches.find((value) => value.name === currentKey);
if (default_branches) {
setDafaultBranch(default_branches);
UpdateTree(default_branches).then(() => {
}).catch(() => {
})
}
}
}}>
{
Branches.map(value => {
return (
<SelectItem key={value.name}>
{value.name}
</SelectItem>
)
})
}
</Select>
)
}
{
(Head !== null) && (
<div className="head-message">
Expand Down

0 comments on commit 1dbc1e0

Please sign in to comment.