Skip to content

Commit

Permalink
feat: file-viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
sans-harness committed Feb 19, 2025
1 parent 540188d commit 64aa996
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const BranchSelectorDropdown: FC<BranchSelectorDropdownProps> = ({
useTranslationStore,
isBranchOnly = false,
searchQuery,
setSearchQuery
setSearchQuery,
dynamicWidth = false
}) => {
const [activeTab, setActiveTab] = useState<BranchSelectorTab>(BranchSelectorTab.BRANCHES)
const { t } = useTranslationStore()
Expand All @@ -38,7 +39,9 @@ export const BranchSelectorDropdown: FC<BranchSelectorDropdownProps> = ({
return (
<DropdownMenu.Content
className="p-0"
style={{ width: 'var(--radix-dropdown-menu-trigger-width)' }}
style={{
width: dynamicWidth ? 'var(--radix-dropdown-menu-trigger-width)' : '298px'
}}
align="start"
onCloseAutoFocus={event => event.preventDefault()} // Prevent focus on hidden content
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface BranchSelectorProps {
isBranchOnly?: boolean
searchQuery?: string
setSearchQuery: (query: string) => void
dynamicWidth?: boolean
}
export const BranchSelector: FC<BranchSelectorProps> = ({
useRepoBranchesStore,
Expand All @@ -25,7 +26,8 @@ export const BranchSelector: FC<BranchSelectorProps> = ({
onSelectBranch,
isBranchOnly = false,
searchQuery = '',
setSearchQuery
setSearchQuery,
dynamicWidth = false
}) => {
const { selectedBranchTag, branchList, tagList, repoId, spaceId } = useRepoBranchesStore()

Expand Down Expand Up @@ -63,6 +65,7 @@ export const BranchSelector: FC<BranchSelectorProps> = ({
useTranslationStore={useTranslationStore}
searchQuery={searchQuery}
setSearchQuery={setSearchQuery}
dynamicWidth={dynamicWidth}
/>
</DropdownMenu.Root>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface BranchSelectorDropdownProps {
isBranchOnly?: boolean
searchQuery: string
setSearchQuery: (query: string) => void
dynamicWidth?: boolean
}

export interface BranchSelectorProps extends BranchSelectorDropdownProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
import { useEffect, useMemo } from 'react'
import { useForm } from 'react-hook-form'

import {
Alert,
Button,
ControlGroup,
Dialog,
Fieldset,
FormWrapper,
Icon,
Input,
Label,
Select,
SelectContent,
SelectItem,
Textarea
} from '@/components'
import { Alert, Button, ControlGroup, Dialog, Fieldset, FormWrapper, Input, Label, Textarea } from '@/components'
import { zodResolver } from '@hookform/resolvers/zod'
import { BranchSelector } from '@views/repo/components'
// import { BranchSelector } from '@views/repo/components'
import { TranslationStore } from '@views/repo/repo-list/types'
import { IBranchSelectorStore } from '@views/repo/repo.types'
import { z } from 'zod'
Expand All @@ -27,11 +12,9 @@ interface CreateTagDialogProps {
open: boolean
onClose: () => void
onSubmit: (data: CreateTagFromFields) => void
// branches?: { name: string }[]
branchQuery?: string
setBranchQuery: (query: string) => void
useRepoBranchesStore: () => IBranchSelectorStore
isLoadingBranches?: boolean
error?: string
useTranslationStore: () => TranslationStore
isLoading?: boolean
Expand All @@ -50,7 +33,6 @@ export function CreateTagDialog({
onClose,
onSubmit,
useRepoBranchesStore,
isLoadingBranches,
error,
useTranslationStore,
isLoading,
Expand Down Expand Up @@ -95,18 +77,6 @@ export function CreateTagDialog({
onClose()
}

const processedBranches = useMemo(
() =>
defaultBranch
? branches?.some(branch => branch.name === defaultBranch)
? branches
: [{ name: defaultBranch }, ...(branches || [])]
: branches,
[branches, defaultBranch]
)

const targetValue = watch('target')

const handleSelectChange = (fieldName: keyof CreateTagFromFields, value: string) => {
setValue(fieldName, value, { shouldValidate: true })
}
Expand Down Expand Up @@ -149,6 +119,7 @@ export function CreateTagDialog({
isBranchOnly={true}
searchQuery={branchQuery}
setSearchQuery={setBranchQuery}
dynamicWidth
/>
</ControlGroup>
</Fieldset>
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/views/repo/repo-tags/repo-tags-list-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ export const RepoTagsListView: FC<RepoTagsListViewProps> = ({
// to: toPullRequestCompare?.({ diffRefs: `${defaultBranch}...${branch.name}` }) || ''
},
{
title: t('views:repos.viewFiles', 'View Files')
// to: toBranchRules?.()
title: t('views:repos.viewFiles', 'View Files'),
to: `../code/refs/tags/${tag.name}`
},
{
isDanger: true,
Expand Down

0 comments on commit 64aa996

Please sign in to comment.