@@ -23,6 +23,7 @@ import { IconButton } from '@mui/material'
2323import { __ } from 'src/utilities/Intl'
2424import * as connectActions from 'src/redux/actions/Connect'
2525import { selectConnectConfig } from 'src/redux/reducers/configSlice'
26+ import { getWidgetVersion } from 'src/redux/selectors/app'
2627import { getMembers } from 'src/redux/selectors/Connect'
2728
2829import { AnalyticEvents , PageviewInfo } from 'src/const/Analytics'
@@ -61,6 +62,20 @@ export const initialState = {
6162
6263const MAX_SUGGESTED_LIST_SIZE = 25
6364
65+ const getVersionLabel = ( version ) => {
66+ // Check for SHA pattern
67+ if ( typeof version === 'string' && / ^ [ 0 - 9 a - f ] { 7 , 40 } $ / i. test ( version ) ) {
68+ return `v.${ version . slice ( 0 , 7 ) } `
69+ }
70+
71+ // Trim a string that isn't a SHA pattern
72+ if ( typeof version === 'string' && version . trim ( ) !== '' ) {
73+ return `v.${ version . trim ( ) } `
74+ }
75+
76+ return ''
77+ }
78+
6479const reducer = ( state , action ) => {
6580 switch ( action . type ) {
6681 case SEARCH_ACTIONS . LOAD_SUCCESS :
@@ -131,6 +146,7 @@ export const Search = React.forwardRef((_, navigationRef) => {
131146 useAnalyticsPath ( ...PageviewInfo . CONNECT_SEARCH , { } , false )
132147 const [ state , dispatch ] = useReducer ( reducer , initialState )
133148 const [ ariaLiveRegionMessage , setAriaLiveRegionMessage ] = useState ( '' )
149+ const [ headerClicks , setHeaderClicks ] = useState ( 0 )
134150 const searchInput = useRef ( '' )
135151 const sendAnalyticsEvent = useAnalyticsEvent ( )
136152 const postMessageFunctions = useContext ( PostMessageContext )
@@ -140,6 +156,7 @@ export const Search = React.forwardRef((_, navigationRef) => {
140156 // Redux
141157 const reduxDispatch = useDispatch ( )
142158 const connectConfig = useSelector ( selectConnectConfig )
159+ const widgetVersion = useSelector ( getWidgetVersion )
143160 const connectedMembers = useSelector ( getMembers )
144161 const usePopularOnly = useSelector ( ( state ) => {
145162 const clientProfile = state . profiles . clientProfile || { }
@@ -155,6 +172,7 @@ export const Search = React.forwardRef((_, navigationRef) => {
155172
156173 const MINIMUM_SEARCH_LENGTH = 2
157174 const isFirstTimeUser = connectedMembers . length === 0
175+ const versionLabel = getVersionLabel ( widgetVersion )
158176
159177 useImperativeHandle ( navigationRef , ( ) => {
160178 return {
@@ -331,13 +349,20 @@ export const Search = React.forwardRef((_, navigationRef) => {
331349 component = { 'h2' }
332350 data-test = "search-header"
333351 id = "connect-search-header"
352+ onClick = { ( ) => setHeaderClicks ( ( prev ) => prev + 1 ) }
334353 style = { inlineStyles . headerText }
335354 tabIndex = { - 1 }
336355 truncate = { false }
337356 variant = "H2"
338357 >
339358 { __ ( 'Select your institution' ) }
340359 </ Text >
360+ { /* This version is a hidden feature unless a user is told how to find it */ }
361+ { headerClicks >= 5 && versionLabel && (
362+ < Text data-test = "search-version-label" style = { inlineStyles . version } >
363+ { versionLabel }
364+ </ Text >
365+ ) }
341366 < TextField
342367 InputProps = { {
343368 startAdornment : (
@@ -450,6 +475,12 @@ const getStyles = (tokens) => {
450475 spinner : {
451476 marginTop : '24px' ,
452477 } ,
478+ version : {
479+ fontWeight : tokens . FontWeight . Semibold ,
480+ fontSize : tokens . FontSize . Small ,
481+ marginTop : '-16px' ,
482+ marginBottom : '16px' ,
483+ } ,
453484 }
454485}
455486
0 commit comments