mirror of https://github.com/jitsi/jitsi-meet
feat: Add search to speaker stats (#9510)
* Additional setting to add search to speaker stats * Add translation for speaker stats search placeholder * Unset speaker stats search input autocomplete * Fix lint errors for speaker stats search * Change setting to disableSpeakerStatsSearch * Better Object.prototype.hasOwnProperty.call alternative * Make SpeakerStatsSearch a functional component * Align header with input and use material-ui styles instead of scss and remove SpeakerStats header and fix dialog close * Resolve code style remark in SpeakerStats constructor * Resolve component empty return value remark in SpeakerStatsSearch * Resolve get config property in outside function remark in SpeakerStatsSearch * Resolve unnecessary anonymous function remark in SpeakerStatsSearchpull/9723/head jitsi-meet_6179
parent
ae33755913
commit
c123ff9e15
@ -0,0 +1,73 @@ |
||||
/* @flow */ |
||||
|
||||
import { FieldTextStateless as TextField } from '@atlaskit/field-text'; |
||||
import { makeStyles } from '@material-ui/core/styles'; |
||||
import React, { useCallback, useState } from 'react'; |
||||
import { useTranslation } from 'react-i18next'; |
||||
import { useSelector } from 'react-redux'; |
||||
|
||||
import { getFieldValue } from '../../base/react'; |
||||
import { isSpeakerStatsSearchDisabled } from '../functions'; |
||||
|
||||
const useStyles = makeStyles(() => { |
||||
return { |
||||
speakerStatsSearch: { |
||||
position: 'absolute', |
||||
right: '50px', |
||||
top: '-5px' |
||||
} |
||||
}; |
||||
}); |
||||
|
||||
/** |
||||
* The type of the React {@code Component} props of {@link SpeakerStatsSearch}. |
||||
*/ |
||||
type Props = { |
||||
|
||||
/** |
||||
* The function to initiate the change in the speaker stats table. |
||||
*/ |
||||
onSearch: Function, |
||||
|
||||
}; |
||||
|
||||
/** |
||||
* React component for display an individual user's speaker stats. |
||||
* |
||||
* @returns {React$Element<any>} |
||||
*/ |
||||
function SpeakerStatsSearch({ onSearch }: Props) { |
||||
const classes = useStyles(); |
||||
const { t } = useTranslation(); |
||||
const [ searchValue, setSearchValue ] = useState<string>(''); |
||||
const onChange = useCallback((evt: Event) => { |
||||
const value = getFieldValue(evt); |
||||
|
||||
setSearchValue(value); |
||||
|
||||
onSearch && onSearch(value); |
||||
}, []); |
||||
const disableSpeakerStatsSearch = useSelector(isSpeakerStatsSearchDisabled); |
||||
|
||||
if (disableSpeakerStatsSearch) { |
||||
return null; |
||||
} |
||||
|
||||
return ( |
||||
<div className = { classes.speakerStatsSearch }> |
||||
<TextField |
||||
autoComplete = 'off' |
||||
autoFocus = { false } |
||||
compact = { true } |
||||
name = 'speakerStatsSearch' |
||||
onChange = { onChange } |
||||
placeholder = { t('speakerStats.search') } |
||||
shouldFitContainer = { false } |
||||
type = 'text' |
||||
value = { searchValue } /> |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
export default SpeakerStatsSearch; |
||||
|
@ -0,0 +1,11 @@ |
||||
// @flow
|
||||
|
||||
/** |
||||
* Checks if the speaker stats search is disabled. |
||||
* |
||||
* @param {*} state - The redux state. |
||||
* @returns {boolean} - True if the speaker stats search is disabled and false otherwise. |
||||
*/ |
||||
export function isSpeakerStatsSearchDisabled(state: Object) { |
||||
return state['features/base/config']?.disableSpeakerStatsSearch; |
||||
} |
Loading…
Reference in new issue