-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
At a glance: add Activity Log card (#8199)
* At a glance: add Activity Log card * Pass down site urls to DashActivity component * Pass only siteRawUrl prop * Introduce property isModule in DashItem so cards for elements that are not modules, like Activity Log, can opt out of the toggle/button on the right of the header of the cards in dashboard
- Loading branch information
1 parent
95253f7
commit baad73d
Showing
5 changed files
with
103 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import DashItem from 'components/dash-item'; | ||
import { translate as __ } from 'i18n-calypso'; | ||
import get from 'lodash/get'; | ||
import includes from 'lodash/includes'; | ||
import classNames from 'classnames'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getSitePlan } from 'state/site'; | ||
import { isDevMode } from 'state/connection'; | ||
import { PLAN_JETPACK_BUSINESS, PLAN_JETPACK_BUSINESS_MONTHLY } from 'lib/plans/constants'; | ||
|
||
class DashActivity extends Component { | ||
static propTypes = { | ||
inDevMode: PropTypes.bool.isRequired, | ||
siteRawUrl: PropTypes.string.isRequired, | ||
sitePlan: PropTypes.object.isRequired | ||
}; | ||
|
||
static defaultProps = { | ||
inDevMode: false, | ||
siteRawUrl: '', | ||
sitePlan: '' | ||
}; | ||
|
||
render() { | ||
const { siteRawUrl, inDevMode } = this.props; | ||
const sitePlan = get( this.props.sitePlan, 'product_slug', 'jetpack_free' ); | ||
const activityLogLink = <a href={ `https://wordpress.com/stats/activity/${ siteRawUrl }` } />; | ||
const hasBackups = includes( [ PLAN_JETPACK_BUSINESS, PLAN_JETPACK_BUSINESS_MONTHLY ], sitePlan ); | ||
const maybeUpgrade = hasBackups | ||
? __( "{{a}}View your site's activity{{/a}} in a single feed where you can see when events occur and rewind them if you need to.", { | ||
components: { | ||
a: activityLogLink | ||
} | ||
} ) | ||
: __( "{{a}}View your site's activity{{/a}} in a single feed where you can see when events occur and, {{plan}}with a plan{{/plan}}, rewind them if you need to.", { | ||
components: { | ||
a: activityLogLink, | ||
plan: <a href={ `https://jetpack.com/redirect/?source=plans-main-bottom&site=${ siteRawUrl }` } /> | ||
} | ||
} ); | ||
|
||
return ( | ||
<div className="jp-dash-item__interior"> | ||
<DashItem | ||
label={ __( 'Activity' ) } | ||
isModule={ false } | ||
className={ classNames( { | ||
'jp-dash-item__is-inactive': inDevMode | ||
} ) } | ||
pro={ ! hasBackups } | ||
> | ||
<p className="jp-dash-item__description"> | ||
{ | ||
inDevMode | ||
? __( 'Unavailable in Dev Mode.' ) | ||
: maybeUpgrade | ||
} | ||
</p> | ||
</DashItem> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default connect( | ||
state => ( { | ||
sitePlan: getSitePlan( state ), | ||
inDevMode: isDevMode( state ), | ||
} ) | ||
)( DashActivity ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters