Skip to content

Commit

Permalink
Pr page bugs #1 (harness#825)
Browse files Browse the repository at this point in the history
* chore: fix title/desc edit on PR page

* chore: fix branch selector and form label size

* feat: add no data states

* chore: hide 3-dot-menu

* feat: fix selector and add FF merge

* chore: fix file view gauge

* chore: fix ready for review btn

* fix: tsc

* chore: minor fix to branch selector

* chore: remove logs
  • Loading branch information
sans-harness authored Jan 24, 2025
1 parent 0c4c123 commit 4dc7839
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ export const mockPullRequestActions = [
action: () => {
noop()
}
},
{
id: '3',
title: 'Fast-forward merge',
description:
'All commits from this branch will be added to the base branch without a merge commit. Rebase may be required.',
action: () => {
noop()
}
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,15 @@ export default function PullRequestConversationPage() {
action: () => {
handleMerge('rebase')
}
},
{
id: '3',
title: 'Fast-forward merge',
description:
'All commits from this branch will be added to the base branch without a merge commit. Rebase may be required.',
action: () => {
handleMerge('fast-forward')
}
}
])
]
Expand Down
24 changes: 22 additions & 2 deletions apps/gitness/src/pages-v2/repo/repo-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Outlet, useNavigate, useParams } from 'react-router-dom'
import {
getContent,
useFindRepositoryQuery,
useGetBranchQuery,
useGetContentQuery,
useListBranchesQuery,
useListPathsQuery,
Expand Down Expand Up @@ -62,6 +63,26 @@ export const RepoSidebar = () => {
}
})

const { data: { body: selectedGitRefBranch } = {} } = useGetBranchQuery(
{
repo_ref: repoRef,
branch_name: fullGitRef,
queryParams: {}
},
{
enabled: !!fullGitRef
}
)

useEffect(() => {
if (selectedGitRefBranch) {
setSelectedBranchTag({
name: selectedGitRefBranch.name ?? '',
sha: selectedGitRefBranch.sha ?? ''
})
}
}, [selectedGitRefBranch, fullGitRef])

useEffect(() => {
if (branches) {
setBranchList(transformBranchList(branches, repository?.default_branch))
Expand Down Expand Up @@ -105,10 +126,9 @@ export const RepoSidebar = () => {
default: true
})
} else {
const selectedGitRefBranch = branchList.find(branch => branch.name === fullGitRef)
const selectedGitRefTag = tagList.find(tag => tag.name === gitRefName)
if (selectedGitRefBranch) {
setSelectedBranchTag(selectedGitRefBranch)
setSelectedBranchTag({ name: selectedGitRefBranch.name ?? '', sha: selectedGitRefBranch.sha ?? '' })
} else if (selectedGitRefTag) {
setSelectedBranchTag(selectedGitRefTag)
}
Expand Down
10 changes: 6 additions & 4 deletions packages/ui/locales/en/views.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
"noResultsDescription": "No {{type}} match your search. Try adjusting your keywords or filters.",
"members": "No members yet",
"inviteMembers": "There are no members in this project. Click on the button below to start adding them.",
"noCommitsYet": "No commits yet",
"noCommitsYetDescription": "Your commits will appear here once they're made. Start committing to see your changes reflected.",
"compareChanges": "Compare and review just about anything",
"compareChangesDescription": "Branches, tags, commit ranges, and time ranges. In the same repository and across forks.",
"clearFilters": "Clear filters",
Expand All @@ -179,9 +181,7 @@
"startBranchDescription": "Start branching to see your work organized.",
"createBranch": "Create new branch",
"noCommitsHistory": "No commits history",
"noCommitsYet": "No commits yet",
"noCommitsHistoryDescription": "There isn't any commit history to show here for the selected user, time range, or current page.",
"noCommitsYetDescription": "Your commits will appear here once they're made. Start committing to see your changes reflected.",
"errorApiTitle": "Failed to load {{type}}",
"errorApiDescription": "An error occurred while loading the data. Please try again and reload the page.",
"noRepos": "No repositories yet",
Expand Down Expand Up @@ -218,10 +218,10 @@
"compareChangesDraftTitle": "Create draft pull request",
"compareChangesDraftDescription": "Does not request code reviews and cannot be merged.",
"compareChangesCreatedButton": "Pull request created",
"compareChangesFormTitle": "Add a title",
"compareChangesFormTitlePlaceholder": "Enter pull request title",
"compareChangesFormDescription": "Add a description",
"compareChangesFormTitleLabel": "Title",
"compareChangesFormDescriptionPlaceholder": "Add Pull Request description here.",
"compareChangesFormDescriptionLabel": "Description",
"compareChanges": "Comparing changes",
"compareChangesDescription": "Choose two branches to see what’s changed or to start a new pull request.",
"compareChangesForkLink": "compare across forks",
Expand Down Expand Up @@ -252,6 +252,8 @@
"split": "Split",
"unified": "Unified",
"viewed": "Viewed",
"compareChangesFormTitle": "Add a title",
"compareChangesFormDescription": "Add a description",
"compareChangesCreateButton": "Create pull request",
"compareChangesCreateButtonLoading": "Creating pull request...",
"compareChangesDraftButton": "Draft pull request",
Expand Down
10 changes: 6 additions & 4 deletions packages/ui/locales/es/views.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
"noResultsDescription": "No {{type}} match your search. Try adjusting your keywords or filters.",
"members": "",
"inviteMembers": "",
"noCommitsYet": "No commits yet",
"noCommitsYetDescription": "Your commits will appear here once they're made. Start committing to see your changes reflected.",
"compareChanges": "Compare and review just about anything",
"compareChangesDescription": "Branches, tags, commit ranges, and time ranges. In the same repository and across forks.",
"clearFilters": "Clear filters",
Expand All @@ -179,9 +181,7 @@
"startBranchDescription": "Start branching to see your work organized.",
"createBranch": "Crear nueva rama",
"noCommitsHistory": "No commits history",
"noCommitsYet": "No commits yet",
"noCommitsHistoryDescription": "There isn't any commit history to show here for the selected user, time range, or current page.",
"noCommitsYetDescription": "Your commits will appear here once they're made. Start committing to see your changes reflected.",
"errorApiTitle": "Failed to load {{type}}",
"errorApiDescription": "An error occurred while loading the data. Please try again and reload the page.",
"noRepos": "No repositories yet",
Expand Down Expand Up @@ -218,10 +218,10 @@
"compareChangesDraftTitle": "Crear borrador de solicitud de cambios",
"compareChangesDraftDescription": "No solicita revisiones de código y no se puede fusionar.",
"compareChangesCreatedButton": "Solicitud de cambios creada",
"compareChangesFormTitle": "Agregar un título",
"compareChangesFormTitlePlaceholder": "Ingrese el título de la solicitud de cambios",
"compareChangesFormDescription": "Agregar una descripción",
"compareChangesFormTitleLabel": "Title",
"compareChangesFormDescriptionPlaceholder": "Agregue aquí la descripción de la solicitud de cambios.",
"compareChangesFormDescriptionLabel": "Description",
"compareChanges": "Compare y revise prácticamente cualquier cosa",
"compareChangesDescription": "Ramas, etiquetas, rangos de commits y rangos de tiempo. En el mismo repositorio y entre bifurcaciones.",
"compareChangesForkLink": "comparar entre bifurcaciones",
Expand Down Expand Up @@ -252,6 +252,8 @@
"split": "",
"unified": "",
"viewed": "",
"compareChangesFormTitle": "Agregar un título",
"compareChangesFormDescription": "Agregar una descripción",
"replyHere": "",
"commits": ""
},
Expand Down
10 changes: 6 additions & 4 deletions packages/ui/locales/fr/views.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
"noResultsDescription": "No {{type}} match your search. Try adjusting your keywords or filters.",
"members": "",
"inviteMembers": "",
"noCommitsYet": "No commits yet",
"noCommitsYetDescription": "Your commits will appear here once they're made. Start committing to see your changes reflected.",
"compareChanges": "Comparez et révisez pratiquement tout",
"compareChangesDescription": "Branches, tags, plages de commits et périodes. Dans le même dépôt et entre les forks.",
"clearFilters": "Effacer les filtres",
Expand All @@ -179,9 +181,7 @@
"startBranchDescription": "Commencez à créer des branches pour voir votre travail organisé.",
"createBranch": "Créer une nouvelle branche",
"noCommitsHistory": "No commits history",
"noCommitsYet": "No commits yet",
"noCommitsHistoryDescription": "There isn't any commit history to show here for the selected user, time range, or current page.",
"noCommitsYetDescription": "Your commits will appear here once they're made. Start committing to see your changes reflected.",
"errorApiTitle": "Failed to load {{type}}",
"errorApiDescription": "An error occurred while loading the data. Please try again and reload the page.",
"noRepos": "Pas encore de dépôts",
Expand Down Expand Up @@ -218,10 +218,10 @@
"compareChangesDraftTitle": "Créer une pull request en brouillon",
"compareChangesDraftDescription": "Ne demande pas de révision de code et ne peut pas être fusionnée.",
"compareChangesCreatedButton": "Pull request créée",
"compareChangesFormTitle": "Ajouter un titre",
"compareChangesFormTitlePlaceholder": "Saisissez le titre de la pull request",
"compareChangesFormDescription": "Ajouter une description",
"compareChangesFormTitleLabel": "Title",
"compareChangesFormDescriptionPlaceholder": "Ajoutez la description de la pull request ici.",
"compareChangesFormDescriptionLabel": "Description",
"compareChanges": "Comparaison des modifications",
"compareChangesDescription": "Choisissez deux branches pour voir les modifications ou pour créer une nouvelle pull request. Si nécessaire, vous pouvez aussi",
"compareChangesForkLink": "comparer entre les forks",
Expand Down Expand Up @@ -252,6 +252,8 @@
"split": "Diviser",
"unified": "Unifié",
"viewed": "Vu",
"compareChangesFormTitle": "Ajouter un titre",
"compareChangesFormDescription": "Ajouter une description",
"replyHere": "Repondre ici",
"commits": "Commets",
"noUsers": "Aucun utilisateur trouvé.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Button,
CopyButton,
DropdownMenu,
Icon,
Layout,
ListActions,
Spacer,
Expand All @@ -31,11 +30,11 @@ const LineTitle: FC<LineTitleProps> = ({ text }) => (
<p className="font-medium">{text}</p>
<CopyButton name={text} />
</div>
<div className="inline-flex items-center gap-x-6">
{/* <div className="inline-flex items-center gap-x-6">
<div className="flex items-center gap-2">
<Icon name="ellipsis" size={12} />
</div>
</div>
</div> */}
</div>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,24 @@ const PullRequestCompareForm = forwardRef<HTMLFormElement, PullRequestFormProps>
return (
<form ref={ref} onSubmit={handleSubmit(onSubmit)}>
<Fieldset className="gap-y-3">
<span className="text-18 font-medium leading-none text-foreground-1">
{t('views:pullRequests.compareChangesFormTitle', 'Add a title')}
</span>
<Input
id="title"
{...register('title')}
placeholder={t('views:pullRequests.compareChangesFormTitlePlaceholder', 'Enter pull request title')}
error={errors.title?.message?.toString()}
autoFocus
label={t('views:pullRequests.compareChangesFormTitleLabel', 'Title')}
size="md"
/>
<span className="mt-4 text-18 font-medium leading-none text-foreground-1">
{t('views:pullRequests.compareChangesFormDescription', 'Add a description')}
</span>

<Textarea
id="description"
{...register('description')}
placeholder={t(
'views:pullRequests.compareChangesFormDescriptionPlaceholder',
'Add Pull Request description here.'
)}
label={t('views:pullRequests.compareChangesFormDescriptionLabel', 'Description')}
error={errors.description?.message?.toString()}
/>
</Fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export const PullRequestComparePage: FC<PullRequestComparePageProps> = ({
<Layout.Horizontal className="items-center" gap="gap-x-2.5">
<Icon name="compare" size={14} className="text-icons-1" />
<BranchSelector
isBranchOnly={true}
useTranslationStore={useTranslationStore}
useRepoBranchesStore={useRepoBranchesStore}
branchPrefix="base"
Expand All @@ -205,6 +206,7 @@ export const PullRequestComparePage: FC<PullRequestComparePageProps> = ({

<Icon name="arrow-long" size={12} className="rotate-180 text-icons-1" />
<BranchSelector
isBranchOnly={true}
useTranslationStore={useTranslationStore}
useRepoBranchesStore={useRepoBranchesStore}
branchPrefix="compare"
Expand Down Expand Up @@ -384,27 +386,48 @@ export const PullRequestComparePage: FC<PullRequestComparePageProps> = ({
)}
<TabsContent className="pt-7" value="commits">
{/* TODO: add pagination to this */}
<CommitsList
toCode={toCode}
toCommitDetails={toCommitDetails}
data={commitData?.map((item: TypesCommit) => ({
sha: item.sha,
parent_shas: item.parent_shas,
title: item.title,
message: item.message,
author: item.author,
committer: item.committer
}))}
/>
{(commitData ?? []).length > 0 ? (
<CommitsList
toCode={toCode}
toCommitDetails={toCommitDetails}
data={commitData?.map((item: TypesCommit) => ({
sha: item.sha,
parent_shas: item.parent_shas,
title: item.title,
message: item.message,
author: item.author,
committer: item.committer
}))}
/>
) : (
<NoData
iconName={'no-data-commits'}
title={t('views:noData.noCommitsYet', 'No commits yet')}
description={[
t(
'views:noData.noCommitsYetDescription',
"Your commits will appear here once they're made. Start committing to see your changes reflected."
)
]}
/>
)}
</TabsContent>
<TabsContent className="pt-7" value="changes">
{/* Content for Changes */}
<PullRequestCompareDiffList
diffData={diffData}
currentUser={currentUser}
diffStats={diffStats}
useTranslationStore={useTranslationStore}
/>
{(diffData ?? []).length > 0 ? (
<PullRequestCompareDiffList
diffData={diffData}
currentUser={currentUser}
diffStats={diffStats}
useTranslationStore={useTranslationStore}
/>
) : (
<NoData
iconName="no-data-folder"
title="No changes to display"
description={['There are no changes to display for the selected branches.']}
/>
)}
</TabsContent>
</Tabs>
</Layout.Vertical>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export const PullRequestHeader: React.FC<PullRequestTitleProps> = ({

const stateObject = getPrState(is_draft, merged, state)
const submitChange = useCallback(() => {
if (val && description) {
updateTitle(val, description)
if (val) {
updateTitle(val, description ?? '')
.then(() => {
setEdit(false)
setOriginal(val)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,17 @@ export const PullRequestChangesFilter: React.FC<PullRequestChangesFilterProps> =
</DropdownMenu.Content>
</DropdownMenu.Root>
</ListActions.Left>

<ListActions.Right>
<FileViewGauge.Root>
<FileViewGauge.Content>
{viewedFiles}/{totalFiles} file{totalFiles === 1 ? '' : 's'} viewed
</FileViewGauge.Content>
<FileViewGauge.Bar total={totalFiles} filled={viewedFiles} />
</FileViewGauge.Root>
{selectedCommits[0].value === 'ALL' && (
<FileViewGauge.Root>
<FileViewGauge.Content>
{viewedFiles}/{totalFiles} file{totalFiles === 1 ? '' : 's'} viewed
</FileViewGauge.Content>
<FileViewGauge.Bar total={totalFiles} filled={viewedFiles} />
</FileViewGauge.Root>
)}

{commitSuggestionsBatchCount > 0 ? (
<Button variant={'outline'} onClick={() => onCommitSuggestionsBatch()}>
{`Commit suggestion (${commitSuggestionsBatchCount})`}
Expand Down
Loading

0 comments on commit 4dc7839

Please sign in to comment.