Skip to content

Commit

Permalink
fix(views): ds-832 unselect items upon deletion
Browse files Browse the repository at this point in the history
Relates to JIRA: DISCOVERY-832
  • Loading branch information
mirekdlugosz committed Nov 5, 2024
1 parent a1949dc commit 5fb3a2d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/views/credentials/viewCredentialsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const CredentialsListView: React.FunctionComponent = () => {
});

const {
selection: { selectedItems },
selection: { selectedItems, setSelectedItems },
currentPageItems,
numRenderedColumns,
components: { Toolbar, FilterToolbar, PaginationToolbarItem, Pagination, Table, Tbody, Td, Th, Thead, Tr }
Expand Down Expand Up @@ -206,7 +206,12 @@ const CredentialsListView: React.FunctionComponent = () => {
<Button
variant={ButtonVariant.secondary}
isDisabled={!hasSelectedCredentials()}
onClick={() => deleteCredentials(selectedItems).finally(() => onRefresh())}
onClick={() =>
deleteCredentials(selectedItems).finally(() => {
setSelectedItems([]);
onRefresh();
})
}
>
{t('table.label', { context: 'delete' })}
</Button>
Expand Down
3 changes: 2 additions & 1 deletion src/views/scans/viewScansList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const ScansListView: React.FunctionComponent = () => {
});

const {
selection: { selectedItems },
selection: { selectedItems, setSelectedItems },
currentPageItems,
numRenderedColumns,
components: { Toolbar, FilterToolbar, PaginationToolbarItem, Pagination, Table, Tbody, Td, Th, Thead, Tr }
Expand All @@ -140,6 +140,7 @@ const ScansListView: React.FunctionComponent = () => {
onClick={() =>
deleteScans(selectedItems).finally(() => {
setPendingDeleteScan(undefined);
setSelectedItems([]);
onRefresh();
})
}
Expand Down
9 changes: 7 additions & 2 deletions src/views/sources/viewSourcesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const SourcesListView: React.FunctionComponent = () => {
});

const {
selection: { selectedItems },
selection: { selectedItems, setSelectedItems },
currentPageItems,
numRenderedColumns,
components: { Toolbar, FilterToolbar, PaginationToolbarItem, Pagination, Table, Tbody, Td, Th, Thead, Tr }
Expand Down Expand Up @@ -273,7 +273,12 @@ const SourcesListView: React.FunctionComponent = () => {
<Button
variant={ButtonVariant.secondary}
isDisabled={!hasSelectedSources()}
onClick={() => deleteSources(selectedItems).finally(() => onRefresh())}
onClick={() =>
deleteSources(selectedItems).finally(() => {
setSelectedItems([]);
onRefresh();
})
}
>
{t('table.label', { context: 'delete' })}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/code.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ exports[`General code checks should only have specific console.[warn|log|info|er
"hooks/useSourceApi.ts:255: console.error(error);",
"hooks/useStatusApi.ts:38: console.error(error);",
"views/sources/addSourceModal.tsx:106: console.error(err);",
"views/sources/viewSourcesList.tsx:314: console.error(err);",
"views/sources/viewSourcesList.tsx:319: console.error(err);",
]
`;

0 comments on commit 5fb3a2d

Please sign in to comment.