From 4dc783984549cd510701580f0dd68b3aac0cfb43 Mon Sep 17 00:00:00 2001 From: Sanskar Date: Thu, 23 Jan 2025 21:45:24 -0800 Subject: [PATCH] Pr page bugs #1 (#825) * 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 --- .../pull-request-panelData.ts | 9 +++ .../pull-request-conversation.tsx | 9 +++ .../src/pages-v2/repo/repo-sidebar.tsx | 24 +++++++- packages/ui/locales/en/views.json | 10 ++-- packages/ui/locales/es/views.json | 10 ++-- packages/ui/locales/fr/views.json | 10 ++-- .../pull-request-compare-diff-list.tsx | 5 +- .../components/pull-request-compare-form.tsx | 9 +-- .../compare/pull-request-compare-page.tsx | 59 +++++++++++++------ .../components/pull-request-header.tsx | 4 +- .../changes/pull-request-changes-filter.tsx | 16 +++-- .../conversation/pull-request-panel.tsx | 15 ++--- 12 files changed, 124 insertions(+), 56 deletions(-) diff --git a/apps/design-system/src/subjects/views/pull-request-conversation/pull-request-panelData.ts b/apps/design-system/src/subjects/views/pull-request-conversation/pull-request-panelData.ts index cc307d24c3..6edd0c9caf 100644 --- a/apps/design-system/src/subjects/views/pull-request-conversation/pull-request-panelData.ts +++ b/apps/design-system/src/subjects/views/pull-request-conversation/pull-request-panelData.ts @@ -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() + } } ] diff --git a/apps/gitness/src/pages-v2/pull-request/pull-request-conversation.tsx b/apps/gitness/src/pages-v2/pull-request/pull-request-conversation.tsx index fec93759b8..e778881b9d 100644 --- a/apps/gitness/src/pages-v2/pull-request/pull-request-conversation.tsx +++ b/apps/gitness/src/pages-v2/pull-request/pull-request-conversation.tsx @@ -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') + } } ]) ] diff --git a/apps/gitness/src/pages-v2/repo/repo-sidebar.tsx b/apps/gitness/src/pages-v2/repo/repo-sidebar.tsx index 8878cf949b..8259f5a28d 100644 --- a/apps/gitness/src/pages-v2/repo/repo-sidebar.tsx +++ b/apps/gitness/src/pages-v2/repo/repo-sidebar.tsx @@ -4,6 +4,7 @@ import { Outlet, useNavigate, useParams } from 'react-router-dom' import { getContent, useFindRepositoryQuery, + useGetBranchQuery, useGetContentQuery, useListBranchesQuery, useListPathsQuery, @@ -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)) @@ -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) } diff --git a/packages/ui/locales/en/views.json b/packages/ui/locales/en/views.json index a9a487fe93..790eddcf32 100644 --- a/packages/ui/locales/en/views.json +++ b/packages/ui/locales/en/views.json @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/packages/ui/locales/es/views.json b/packages/ui/locales/es/views.json index 1cdfa4bf87..fd95d0879d 100644 --- a/packages/ui/locales/es/views.json +++ b/packages/ui/locales/es/views.json @@ -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", @@ -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", @@ -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", @@ -252,6 +252,8 @@ "split": "", "unified": "", "viewed": "", + "compareChangesFormTitle": "Agregar un título", + "compareChangesFormDescription": "Agregar una descripción", "replyHere": "", "commits": "" }, diff --git a/packages/ui/locales/fr/views.json b/packages/ui/locales/fr/views.json index 5dcae9c31b..9dd6325cf7 100644 --- a/packages/ui/locales/fr/views.json +++ b/packages/ui/locales/fr/views.json @@ -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", @@ -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", @@ -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", @@ -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é.", diff --git a/packages/ui/src/views/repo/pull-request/compare/components/pull-request-compare-diff-list.tsx b/packages/ui/src/views/repo/pull-request/compare/components/pull-request-compare-diff-list.tsx index 83dc719b70..2fd41856ed 100644 --- a/packages/ui/src/views/repo/pull-request/compare/components/pull-request-compare-diff-list.tsx +++ b/packages/ui/src/views/repo/pull-request/compare/components/pull-request-compare-diff-list.tsx @@ -6,7 +6,6 @@ import { Button, CopyButton, DropdownMenu, - Icon, Layout, ListActions, Spacer, @@ -31,11 +30,11 @@ const LineTitle: FC = ({ text }) => (

{text}

-
+ {/*
-
+
*/} ) diff --git a/packages/ui/src/views/repo/pull-request/compare/components/pull-request-compare-form.tsx b/packages/ui/src/views/repo/pull-request/compare/components/pull-request-compare-form.tsx index 62ac59932e..a575e5d1c2 100644 --- a/packages/ui/src/views/repo/pull-request/compare/components/pull-request-compare-form.tsx +++ b/packages/ui/src/views/repo/pull-request/compare/components/pull-request-compare-form.tsx @@ -36,20 +36,16 @@ const PullRequestCompareForm = forwardRef return (
- - {t('views:pullRequests.compareChangesFormTitle', 'Add a title')} - - - {t('views:pullRequests.compareChangesFormDescription', 'Add a description')} - +