File size: 1,672 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
import clsx from 'clsx';
import * as React from 'react';
import { isSuccessfulRealtimeBackup } from 'calypso/lib/jetpack/backup-utils';
import { Activity } from '../types';
import ActionsButton from './actions-button';
import ExpandContent from './expand-content';
import './style.scss';
type OwnProps = {
siteId: number;
activity: Activity;
isContentExpanded?: boolean;
onToggleContent?: () => void;
availableActions?: Array< string >;
onClickClone?: ( period: string ) => void;
hideExpandedContent?: boolean;
useSplitButton?: boolean;
};
const Toolbar: React.FC< OwnProps > = ( {
siteId,
activity,
isContentExpanded,
onToggleContent,
availableActions,
onClickClone,
hideExpandedContent = false,
useSplitButton = false,
} ) => {
const isRewindable = isSuccessfulRealtimeBackup( activity );
const { streams } = activity;
if ( ! isRewindable && ! streams ) {
return null;
}
const showStreams = streams && ! hideExpandedContent;
const classNames = clsx( {
// force the actions to stay in the left if we aren't showing the content link
'activity-card__toolbar': showStreams || useSplitButton,
'activity-card__toolbar--reverse': ! showStreams && ! useSplitButton,
'activity-card__split-button': useSplitButton,
} );
return (
<div className={ classNames }>
{ showStreams && (
<ExpandContent isExpanded={ isContentExpanded } onToggle={ onToggleContent } />
) }
{ isRewindable && (
<ActionsButton
siteId={ siteId }
activity={ activity }
availableActions={ availableActions }
onClickClone={ onClickClone }
useSplitButton={ useSplitButton }
/>
) }
</div>
);
};
export default Toolbar;
|