1- // Copyright (c) 2020-2023 The MathWorks, Inc.
1+ // Copyright 2020-2023 The MathWorks, Inc.
22
3- import React , { useMemo } from 'react' ;
3+ import React from 'react' ;
44import PropTypes from 'prop-types' ;
55import { useSelector } from 'react-redux' ;
66import ReactTooltip from 'react-tooltip' ;
@@ -12,10 +12,11 @@ import {
1212 selectMatlabStarting ,
1313 selectMatlabStopping ,
1414 selectMatlabDown ,
15- selectMatlabVersion ,
1615 selectError ,
1716 selectIsAuthenticated ,
1817 selectAuthEnabled ,
18+ selectLicensingIsMhlm ,
19+ selectIsEntitled ,
1920} from '../../selectors' ;
2021import {
2122 fetchStartMatlab ,
@@ -40,20 +41,16 @@ function Controls({
4041 const matlabUp = useSelector ( selectMatlabUp ) ;
4142 const matlabStopping = useSelector ( selectMatlabStopping ) ;
4243 const matlabDown = useSelector ( selectMatlabDown ) ;
43- const matlabVersion = useSelector ( selectMatlabVersion ) ;
4444 const error = useSelector ( selectError ) ;
4545 const authEnabled = useSelector ( selectAuthEnabled ) ;
4646 const isAuthenticated = useSelector ( selectIsAuthenticated ) ;
4747 const licensingInfo = useSelector ( selectLicensingInfo ) ;
4848 const canResetLicensing = licensed && ! submitting ;
4949
50- const feedbackBody = useMemo (
51- ( ) => `%0D%0A
52- Thank you for providing feedback.%0D%0A
53- %0D%0A
54- MATLAB version: ${ matlabVersion } %0D%0A` ,
55- [ matlabVersion ]
56- ) ;
50+ // If licensing type is MHLM and the user is not entitled ( MATLAB version couldn't be determined (VersionInfo.xml was not found))
51+ // then start, stop & signout buttons should be disabled.
52+ const licensingIsMhlm = useSelector ( selectLicensingIsMhlm ) ;
53+ const isEntitled = useSelector ( selectIsEntitled ) ;
5754
5855 let licensingData , licensingConfirmationMessage ;
5956 switch ( licensingInfo ?. type ) {
@@ -136,7 +133,7 @@ MATLAB version: ${matlabVersion}%0D%0A`,
136133 data-testid = 'startMatlabBtn'
137134 className = { getBtnClass ( matlabUp ? 'restart' : 'start' ) }
138135 onClick = { ( ) => callback ( Confirmations . START ) }
139- disabled = { ! licensed || matlabStarting || matlabStopping || ( authEnabled && ! isAuthenticated ) }
136+ disabled = { ! licensed || matlabStarting || matlabStopping || ( authEnabled && ! isAuthenticated ) || ( licensingIsMhlm && ! isEntitled ) }
140137 data-for = "control-button-tooltip"
141138 data-tip = { `${ matlabUp ? 'Restart' : 'Start' } MATLAB` }
142139 >
@@ -160,7 +157,7 @@ MATLAB version: ${matlabVersion}%0D%0A`,
160157 data-testid = 'unsetLicensingBtn'
161158 className = { getBtnClass ( 'sign-out' ) }
162159 onClick = { ( ) => callback ( Confirmations . SIGN_OUT ) }
163- disabled = { ! canResetLicensing || ( authEnabled && ! isAuthenticated ) }
160+ disabled = { ! canResetLicensing || ( authEnabled && ! isAuthenticated ) || ( licensingIsMhlm && ! isEntitled ) }
164161 data-for = "control-button-tooltip"
165162 data-tip = { licensingData . dataTip }
166163 >
@@ -183,9 +180,11 @@ MATLAB version: ${matlabVersion}%0D%0A`,
183180 id = "feedback"
184181 data-testid = 'feedbackLink'
185182 className = "btn btn_color_mediumgray companion_btn"
186- href = { `mailto:[email protected] ?subject=MATLAB-PROXY Feedback&body=${ feedbackBody } ` } 183+ href = "https://github.com/mathworks/matlab-proxy/issues/new/choose"
184+ target = "_blank"
185+ rel = "noreferrer"
187186 data-for = "control-button-tooltip"
188- data-tip = "Send feedback (opens your default email application )"
187+ data-tip = "Provide feedback (opens matlab-proxy repository on github.com in a new tab )"
189188 >
190189 < span className = 'icon-custom-feedback' > </ span >
191190 < span className = 'btn-label' > Feedback</ span >
0 commit comments