Changeset 5024 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/widget-area/widgets/support/index.jsx
- Timestamp:
- 03/01/2017 06:08:54 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/widget-area/widgets/support/index.jsx
r4223 r5024 1 import React from 'react'; 1 /** 2 * External dependencies. 3 */ 4 import React, { Component, PropTypes } from 'react'; 5 import { connect } from 'react-redux'; 6 import { identity } from 'lodash'; 7 import { localize } from 'i18n-calypso'; 2 8 3 export default React.createClass( { 4 displayName: 'SupportWidget', 5 resolutions: false, 9 /** 10 * Internal dependencies. 11 */ 12 import { getPlugin } from 'state/selectors'; 13 14 export class SupportWidget extends Component { 15 resolutions: false; 16 17 static propTypes = { 18 plugin: PropTypes.object, 19 translate: PropTypes.func, 20 }; 21 22 static defaultProps = { 23 plugin: {}, 24 translate: identity, 25 }; 6 26 7 27 componentWillMount() { 8 this.resolutions = ( this.props.plugin.support_threads || 'buddypress' === this.props.plugin.slug || 'bbpress' === this.props.plugin.slug ); 9 }, 28 const { meta, slug } = this.props.plugin; 29 this.resolutions = ( meta.support_threads || 'buddypress' === slug || 'bbpress' === slug ); 30 } 10 31 11 32 componentDidUpdate() { 12 this.resolutions = this.resolutions || this.props.plugin. support_threads;13 } ,33 this.resolutions = this.resolutions || this.props.plugin.meta.support_threads; 34 } 14 35 15 36 supportBar() { 16 const { support_threads: threads, support_threads_resolved: resolved } = this.props.plugin; 37 const { support_threads: threads, support_threads_resolved: resolved } = this.props.plugin.meta; 38 39 if ( ! this.resolutions ) { 40 return ( 41 <p>{ this.props.translate( 'Got something to say? Need help?' ) }</p> 42 ); 43 } 17 44 18 45 return ( 19 46 <div> 20 <p className="aside"> Issues resolved in last two months:</p>47 <p className="aside">{ this.props.translate( 'Issues resolved in last two months:' ) }</p> 21 48 <p className="counter-container"> 22 49 <span className="counter-back"> … … 24 51 </span> 25 52 <span className="counter-count"> 26 { resolved } out of { threads}53 { this.props.translate( '%(resolved)s out of %(threads)s', { args: { resolved, threads } } ) } 27 54 </span> 28 55 </p> 29 56 </div> 30 ) 31 } ,57 ); 58 } 32 59 33 60 getSupportUrl() { 34 let supportURL = `https://wordpress.org/support/plugin/${ this.props.plugin.slug }/`; 61 const { slug } = this.props.plugin; 62 let supportURL = `https://wordpress.org/support/plugin/${ slug }/`; 35 63 36 64 /* … … 38 66 * In the future we could open this up to all plugins that define a custom support URL. 39 67 */ 40 if ( 'buddypress' === this.props.plugin.slug ) {68 if ( 'buddypress' === slug ) { 41 69 supportURL = 'https://buddypress.org/support/'; 42 } else if ( 'bbpress' === this.props.plugin.slug ) {70 } else if ( 'bbpress' === slug ) { 43 71 supportURL = 'https://bbpress.org/forums/'; 44 72 } 45 73 46 74 return supportURL; 47 } ,75 } 48 76 49 77 render() { 50 78 return ( 51 79 <div className="widget plugin-support"> 52 <h4 className="widget-title">Support</h4> 53 { this.resolutions ? 54 this.supportBar() : 55 <p>Got something to say? Need help?</p> 56 } 80 <h4 className="widget-title">{ this.props.translate( 'Support' ) }</h4> 81 82 { this.supportBar() } 83 57 84 <p> 58 <a className="button" href={ this.getSupportUrl() }>View support forum</a> 85 <a className="button" href={ this.getSupportUrl() }> 86 { this.props.translate( 'View support forum' ) } 87 </a> 59 88 </p> 60 89 </div> 61 ) 90 ); 62 91 } 63 } ); 92 } 93 94 export default connect( 95 ( state ) => ( { 96 plugin: getPlugin( state ), 97 } ), 98 )( localize( SupportWidget ) );
Note: See TracChangeset
for help on using the changeset viewer.