react-code-dataset / wp-calypso /client /me /notification-settings /settings-form /device-selector.jsx
react-code-dataset / wp-calypso /client /me /notification-settings /settings-form /device-selector.jsx
Download wp-calypso/client/me/notification-settings/settings-form/device-selector.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/me/notification-settings/settings-form/device-selector.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/me/notification-settings/settings-form/device-selector.jsx
-
curl -L -o device-selector.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/me/notification-settings/settings-form/device-selector.jsx
1.08 kB
| import PropTypes from 'prop-types'; | |
| import FormSelect from 'calypso/components/forms/form-select'; | |
| import { useNotificationDevicesQuery } from 'calypso/data/notification-devices/use-notification-devices-query'; | |
| import StreamHeader from './stream-header'; | |
| function NotificationSettingsFormDeviceSelector( { selectedDeviceId, onChange } ) { | |
| const { data: devices = [] } = useNotificationDevicesQuery(); | |
| if ( devices.length === 1 ) { | |
| return <StreamHeader title={ devices[ 0 ].name } />; | |
| } | |
| return ( | |
| <div className="notification-settings-form-header"> | |
| <div className="notification-settings-form-header__title"> | |
| <FormSelect value={ selectedDeviceId } onChange={ onChange }> | |
| { devices.map( ( { id, name } ) => ( | |
| <option key={ `device-notifications-${ id }` } value={ id }> | |
| { name } | |
| </option> | |
| ) ) } | |
| </FormSelect> | |
| </div> | |
| </div> | |
| ); | |
| } | |
| NotificationSettingsFormDeviceSelector.propTypes = { | |
| selectedDeviceId: PropTypes.number.isRequired, | |
| onChange: PropTypes.func.isRequired, | |
| }; | |
| export default NotificationSettingsFormDeviceSelector; | |