2020-03-27 22:32:33 +00:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
import { Subuser } from '@/state/server/subusers';
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
import { faPencilAlt } from '@fortawesome/free-solid-svg-icons/faPencilAlt';
|
|
|
|
import RemoveSubuserButton from '@/components/server/users/RemoveSubuserButton';
|
2020-03-27 22:40:24 +00:00
|
|
|
import EditSubuserModal from '@/components/server/users/EditSubuserModal';
|
2020-03-27 23:42:27 +00:00
|
|
|
import { faUnlockAlt } from '@fortawesome/free-solid-svg-icons/faUnlockAlt';
|
|
|
|
import { faUserLock } from '@fortawesome/free-solid-svg-icons/faUserLock';
|
|
|
|
import classNames from 'classnames';
|
2020-03-29 21:19:17 +00:00
|
|
|
import Can from '@/components/elements/Can';
|
2020-03-27 22:32:33 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
subuser: Subuser;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ({ subuser }: Props) => {
|
2020-03-27 22:40:24 +00:00
|
|
|
const [ visible, setVisible ] = useState(false);
|
2020-03-27 22:32:33 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={'grey-row-box mb-2'}>
|
2020-03-27 22:40:24 +00:00
|
|
|
{visible &&
|
|
|
|
<EditSubuserModal
|
|
|
|
appear={true}
|
|
|
|
visible={true}
|
|
|
|
subuser={subuser}
|
|
|
|
onDismissed={() => setVisible(false)}
|
|
|
|
/>
|
|
|
|
}
|
2020-03-27 22:32:33 +00:00
|
|
|
<div className={'w-10 h-10 rounded-full bg-white border-2 border-inset border-neutral-800 overflow-hidden'}>
|
|
|
|
<img className={'f-full h-full'} src={`${subuser.image}?s=400`}/>
|
|
|
|
</div>
|
|
|
|
<div className={'ml-4 flex-1'}>
|
|
|
|
<p className={'text-sm'}>{subuser.email}</p>
|
|
|
|
</div>
|
2020-03-27 23:42:27 +00:00
|
|
|
<div className={'ml-4'}>
|
|
|
|
<p className={'font-medium text-center'}>
|
|
|
|
|
|
|
|
<FontAwesomeIcon
|
|
|
|
icon={subuser.twoFactorEnabled ? faUserLock : faUnlockAlt}
|
|
|
|
className={classNames('fa-fw', {
|
|
|
|
'text-red-400': !subuser.twoFactorEnabled,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
|
|
|
|
</p>
|
|
|
|
<p className={'text-2xs text-neutral-500 uppercase'}>2FA Enabled</p>
|
|
|
|
</div>
|
|
|
|
<div className={'ml-4'}>
|
|
|
|
<p className={'font-medium text-center'}>
|
2020-04-17 17:21:15 +00:00
|
|
|
{subuser.permissions.filter(permission => permission !== 'websocket.connect').length}
|
2020-03-27 23:42:27 +00:00
|
|
|
</p>
|
|
|
|
<p className={'text-2xs text-neutral-500 uppercase'}>Permissions</p>
|
|
|
|
</div>
|
2020-03-27 22:32:33 +00:00
|
|
|
<button
|
|
|
|
type={'button'}
|
|
|
|
aria-label={'Edit subuser'}
|
2020-03-27 23:42:27 +00:00
|
|
|
className={'block text-sm p-2 text-neutral-500 hover:text-neutral-100 transition-colors duration-150 mx-4'}
|
2020-03-27 22:40:24 +00:00
|
|
|
onClick={() => setVisible(true)}
|
2020-03-27 22:32:33 +00:00
|
|
|
>
|
|
|
|
<FontAwesomeIcon icon={faPencilAlt}/>
|
|
|
|
</button>
|
2020-03-29 21:19:17 +00:00
|
|
|
<Can action={'user.delete'}>
|
|
|
|
<RemoveSubuserButton subuser={subuser}/>
|
|
|
|
</Can>
|
2020-03-27 22:32:33 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|