import PropTypes from 'prop-types'; import React, { useEffect, useRef } from 'react'; import Alert from 'Components/Alert'; import FormGroup from 'Components/Form/FormGroup'; import FormInputButton from 'Components/Form/FormInputButton'; import FormInputGroup from 'Components/Form/FormInputGroup'; import FormLabel from 'Components/Form/FormLabel'; import OAuthInputConnector from 'Components/Form/OAuthInputConnector'; import Icon from 'Components/Icon'; import SpinnerButton from 'Components/Link/SpinnerButton'; import LoadingIndicator from 'Components/Loading/LoadingIndicator'; import ModalBody from 'Components/Modal/ModalBody'; import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import { icons, inputTypes, kinds } from 'Helpers/Props'; import { authenticationMethodOptions, authenticationRequiredOptions, authenticationRequiredWarning } from 'Settings/General/SecuritySettings'; import styles from './AuthenticationRequiredModalContent.css'; const oauthData = { implementation: { value: 'PlexImport' }, configContract: { value: 'PlexListSettings' }, fields: [ { type: 'textbox', name: 'accessToken' }, { type: 'oAuth', name: 'signIn', value: 'startAuth' } ] }; function onModalClose() { // No-op } function AuthenticationRequiredModalContent(props) { const { isPopulated, plexServersPopulated, error, isSaving, settings, onInputChange, onSavePress, dispatchFetchStatus } = props; const { authenticationMethod, authenticationRequired, username, password, plexAuthServer, plexRequireOwner, oidcClientId, oidcClientSecret, oidcAuthority } = settings; const authenticationEnabled = authenticationMethod && authenticationMethod.value !== 'none'; const showUserPass = authenticationMethod && ['basic', 'forms'].includes(authenticationMethod.value); const plexEnabled = authenticationMethod && authenticationMethod.value === 'plex'; const oidcEnabled = authenticationMethod && authenticationMethod.value === 'oidc'; const didMount = useRef(false); useEffect(() => { if (!isSaving && didMount.current) { dispatchFetchStatus(); } didMount.current = true; }, [isSaving, dispatchFetchStatus]); return ( Authentication Required {authenticationRequiredWarning} { isPopulated && !error ?
Authentication { authenticationEnabled ? Authentication Required : null } { showUserPass && <> Username Password } { plexEnabled && <> Plex Server : 'Fetch'} name="plexAuth" provider="importList" providerData={oauthData} section="settings.importLists" onChange={onInputChange} /> ]} onChange={onInputChange} {...plexAuthServer} /> Restrict Access to Server Owner } { oidcEnabled && <> Authority ClientId ClientSecret }
: null } { !isPopulated && !error ? : null }
Save
); } AuthenticationRequiredModalContent.propTypes = { isPopulated: PropTypes.bool.isRequired, plexServersPopulated: PropTypes.bool.isRequired, error: PropTypes.object, isSaving: PropTypes.bool.isRequired, saveError: PropTypes.object, settings: PropTypes.object.isRequired, onInputChange: PropTypes.func.isRequired, onSavePress: PropTypes.func.isRequired, dispatchFetchStatus: PropTypes.func.isRequired }; export default AuthenticationRequiredModalContent;