import { Card } from '@automattic/components'; import { Icon, plugins } from '@wordpress/icons'; import clsx from 'clsx'; import FormInputCheckbox from 'calypso/components/forms/form-checkbox'; import PluginCommonActions from '../plugin-common-actions'; import type { Columns, RowFormatterArgs } from '../../types'; import type { SiteDetails } from '@automattic/data-stores'; import type { ReactElement, ReactNode } from 'react'; import './style.scss'; interface Props { item: any; selectedSite?: SiteDetails; rowFormatter: ( args: RowFormatterArgs ) => ReactNode; columns: Columns; renderActions?: ( args: any ) => ReactElement; } export default function PluginCommonCard( { item, selectedSite, rowFormatter, columns, renderActions, }: Props ) { const columnKeys: { [ key: string ]: boolean } = columns.reduce( ( obj, cur ) => ( { ...obj, [ cur.key ]: true } ), {} ); const showLeftContent = columnKeys[ 'plugin' ]; return (
{ showLeftContent && ( <>
{ item?.isSelectable && ( ) }
{ item.icon ? ( { ) : ( ) }
) }
{ columnKeys[ 'plugin' ] && (
{ rowFormatter( { columnKey: 'plugin', item, isSmallScreen: true } ) }
) } { columnKeys[ 'site-name' ] && (
{ rowFormatter( { columnKey: 'site-name', item } ) }
) } { columnKeys[ 'update' ] && rowFormatter( { columnKey: 'update', item, isSmallScreen: true, } ) } { columnKeys[ 'last-updated' ] && (
{ rowFormatter( { columnKey: 'last-updated', item, isSmallScreen: true, } ) }
) } { ( columnKeys[ 'active' ] || columnKeys[ 'autoupdate' ] ) && (
{ columnKeys[ 'activate' ] && (
{ rowFormatter( { columnKey: 'activate', item, isSmallScreen: true, selectedSite, } ) }
) } { columnKeys[ 'autoupdate' ] && (
{ rowFormatter( { columnKey: 'autoupdate', item, isSmallScreen: true, selectedSite, } ) }
) }
) } { columnKeys[ 'sites' ] && (
{ rowFormatter( { columnKey: 'sites', item, isSmallScreen: true, } ) }
) } { columnKeys[ 'install' ] && (
{ rowFormatter( { columnKey: 'install', item, isSmallScreen: true, } ) }
) }
{ renderActions && (
) }
); }