Display sync status in Channels card.
This commit is contained in:
parent
02ce7cccc5
commit
437ebb20a8
|
@ -1,2 +1,22 @@
|
|||
.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,85 @@
|
|||
/**
|
||||
* 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
|
||||
*/
|
||||
import { InstalledChannel } from '~/marketing/types';
|
||||
import { PluginCardBody } from '~/marketing/components';
|
||||
import { InstalledChannel, SyncStatusType } from '~/marketing/types';
|
||||
import './InstalledChannelCardBody.scss';
|
||||
|
||||
type InstalledChannelCardBodyProps = {
|
||||
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<
|
||||
InstalledChannelCardBodyProps
|
||||
> = ( { installedChannel } ) => {
|
||||
return (
|
||||
<CardBody className="woocommerce-marketing-installed-channel-card-body">
|
||||
InstalledChannelCardBody
|
||||
</CardBody>
|
||||
<PluginCardBody
|
||||
className="woocommerce-marketing-installed-channel-card-body"
|
||||
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>
|
||||
}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue