Skip to content

Commit 67e6646

Browse files
committed
feat: DynamicDataTable - update row delete icon with Button component, RuntimePluginVariables - types update
1 parent a13ee2b commit 67e6646

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

src/Shared/Components/DynamicDataTable/DynamicDataTableRow.tsx

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ import { followCursor } from 'tippy.js'
44

55
import { ReactComponent as ICCross } from '@Icons/ic-cross.svg'
66
import { Tooltip } from '@Common/Tooltip'
7-
87
import { ConditionalWrap } from '@Common/Helper'
98
import { ResizableTagTextArea } from '@Common/CustomTagSelector'
9+
import { ComponentSizeType } from '@Shared/constants'
10+
11+
import { Button, ButtonStyleType, ButtonVariantType } from '../Button'
1012
import { SelectTextArea } from '../SelectTextArea'
1113
import {
1214
getSelectPickerOptionByValue,
1315
SelectPicker,
1416
SelectPickerOptionType,
1517
SelectPickerVariantType,
1618
} from '../SelectPicker'
19+
import { FileUpload } from '../FileUpload'
1720
import { getActionButtonPosition, getRowGridTemplateColumn, rowTypeHasInputField } from './utils'
1821
import { DynamicDataTableRowType, DynamicDataTableRowProps, DynamicDataTableRowDataType } from './types'
19-
import { FileUpload } from '../FileUpload'
2022

2123
const conditionalWrap =
2224
<K extends string, CustomStateType = Record<string, unknown>>(
@@ -214,7 +216,7 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
214216

215217
const renderCellIcon = (row: DynamicDataTableRowType<K, CustomStateType>, key: K, isLeadingIcon?: boolean) => {
216218
const iconConfig = isLeadingIcon ? leadingCellIcon : trailingCellIcon
217-
if (!iconConfig?.[key]) {
219+
if (!iconConfig?.[key]?.(row)) {
218220
return null
219221
}
220222

@@ -256,8 +258,9 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
256258

257259
const cellNode = (
258260
<Tooltip
259-
alwaysShowTippyOnHover={!!row.data[key].tooltipText || isDisabled}
260-
content={row.data[key].tooltipText || (isDisabled ? 'Cannot edit in read-only mode' : '')}
261+
alwaysShowTippyOnHover={!!row.data[key].tooltip?.content || isDisabled}
262+
className={row.data[key].tooltip?.className}
263+
content={row.data[key].tooltip?.content || (isDisabled ? 'Cannot edit in read-only mode' : '')}
261264
followCursor="horizontal"
262265
plugins={[followCursor]}
263266
>
@@ -308,14 +311,19 @@ export const DynamicDataTableRow = <K extends string, CustomStateType = Record<s
308311
<Fragment key={key}>{renderCell(row, key, index)}</Fragment>
309312
))}
310313
{!isDeletionNotAllowed && !readOnly && (
311-
<button
312-
type="button"
313-
className={`dynamic-data-table__row-delete-btn dc__unset-button-styles dc__align-self-stretch dc__no-shrink flex py-10 px-8 bcn-0 ${disableDeleteRow || row.disableDelete ? 'dc__disabled' : 'dc__hover-n50 dc__tab-focus'}`}
314-
onClick={onDelete(row)}
315-
disabled={disableDeleteRow || row.disableDelete}
316-
>
317-
<ICCross aria-label="delete-row" className="icon-dim-16 fcn-4 dc__align-self-start" />
318-
</button>
314+
<div className="dynamic-data-table__row-delete-btn bcn-0">
315+
<Button
316+
dataTestId="dynamic-data-table-row-delete-btn"
317+
ariaLabel="Delete Row"
318+
showAriaLabelInTippy={false}
319+
icon={<ICCross />}
320+
disabled={disableDeleteRow || row.disableDelete}
321+
onClick={onDelete(row)}
322+
variant={ButtonVariantType.borderLess}
323+
style={ButtonStyleType.negativeGrey}
324+
size={ComponentSizeType.small}
325+
/>
326+
</div>
319327
)}
320328
</div>
321329
))}

src/Shared/Components/DynamicDataTable/styles.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@
4848
height: 50px;
4949
}
5050

51+
&__row-delete-btn {
52+
> div {
53+
height: 100%;
54+
width: 100%;
55+
56+
> button {
57+
padding: 0;
58+
width: 100%;
59+
height: 100%;
60+
border-radius: 0;
61+
}
62+
}
63+
}
64+
5165
&__cell-input {
5266
outline: none;
5367
border: none !important;

src/Shared/Components/DynamicDataTable/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { DetailedHTMLProps, ReactElement, ReactNode } from 'react'
1919
import { ResizableTagTextAreaProps } from '@Common/CustomTagSelector'
2020
import { UseStateFiltersReturnType } from '@Common/Hooks'
2121

22+
import { TooltipProps } from '@Common/Tooltip/types'
2223
import { SelectPickerOptionType, SelectPickerProps } from '../SelectPicker'
2324
import { SelectTextAreaProps } from '../SelectTextArea'
2425
import { FileUploadProps } from '../FileUpload'
@@ -99,8 +100,8 @@ export type DynamicDataTableRowType<K extends string, CustomStateType = Record<s
99100
disabled?: boolean
100101
/** An optional boolean indicating if an asterisk should be shown. */
101102
required?: boolean
102-
/** An optional tooltip text to show when hovering over cell. */
103-
tooltipText?: string
103+
/** An optional tooltip to show when hovering over cell. */
104+
tooltip?: Partial<Pick<TooltipProps, 'content' | 'className'>>
104105
} & DynamicDataTableCellData
105106
}
106107
id: string | number

src/Shared/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ export interface RuntimePluginVariables
349349
stepType: PluginType
350350
isRequired: boolean
351351
pluginIcon?: string
352+
description?: string
352353
}
353354

354355
export interface RuntimeParamsAPIResponseType {

0 commit comments

Comments
 (0)