@@ -7,6 +7,7 @@ import { Helmet } from 'react-helmet';
77import { connect } from 'react-redux' ;
88import { compose } from 'redux' ;
99
10+ import { withInstallHelpers } from 'amo/installAddon' ;
1011import { sendAddonAbuseReport } from 'amo/reducers/abuse' ;
1112import { getCurrentUser } from 'amo/reducers/users' ;
1213import translate from 'amo/i18n/translate' ;
@@ -22,6 +23,8 @@ import type { ErrorHandlerType } from 'amo/types/errorHandler';
2223import type { I18nType } from 'amo/types/i18n' ;
2324import type { AddonType } from 'amo/types/addons' ;
2425import type { DispatchFunc } from 'amo/types/redux' ;
26+ import type { WithInstallHelpersInjectedProps } from 'amo/installAddon' ;
27+ import type { InstalledAddon } from 'amo/reducers/installations' ;
2528
2629import './styles.scss' ;
2730
@@ -35,6 +38,7 @@ type PropsFromState = {|
3538 abuseReport : AddonAbuseState | null ,
3639 currentUser : UserType | null ,
3740 loading : boolean ,
41+ installedAddon : InstalledAddon | null ,
3842| } ;
3943
4044type DefaultProps = { |
@@ -45,6 +49,7 @@ type InternalProps = {|
4549 ...Props ,
4650 ...PropsFromState ,
4751 ...DefaultProps ,
52+ ...WithInstallHelpersInjectedProps ,
4853 dispatch : DispatchFunc ,
4954 i18n : I18nType ,
5055| } ;
@@ -173,7 +178,7 @@ export class FeedbackFormBase extends React.Component<InternalProps, State> {
173178 onSubmit: HTMLElementEventHandler = ( event : ElementEvent ) => {
174179 event . preventDefault ( ) ;
175180
176- const { addon, dispatch, errorHandler } = this . props ;
181+ const { addon, dispatch, errorHandler, installedAddon } = this . props ;
177182 const { email, name, text, category, violationLocation } = this . state ;
178183
179184 invariant ( text . trim ( ) . length , 'A report cannot be sent with no content.' ) ;
@@ -190,6 +195,7 @@ export class FeedbackFormBase extends React.Component<InternalProps, State> {
190195 message : text ,
191196 reason : category ,
192197 location : violationLocation ,
198+ addonVersion : installedAddon ?. version || null ,
193199 } ) ,
194200 ) ;
195201 } ;
@@ -457,15 +463,19 @@ export class FeedbackFormBase extends React.Component<InternalProps, State> {
457463function mapStateToProps ( state : AppState , ownProps : Props ) : PropsFromState {
458464 const { addon } = ownProps ;
459465 const currentUser = getCurrentUser ( state . users ) ;
466+ const installedAddon =
467+ ( addon ?. guid && state . installations [ addon . guid ] ) || null ;
460468
461469 return {
462470 abuseReport : ( addon ?. slug && state . abuse . bySlug [ addon . slug ] ) || null ,
463471 currentUser,
464472 loading : state . abuse . loading ,
473+ installedAddon,
465474 } ;
466475}
467476
468477const FeedbackForm : React . ComponentType < Props > = compose(
478+ withInstallHelpers,
469479 connect(mapStateToProps),
470480 translate(),
471481)(FeedbackFormBase);
0 commit comments