Server IP : 104.21.14.103 / Your IP : 18.224.56.183 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/giankuin/dietcontrungnhanh.com/wp-content/plugins/ithemes-security-pro/pro/privilege/entries/profile/components/create-escalation/ |
Upload File : |
/** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import apiFetch from '@wordpress/api-fetch'; import { useCallback, useState } from '@wordpress/element'; import { useDispatch } from '@wordpress/data'; import { SelectControl } from '@wordpress/components'; /** * SolidWP dependencies */ import { TextVariant, TextWeight } from '@ithemes/ui'; /** * Internal dependencies */ import { coreStore } from '@ithemes/security.packages.data'; import { useAsync } from '@ithemes/security-hocs'; import { StyledDays, StyledDescription, StyledForm, StyledRoles, StyledTitle, StyledUpdateButton, StyledError, } from './styles'; export default function CreateEscalation( { userId, userRoles } ) { const [ tempRole, setTempRole ] = useState( userRoles[ 0 ].role ); const [ duration, setDuration ] = useState( 0 ); const { fetchUser } = useDispatch( coreStore ); const escalation = useCallback( () => apiFetch( { method: 'POST', path: 'ithemes-security/rpc/privilege/escalate', data: { id: userId, role: tempRole, days: duration, }, } ) .then( () => fetchUser( userId ) ), [ userId, tempRole, duration, fetchUser ] ); const { status: escalationStatus, execute: executeEscalation, error: escalationError, } = useAsync( escalation, false ); return ( <StyledForm> <StyledTitle variant={ TextVariant.DARK } weight={ TextWeight.HEAVY } text={ __( 'Set Temporary Role', 'it-l10n-ithemes-security-pro' ) } /> <StyledDescription variant={ TextVariant.MUTED } text={ __( 'Set the role which you would like to assign to the user temporarily and for how long you would like it to last.', 'it-l10n-ithemes-security-pro' ) } /> <StyledRoles> <SelectControl label={ __( 'Select a role for this user', 'it-l10n-ithemes-security-pro' ) } name="itsec_privilege_profile[role]" value={ tempRole } onChange={ setTempRole } > { userRoles.map( ( { role, label } ) => <option value={ role } key={ role }>{ label }</option> ) } </SelectControl> </StyledRoles> <StyledDays label={ __( 'Day(s)', 'it-l10n-ithemes-security-pro' ) } id="itsec_privilege_expires" type="number" min="1" value={ duration } onChange={ setDuration } /> <StyledUpdateButton onClick={ executeEscalation } isBusy={ escalationStatus === 'pending' } variant="primary" text={ __( 'Update User', 'it-l10n-ithemes-security-pro' ) } /> { escalationError && ( <StyledError text={ escalationError.message } /> ) } </StyledForm> ); }