diff --git a/packages/dataviews/src/types.ts b/packages/dataviews/src/types.ts index b46c8b89b2f441..065deaac687e6f 100644 --- a/packages/dataviews/src/types.ts +++ b/packages/dataviews/src/types.ts @@ -1,8 +1,3 @@ -/** - * WordPress dependencies - */ -import type { IconType } from '@wordpress/components'; - /** * External dependencies */ @@ -183,8 +178,10 @@ interface ActionBase { /** * The icon of the action. (Either a string or an SVG element) + * This should be IconType from the components package + * but that import is breaking typescript build for the moment. */ - icon?: IconType; + icon?: any; /** * Whether the action is disabled. diff --git a/packages/dataviews/src/view-list.tsx b/packages/dataviews/src/view-list.tsx index 022e2a7222f770..203707e0c3ccf1 100644 --- a/packages/dataviews/src/view-list.tsx +++ b/packages/dataviews/src/view-list.tsx @@ -33,6 +33,7 @@ import { moreVertical } from '@wordpress/icons'; */ import { unlock } from './lock-unlock'; import type { + Action, Data, Item, NormalizedField, @@ -41,18 +42,6 @@ import type { import { ActionsDropdownMenuGroup, ActionModal } from './item-actions'; -interface Action { - callback: ( items: Item[] ) => void; - icon: any; - id: string; - isDestructive: boolean | undefined; - isEligible: ( item: Item ) => boolean | undefined; - isPrimary: boolean | undefined; - label: string; - modalHeader: string; - RenderModal: ( props: any ) => JSX.Element; -} - interface ListViewProps { actions: Action[]; data: Data; @@ -215,7 +204,7 @@ function ListItem( { width: 'auto', } } > - { primaryAction && !! primaryAction.RenderModal && ( + { primaryAction && 'RenderModal' in primaryAction && (
) } - { primaryAction && ! primaryAction.RenderModal && ( -
- - primaryAction.callback( [ - item, - ] ) - } - /> - } - /> -
- ) } + { primaryAction && + ! ( 'RenderModal' in primaryAction ) && ( +
+ + primaryAction.callback( [ + item, + ] ) + } + /> + } + /> +
+ ) }