Display sync status in Channels card.

This commit is contained in:
Gan Eng Chin 2022-12-13 21:36:09 +08:00
parent 02ce7cccc5
commit 437ebb20a8
No known key found for this signature in database
GPG Key ID: 94D5D972860ADB01
2 changed files with 86 additions and 5 deletions

View File

@ -1,2 +1,22 @@
.woocommerce-marketing-installed-channel-card-body { .woocommerce-marketing-installed-channel-card-body {
.woocommerce-marketing-sync-status {
display: flex;
align-items: center;
gap: $gap-smallest;
&__failed {
color: $alert-red;
fill: $alert-red;
}
&__syncing {
color: #008a20;
fill: #008a20;
}
&__synced {
color: #008a20;
fill: #008a20;
}
}
} }

View File

@ -1,24 +1,85 @@
/** /**
* External dependencies * External dependencies
*/ */
import { CardBody } from '@wordpress/components'; import { Button } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import GridiconCheckmarkCircle from 'gridicons/dist/checkmark-circle';
import GridiconSync from 'gridicons/dist/sync';
import GridiconNotice from 'gridicons/dist/notice';
import classnames from 'classnames';
/** /**
* Internal dependencies * Internal dependencies
*/ */
import { InstalledChannel } from '~/marketing/types'; import { PluginCardBody } from '~/marketing/components';
import { InstalledChannel, SyncStatusType } from '~/marketing/types';
import './InstalledChannelCardBody.scss'; import './InstalledChannelCardBody.scss';
type InstalledChannelCardBodyProps = { type InstalledChannelCardBodyProps = {
installedChannel: InstalledChannel; installedChannel: InstalledChannel;
}; };
type SyncStatusPropsType = {
status: SyncStatusType;
};
const iconSize = 18;
const className = 'woocommerce-marketing-sync-status';
const SyncStatus: React.FC< SyncStatusPropsType > = ( { status } ) => {
if ( status === 'failed' ) {
return (
<div
className={ classnames( className, `${ className }__failed` ) }
>
<GridiconNotice size={ iconSize } />
{ __( 'Sync failed', 'woocommerce' ) }
</div>
);
}
if ( status === 'syncing' ) {
return (
<div
className={ classnames( className, `${ className }__syncing` ) }
>
<GridiconSync size={ iconSize } />
{ __( 'Syncing', 'woocommerce' ) }
</div>
);
}
return (
<div className={ classnames( className, `${ className }__synced` ) }>
<GridiconCheckmarkCircle size={ iconSize } />
{ __( 'Synced', 'woocommerce' ) }
</div>
);
};
export const InstalledChannelCardBody: React.FC< export const InstalledChannelCardBody: React.FC<
InstalledChannelCardBodyProps InstalledChannelCardBodyProps
> = ( { installedChannel } ) => { > = ( { installedChannel } ) => {
return ( return (
<CardBody className="woocommerce-marketing-installed-channel-card-body"> <PluginCardBody
InstalledChannelCardBody className="woocommerce-marketing-installed-channel-card-body"
</CardBody> icon={
<img
src={ installedChannel.icon }
alt={ installedChannel.title }
/>
}
name={ installedChannel.title }
description={
<div>
<SyncStatus status={ installedChannel.syncStatus } />
</div>
}
button={
<Button variant="secondary" href={ installedChannel.manageUrl }>
{ __( 'Manage', 'woocommerce' ) }
</Button>
}
/>
); );
}; };