Skip to content

Commit

Permalink
[CP-3378] Fix error with wrong number of deleted files (#2273)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Karski <[email protected]>
  • Loading branch information
MateuszMudita and dkarski authored Jan 20, 2025
1 parent f549e70 commit 51d75e4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion libs/generic-view/ui/src/lib/interactive/toast/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Dispatch, ReduxRootState } from "Core/__deprecated__/renderer/store"
import { useDispatch, useSelector } from "react-redux"
import { removeToast } from "generic-view/store"

const toastAnimationDuration = 300
export const toastAnimationDuration = 300

export const Toast: APIFC<undefined, ToastConfig> = ({
config,
Expand Down
44 changes: 30 additions & 14 deletions libs/generic-view/ui/src/lib/table/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ import styled from "styled-components"
import { difference, intersection } from "lodash"
import { TableTestIds } from "e2e-test-ids"
import { APIFC, useViewFormContext } from "generic-view/utils"
import {
TableConfig,
TableData,
tableHeaderCell,
} from "generic-view/models"
import { TableConfig, TableData, tableHeaderCell } from "generic-view/models"
import { TableCell } from "./table-cell"
import { TableHeaderCell } from "./table-header-cell"
import {
Expand All @@ -31,6 +27,7 @@ import {
listItemSelectedStyles,
listRawItemStyles,
} from "../list/list-item"
import { toastAnimationDuration } from "../interactive/toast/toast"

const rowHeight = 64

Expand Down Expand Up @@ -104,11 +101,16 @@ export const Table: APIFC<TableData, TableConfig> & {
formOptions.selectedIdsFieldName
)
const unavailableIds = difference(selectedIds, data)

if (unavailableIds.length > 0) {
formContext.setValue(
formOptions.selectedIdsFieldName,
intersection(data, unavailableIds)
)
setTimeout(() => {
if (formOptions.selectedIdsFieldName !== undefined) {
formContext.setValue(
formOptions.selectedIdsFieldName,
intersection(data, unavailableIds)
)
}
}, toastAnimationDuration)
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -140,8 +142,15 @@ export const Table: APIFC<TableData, TableConfig> & {
(id: string) => {
const isActive = activeRowId === id
return (
<RowPlaceholder key={id} data-testid={TableTestIds.TablePlaceholderRow} className={isActive ? "active" : ""}>
<td data-testid={TableTestIds.TableCell} colSpan={Children.count(children)}>
<RowPlaceholder
key={id}
data-testid={TableTestIds.TablePlaceholderRow}
className={isActive ? "active" : ""}
>
<td
data-testid={TableTestIds.TableCell}
colSpan={Children.count(children)}
>
<div />
</td>
</RowPlaceholder>
Expand Down Expand Up @@ -189,7 +198,12 @@ export const Table: APIFC<TableData, TableConfig> & {
const isActive = activeRowId === id

return (
<tr key={id} data-testid={TableTestIds.TableRow} onClick={onClick} className={isActive ? "active" : ""}>
<tr
key={id}
data-testid={TableTestIds.TableRow}
onClick={onClick}
className={isActive ? "active" : ""}
>
{renderChildren(id)}
</tr>
)
Expand All @@ -206,9 +220,11 @@ export const Table: APIFC<TableData, TableConfig> & {
return useMemo(
() => (
<ScrollableWrapper ref={scrollWrapperRef} {...props}>
<TableWrapper data-testid={TableTestIds.Table} >
<TableWrapper data-testid={TableTestIds.Table}>
<TableHeader>
<tr data-testid={TableTestIds.TableHeaderRow} >{renderHeaderChildren()}</tr>
<tr data-testid={TableTestIds.TableHeaderRow}>
{renderHeaderChildren()}
</tr>
</TableHeader>
<TableBody $clickable={isClickable}>
{data?.map((id, index) => renderRow(id, index))}
Expand Down

0 comments on commit 51d75e4

Please sign in to comment.