Chore: Remove duplicated api calls in mirrors#695
Open
gesquivelgaghi wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors publications-related UI in Mirrors (and Local Repositories) to reduce duplicated API hook implementations by reusing the Publications feature’s query hook(s) and introducing a shared AssociatedPublicationsCount component.
Changes:
- Added
AssociatedPublicationsCountto centralize “publications count + link” rendering for any source name. - Updated Mirrors and Local Repositories lists/modals/forms to use shared publications hooks/components, removing mirrors-specific
useListPublications/useListPublicationTargetshooks and theMirrorPublicationsLinkcomponent. - Simplified/standardized conditional rendering around publications association messaging in remove flows.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/features/publications/index.ts | Exports the new shared AssociatedPublicationsCount component. |
| src/features/publications/components/AssociatedPublicationsCount/index.ts | Barrel export for the new component. |
| src/features/publications/components/AssociatedPublicationsCount/AssociatedPublicationsCount.tsx | New shared UI for showing linked publication counts for a given source. |
| src/features/publications/components/AssociatedPublicationsCount/AssociatedPublicationsCount.test.tsx | Tests for the new shared publication-count component. |
| src/features/mirrors/components/RemoveMirrorModal/RemoveMirrorModal.tsx | Uses shared publications hook and adds loading-state handling while fetching publications. |
| src/features/mirrors/components/PublishMirrorForm/PublishMirrorForm.tsx | Replaces mirrors-local publication/target listing with feature hooks; updates publish destination toggle UI. |
| src/features/mirrors/components/MirrorsList/MirrorsList.tsx | Replaces mirrors-specific publications link with shared AssociatedPublicationsCount. |
| src/features/mirrors/components/MirrorPublicationsLink/MirrorPublicationsLinks.tsx | Removes mirrors-specific publications link component (deduplication). |
| src/features/mirrors/components/MirrorPublicationsLink/MirrorPublicationsLink.test.tsx | Removes tests for deleted MirrorPublicationsLink. |
| src/features/mirrors/components/MirrorPublicationsLink/index.ts | Removes barrel export for deleted MirrorPublicationsLink. |
| src/features/mirrors/components/MirrorDetails/MirrorDetails.tsx | Uses shared publication targets hook; adjusts publish action enable/disable behavior. |
| src/features/mirrors/components/MirrorActions/MirrorActions.tsx | Uses shared publication targets hook; adjusts publish action enable/disable behavior. |
| src/features/mirrors/api/useListPublicationTargets.ts | Removes duplicated mirrors-local publication-target listing hook. |
| src/features/mirrors/api/useListPublications.ts | Removes duplicated mirrors-local publications listing hook. |
| src/features/mirrors/api/index.ts | Stops exporting removed mirrors-local hooks. |
| src/features/local-repositories/components/RemoveLocalRepositoryModal/RemoveLocalRepositoryModal.tsx | Minor content formatting change (removes <br />). |
| src/features/local-repositories/components/LocalRepositoriesList/LocalRepositoriesList.tsx | Uses shared AssociatedPublicationsCount in the publications column. |
| src/features/local-repositories/components/LocalRepositoriesList/components/LocalRepositoryPublicationsCount/LocalRepositoryPublicationsCount.test.tsx | Removes tests for deleted local-repo-specific publications-count component. |
| src/features/local-repositories/components/LocalRepositoriesList/components/LocalRepositoryPublicationsCount/index.ts | Removes barrel export for deleted component. |
| .changeset/lucky-donkeys-kneel.md | Adds an empty changeset entry for the main-targeting PR. |
Comments suppressed due to low confidence (2)
src/features/publications/components/AssociatedPublicationsCount/AssociatedPublicationsCount.tsx:16
AssociatedPublicationsCountfetches all publication pages viauseGetPublicationsBySource(which loops overnextPageToken). Rendering this component in lists (mirrors/local repositories) can cause N+1 network traffic and long blocking spinners for sources with many publications. Consider a dedicated hook for counts that only fetches the first page and shows a limited count (e.g.3+) whennextPageTokenis present, or otherwise avoid per-row full pagination.
src/features/mirrors/components/PublishMirrorForm/PublishMirrorForm.tsx:60- If
publicationTargetsis empty, the "New publication" path rendersPublishMirrorNewFormwith no target options, which can leave the form in an unusable state (required select with no options). Guard the render so the new form is only shown when targets exist (and fall back to the existing-publication form when possible).
{useNewPublication ? (
<PublishMirrorNewForm
mirror={mirror}
publicationTargets={publicationTargets}
/>
) : (
<PublishMirrorExistingForm
mirror={mirror}
publications={publications}
/>
)}
marqode
previously approved these changes
Jun 30, 2026
marqode
left a comment
Contributor
There was a problem hiding this comment.
LGTM, one suggestion and a comment on what may be a slight regression in error reporting.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Summarize the changes made in this pull request. Include any relevant context or background information that would help reviewers understand the purpose and scope of the changes.
Release Impact
Pick the target branch (see RELEASES.md for the full model):
dev— internal testing → publishes toppa-build-devmain— next beta → publishes toppa-buildrelease/YY.MM— point release on a maintained cycle → publishes toppa-build-YY.MM(and toppa-build-stableif this is the currently-promoted branch). Specify cycle:release/____Change type (tick one):
Checklist
pnpm changeset(orpnpm changeset --emptyif no CHANGELOG line is warranted) and committed the resulting.mdfile. Required for PRs targetingmainandrelease/*; enforced by theChangeset checkworkflow.scripts/).Versioning Reminder
Important
Landscape UI uses CalVer (
YY.MM.Point.Build). Version derivation by branch:main/point/*→YY.MM.0.<run>-betadev→YY.MM.0.<run>-devrelease/YY.MM→YY.MM.1.<run>(cycle pinned by branch name)