Skip to content

Commit

Permalink
fix(bulk-import): fixed Check All checkbox selection (#92)
Browse files Browse the repository at this point in the history
* fix(bulk-import): fixed Check All checkbox selection

* fix(bulk-import): changing minor to patch
  • Loading branch information
its-mitesh-kumar authored Dec 2, 2024
1 parent 651312a commit 734d971
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions workspaces/bulk-import/.changeset/neat-news-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@red-hat-developer-hub/backstage-plugin-bulk-import': patch
---

Fixed a bug in the bulk-import plugin where the "Check All" checkbox was incorrectly selected when the total number of selected repositories across multiple pages matched the number of rows in the current table
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
evaluateRowForOrg,
evaluateRowForRepo,
filterSelectedForActiveDrawer,
filterSelectedRepositoriesOnActivePage,
getComparator,
updateWithNewSelectedRepositories,
} from '../../utils/repository-utils';
Expand Down Expand Up @@ -250,7 +251,10 @@ export const RepositoriesTable = ({
() => filterSelectedForActiveDrawer(tableData || [], selected),
[tableData, selected],
);

const selectedRepositoriesOnActivePage = React.useMemo(
() => filterSelectedRepositoriesOnActivePage(filteredData, selected),
[filteredData, selected],
);
const getRowCount = () => {
if (drawerOrganization) {
return tableData?.filter(
Expand Down Expand Up @@ -296,7 +300,7 @@ export const RepositoriesTable = ({
numSelected={
drawerOrganization
? Object.keys(selectedForActiveDrawer).length
: Object.keys(selected).length
: selectedRepositoriesOnActivePage.length
}
isDataLoading={loading}
order={order}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ export const filterSelectedForActiveDrawer = (
);
};

export const filterSelectedRepositoriesOnActivePage = (
activePageTableData: AddRepositoryData[],
selectedRepositories: AddedRepositories,
) => {
return Object.keys(selectedRepositories).filter(repoId => {
return activePageTableData.some(activeRepo => activeRepo.id === repoId);
});
};

export const urlHelper = (url: string) => {
if (!url || url === '') {
return '-';
Expand Down

0 comments on commit 734d971

Please sign in to comment.