import { Icon, plugins } from '@wordpress/icons'; import clsx from 'clsx'; import TextPlaceholder from 'calypso/jetpack-cloud/sections/partner-portal/text-placeholder'; import PluginCommonAction from '../plugin-common-actions'; import type { Columns, RowFormatterArgs } from '../../types'; import type { ReactElement, ReactNode } from 'react'; import './style.scss'; interface Props { isLoading: boolean; columns: Columns; items: Array< any >; rowFormatter: ( args: RowFormatterArgs ) => ReactNode; primaryKey: string; renderActions?: ( args: any ) => ReactElement; className?: string; } export default function PluginCommonTable( { isLoading, columns, items, rowFormatter, primaryKey, renderActions, className, }: Props ) { return ( { columns .filter( ( column ) => column.header ) .map( ( column ) => ( ) ) } { isLoading ? ( { columns.map( ( column ) => ( ) ) } ) : ( items.map( ( item ) => { const id = item[ primaryKey ]; return ( { columns.map( ( column ) => { if ( column.key === 'bulk-actions' ) { // We don't want to render an empty table cell for the bulk actions. return null; } return ( ); } ) } { renderActions && ( ) } ); } ) ) }
{ column.header }
{ column.key === 'plugin' && ( ) }
{ rowFormatter( { columnKey: column.key, item } ) }
); }