mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-29 06:15:29 -04:00
Add prettier for codestyle and re-format everything (#1294)
This commit is contained in:
parent
8b78154075
commit
0aae1f70d2
319 changed files with 4809 additions and 3936 deletions
|
@ -27,26 +27,29 @@ export const ProfileAccessTokens: React.FC = () => {
|
|||
const [newTokenSecret, setNewTokenSecret] = useState('')
|
||||
const [selectedForDeletion, setSelectedForDeletion] = useState(0)
|
||||
|
||||
const addToken = useCallback((event: FormEvent) => {
|
||||
event.preventDefault()
|
||||
postNewAccessToken(newTokenLabel)
|
||||
.then(token => {
|
||||
setNewTokenSecret(token.secret)
|
||||
setShowAddedModal(true)
|
||||
setNewTokenLabel('')
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
setError(true)
|
||||
})
|
||||
}, [newTokenLabel])
|
||||
const addToken = useCallback(
|
||||
(event: FormEvent) => {
|
||||
event.preventDefault()
|
||||
postNewAccessToken(newTokenLabel)
|
||||
.then((token) => {
|
||||
setNewTokenSecret(token.secret)
|
||||
setShowAddedModal(true)
|
||||
setNewTokenLabel('')
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
setError(true)
|
||||
})
|
||||
},
|
||||
[newTokenLabel]
|
||||
)
|
||||
|
||||
const deleteToken = useCallback(() => {
|
||||
deleteAccessToken(selectedForDeletion)
|
||||
.then(() => {
|
||||
setSelectedForDeletion(0)
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.error(error)
|
||||
setError(true)
|
||||
})
|
||||
|
@ -66,11 +69,11 @@ export const ProfileAccessTokens: React.FC = () => {
|
|||
|
||||
useEffect(() => {
|
||||
getAccessTokenList()
|
||||
.then(tokens => {
|
||||
.then((tokens) => {
|
||||
setError(false)
|
||||
setAccessTokens(tokens)
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.error(err)
|
||||
setError(true)
|
||||
})
|
||||
|
@ -81,65 +84,63 @@ export const ProfileAccessTokens: React.FC = () => {
|
|||
<Card className='bg-dark mb-4 access-tokens'>
|
||||
<Card.Body>
|
||||
<Card.Title>
|
||||
<Trans i18nKey='profile.accessTokens.title'/>
|
||||
<Trans i18nKey='profile.accessTokens.title' />
|
||||
</Card.Title>
|
||||
<p className='text-start'><Trans i18nKey='profile.accessTokens.info'/></p>
|
||||
<p className='text-start small'><Trans i18nKey='profile.accessTokens.infoDev'/></p>
|
||||
<hr/>
|
||||
<ShowIf condition={ accessTokens.length === 0 && !error }>
|
||||
<Trans i18nKey='profile.accessTokens.noTokens'/>
|
||||
<p className='text-start'>
|
||||
<Trans i18nKey='profile.accessTokens.info' />
|
||||
</p>
|
||||
<p className='text-start small'>
|
||||
<Trans i18nKey='profile.accessTokens.infoDev' />
|
||||
</p>
|
||||
<hr />
|
||||
<ShowIf condition={accessTokens.length === 0 && !error}>
|
||||
<Trans i18nKey='profile.accessTokens.noTokens' />
|
||||
</ShowIf>
|
||||
<ShowIf condition={ error }>
|
||||
<Trans i18nKey='common.errorOccurred'/>
|
||||
<ShowIf condition={error}>
|
||||
<Trans i18nKey='common.errorOccurred' />
|
||||
</ShowIf>
|
||||
<ListGroup>
|
||||
{
|
||||
accessTokens.map((token) => {
|
||||
return (
|
||||
<ListGroup.Item className='bg-dark' key={ token.created }>
|
||||
<Row>
|
||||
<Col className='text-start'>
|
||||
{ token.label }
|
||||
</Col>
|
||||
<Col className='text-start text-white-50'>
|
||||
<Trans i18nKey='profile.accessTokens.created' values={ {
|
||||
time: DateTime.fromSeconds(token.created)
|
||||
.toRelative({
|
||||
style: 'short'
|
||||
})
|
||||
} }/>
|
||||
</Col>
|
||||
<Col xs='auto'>
|
||||
<IconButton icon='trash-o' variant='danger' onClick={ () => selectForDeletion(token.created) }/>
|
||||
</Col>
|
||||
</Row>
|
||||
</ListGroup.Item>
|
||||
)
|
||||
})
|
||||
}
|
||||
{accessTokens.map((token) => {
|
||||
return (
|
||||
<ListGroup.Item className='bg-dark' key={token.created}>
|
||||
<Row>
|
||||
<Col className='text-start'>{token.label}</Col>
|
||||
<Col className='text-start text-white-50'>
|
||||
<Trans
|
||||
i18nKey='profile.accessTokens.created'
|
||||
values={{
|
||||
time: DateTime.fromSeconds(token.created).toRelative({
|
||||
style: 'short'
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</Col>
|
||||
<Col xs='auto'>
|
||||
<IconButton icon='trash-o' variant='danger' onClick={() => selectForDeletion(token.created)} />
|
||||
</Col>
|
||||
</Row>
|
||||
</ListGroup.Item>
|
||||
)
|
||||
})}
|
||||
</ListGroup>
|
||||
<hr/>
|
||||
<Form onSubmit={ addToken } className='text-left'>
|
||||
<hr />
|
||||
<Form onSubmit={addToken} className='text-left'>
|
||||
<Form.Row>
|
||||
<Col>
|
||||
<Form.Control
|
||||
type='text'
|
||||
size='sm'
|
||||
placeholder={ t('profile.accessTokens.label') }
|
||||
value={ newTokenLabel }
|
||||
placeholder={t('profile.accessTokens.label')}
|
||||
value={newTokenLabel}
|
||||
className='bg-dark text-light'
|
||||
onChange={ (event: ChangeEvent<HTMLInputElement>) => setNewTokenLabel(event.target.value) }
|
||||
isValid={ newTokenSubmittable }
|
||||
onChange={(event: ChangeEvent<HTMLInputElement>) => setNewTokenLabel(event.target.value)}
|
||||
isValid={newTokenSubmittable}
|
||||
required
|
||||
/>
|
||||
</Col>
|
||||
<Col xs={ 'auto' }>
|
||||
<Button
|
||||
type='submit'
|
||||
variant='primary'
|
||||
size='sm'
|
||||
disabled={ !newTokenSubmittable }>
|
||||
<Trans i18nKey='profile.accessTokens.createToken'/>
|
||||
<Col xs={'auto'}>
|
||||
<Button type='submit' variant='primary' size='sm' disabled={!newTokenSubmittable}>
|
||||
<Trans i18nKey='profile.accessTokens.createToken' />
|
||||
</Button>
|
||||
</Col>
|
||||
</Form.Row>
|
||||
|
@ -147,27 +148,29 @@ export const ProfileAccessTokens: React.FC = () => {
|
|||
</Card.Body>
|
||||
</Card>
|
||||
|
||||
<CommonModal show={ showAddedModal } onHide={ () => setShowAddedModal(false) }
|
||||
titleI18nKey='profile.modal.addedAccessToken.title'>
|
||||
<CommonModal
|
||||
show={showAddedModal}
|
||||
onHide={() => setShowAddedModal(false)}
|
||||
titleI18nKey='profile.modal.addedAccessToken.title'>
|
||||
<Modal.Body>
|
||||
<Trans i18nKey='profile.modal.addedAccessToken.message'/>
|
||||
<br/>
|
||||
<CopyableField content={ newTokenSecret }/>
|
||||
<Trans i18nKey='profile.modal.addedAccessToken.message' />
|
||||
<br />
|
||||
<CopyableField content={newTokenSecret} />
|
||||
</Modal.Body>
|
||||
<Modal.Footer>
|
||||
<Button variant='primary' onClick={ () => setShowAddedModal(false) }>
|
||||
<Trans i18nKey='common.close'/>
|
||||
<Button variant='primary' onClick={() => setShowAddedModal(false)}>
|
||||
<Trans i18nKey='common.close' />
|
||||
</Button>
|
||||
</Modal.Footer>
|
||||
</CommonModal>
|
||||
|
||||
<DeletionModal
|
||||
onConfirm={ deleteToken }
|
||||
deletionButtonI18nKey={ 'common.delete' }
|
||||
show={ showDeleteModal }
|
||||
onHide={ () => setShowDeleteModal(false) }
|
||||
titleI18nKey={ 'profile.modal.deleteAccessToken.title' }>
|
||||
<Trans i18nKey='profile.modal.deleteAccessToken.message'/>
|
||||
onConfirm={deleteToken}
|
||||
deletionButtonI18nKey={'common.delete'}
|
||||
show={showDeleteModal}
|
||||
onHide={() => setShowDeleteModal(false)}
|
||||
titleI18nKey={'profile.modal.deleteAccessToken.title'}>
|
||||
<Trans i18nKey='profile.modal.deleteAccessToken.message' />
|
||||
</DeletionModal>
|
||||
</Fragment>
|
||||
)
|
||||
|
|
|
@ -20,23 +20,23 @@ export const ProfilePage: React.FC = () => {
|
|||
const userProvider = useSelector((state: ApplicationState) => state.user?.provider)
|
||||
|
||||
if (!userProvider) {
|
||||
return (
|
||||
<Redirect to={ '/login' }/>
|
||||
)
|
||||
return <Redirect to={'/login'} />
|
||||
}
|
||||
|
||||
return <Fragment>
|
||||
<div className="my-3">
|
||||
<Row className="h-100 flex justify-content-center">
|
||||
<Col lg={ 6 }>
|
||||
<ProfileDisplayName/>
|
||||
<ShowIf condition={ userProvider === LoginProvider.INTERNAL }>
|
||||
<ProfileChangePassword/>
|
||||
</ShowIf>
|
||||
<ProfileAccessTokens/>
|
||||
<ProfileAccountManagement/>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
</Fragment>
|
||||
return (
|
||||
<Fragment>
|
||||
<div className='my-3'>
|
||||
<Row className='h-100 flex justify-content-center'>
|
||||
<Col lg={6}>
|
||||
<ProfileDisplayName />
|
||||
<ShowIf condition={userProvider === LoginProvider.INTERNAL}>
|
||||
<ProfileChangePassword />
|
||||
</ShowIf>
|
||||
<ProfileAccessTokens />
|
||||
<ProfileAccountManagement />
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -60,31 +60,35 @@ export const ProfileAccountManagement: React.FC = () => {
|
|||
|
||||
return (
|
||||
<Fragment>
|
||||
<Card className="bg-dark mb-4">
|
||||
<Card className='bg-dark mb-4'>
|
||||
<Card.Body>
|
||||
<Card.Title><Trans i18nKey="profile.accountManagement"/></Card.Title>
|
||||
<Button variant="secondary" block href={ getApiUrl() + 'me/export' } className="mb-2">
|
||||
<ForkAwesomeIcon icon="cloud-download" fixedWidth={ true } className="mx-2"/>
|
||||
<Trans i18nKey="profile.exportUserData"/>
|
||||
<Card.Title>
|
||||
<Trans i18nKey='profile.accountManagement' />
|
||||
</Card.Title>
|
||||
<Button variant='secondary' block href={getApiUrl() + 'me/export'} className='mb-2'>
|
||||
<ForkAwesomeIcon icon='cloud-download' fixedWidth={true} className='mx-2' />
|
||||
<Trans i18nKey='profile.exportUserData' />
|
||||
</Button>
|
||||
<Button variant="danger" block onClick={ handleModalOpen }>
|
||||
<ForkAwesomeIcon icon="trash" fixedWidth={ true } className="mx-2"/>
|
||||
<Trans i18nKey="profile.deleteUser"/>
|
||||
<Button variant='danger' block onClick={handleModalOpen}>
|
||||
<ForkAwesomeIcon icon='trash' fixedWidth={true} className='mx-2' />
|
||||
<Trans i18nKey='profile.deleteUser' />
|
||||
</Button>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
|
||||
<Modal show={ showDeleteModal } onHide={ handleModalClose } animation={ true }>
|
||||
<Modal.Body className="text-dark">
|
||||
<h3 dir="auto"><Trans i18nKey="profile.modal.deleteUser.message"/></h3>
|
||||
<Trans i18nKey="profile.modal.deleteUser.subMessage"/>
|
||||
<Modal show={showDeleteModal} onHide={handleModalClose} animation={true}>
|
||||
<Modal.Body className='text-dark'>
|
||||
<h3 dir='auto'>
|
||||
<Trans i18nKey='profile.modal.deleteUser.message' />
|
||||
</h3>
|
||||
<Trans i18nKey='profile.modal.deleteUser.subMessage' />
|
||||
</Modal.Body>
|
||||
<Modal.Footer>
|
||||
<Button variant="secondary" onClick={ handleModalClose }>
|
||||
<Trans i18nKey="common.close"/>
|
||||
<Button variant='secondary' onClick={handleModalClose}>
|
||||
<Trans i18nKey='common.close' />
|
||||
</Button>
|
||||
<Button variant="danger" onClick={ deleteUserAccount } disabled={ !deletionButtonActive }>
|
||||
{ deletionButtonActive ? <Trans i18nKey={ 'profile.modal.deleteUser.title' }/> : countdown }
|
||||
<Button variant='danger' onClick={deleteUserAccount} disabled={!deletionButtonActive}>
|
||||
{deletionButtonActive ? <Trans i18nKey={'profile.modal.deleteUser.title'} /> : countdown}
|
||||
</Button>
|
||||
</Modal.Footer>
|
||||
</Modal>
|
||||
|
|
|
@ -36,50 +36,57 @@ export const ProfileChangePassword: React.FC = () => {
|
|||
}
|
||||
|
||||
return (
|
||||
<Card className="bg-dark mb-4">
|
||||
<Card className='bg-dark mb-4'>
|
||||
<Card.Body>
|
||||
<Card.Title><Trans i18nKey="profile.changePassword.title"/></Card.Title>
|
||||
<Form onSubmit={ updatePasswordSubmit } className="text-left">
|
||||
<Form.Group controlId="oldPassword">
|
||||
<Form.Label><Trans i18nKey="profile.changePassword.old"/></Form.Label>
|
||||
<Card.Title>
|
||||
<Trans i18nKey='profile.changePassword.title' />
|
||||
</Card.Title>
|
||||
<Form onSubmit={updatePasswordSubmit} className='text-left'>
|
||||
<Form.Group controlId='oldPassword'>
|
||||
<Form.Label>
|
||||
<Trans i18nKey='profile.changePassword.old' />
|
||||
</Form.Label>
|
||||
<Form.Control
|
||||
type="password"
|
||||
size="sm"
|
||||
className="bg-dark text-light"
|
||||
type='password'
|
||||
size='sm'
|
||||
className='bg-dark text-light'
|
||||
required
|
||||
onChange={ (event) => setOldPassword(event.target.value) }
|
||||
onChange={(event) => setOldPassword(event.target.value)}
|
||||
/>
|
||||
</Form.Group>
|
||||
<Form.Group controlId="newPassword">
|
||||
<Form.Label><Trans i18nKey="profile.changePassword.new"/></Form.Label>
|
||||
<Form.Group controlId='newPassword'>
|
||||
<Form.Label>
|
||||
<Trans i18nKey='profile.changePassword.new' />
|
||||
</Form.Label>
|
||||
<Form.Control
|
||||
type="password"
|
||||
size="sm"
|
||||
className="bg-dark text-light"
|
||||
type='password'
|
||||
size='sm'
|
||||
className='bg-dark text-light'
|
||||
required
|
||||
onChange={ onChangeNewPassword }
|
||||
isValid={ newPasswordValid }
|
||||
onChange={onChangeNewPassword}
|
||||
isValid={newPasswordValid}
|
||||
/>
|
||||
<Form.Text><Trans i18nKey="profile.changePassword.info"/></Form.Text>
|
||||
<Form.Text>
|
||||
<Trans i18nKey='profile.changePassword.info' />
|
||||
</Form.Text>
|
||||
</Form.Group>
|
||||
<Form.Group controlId="newPasswordAgain">
|
||||
<Form.Label><Trans i18nKey="profile.changePassword.newAgain"/></Form.Label>
|
||||
<Form.Group controlId='newPasswordAgain'>
|
||||
<Form.Label>
|
||||
<Trans i18nKey='profile.changePassword.newAgain' />
|
||||
</Form.Label>
|
||||
<Form.Control
|
||||
type="password"
|
||||
size="sm"
|
||||
className="bg-dark text-light"
|
||||
type='password'
|
||||
size='sm'
|
||||
className='bg-dark text-light'
|
||||
required
|
||||
onChange={ onChangeNewPasswordAgain }
|
||||
isValid={ newPasswordAgainValid }
|
||||
isInvalid={ newPasswordAgain !== '' && !newPasswordAgainValid }
|
||||
onChange={onChangeNewPasswordAgain}
|
||||
isValid={newPasswordAgainValid}
|
||||
isInvalid={newPasswordAgain !== '' && !newPasswordAgainValid}
|
||||
/>
|
||||
</Form.Group>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={ !newPasswordValid || !newPasswordAgainValid }>
|
||||
<Trans i18nKey="common.save"/>
|
||||
<Button type='submit' variant='primary' disabled={!newPasswordValid || !newPasswordAgainValid}>
|
||||
<Trans i18nKey='common.save' />
|
||||
</Button>
|
||||
</Form>
|
||||
</Card.Body>
|
||||
|
|
|
@ -27,7 +27,7 @@ export const ProfileDisplayName: React.FC = () => {
|
|||
}, [userName])
|
||||
|
||||
if (!userName) {
|
||||
return <Alert variant={ 'danger' }>User not logged in</Alert>
|
||||
return <Alert variant={'danger'}>User not logged in</Alert>
|
||||
}
|
||||
|
||||
const changeNameField = (event: ChangeEvent<HTMLInputElement>) => {
|
||||
|
@ -41,39 +41,39 @@ export const ProfileDisplayName: React.FC = () => {
|
|||
}
|
||||
|
||||
const changeNameSubmit = (event: FormEvent) => {
|
||||
doAsyncChange()
|
||||
.catch(() => setError(true))
|
||||
doAsyncChange().catch(() => setError(true))
|
||||
event.preventDefault()
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="bg-dark mb-4">
|
||||
<Card className='bg-dark mb-4'>
|
||||
<Card.Body>
|
||||
<Card.Title>
|
||||
<Trans i18nKey="profile.userProfile"/>
|
||||
<Trans i18nKey='profile.userProfile' />
|
||||
</Card.Title>
|
||||
<Form onSubmit={ changeNameSubmit } className="text-left">
|
||||
<Form.Group controlId="displayName">
|
||||
<Form.Label><Trans i18nKey="profile.displayName"/></Form.Label>
|
||||
<Form onSubmit={changeNameSubmit} className='text-left'>
|
||||
<Form.Group controlId='displayName'>
|
||||
<Form.Label>
|
||||
<Trans i18nKey='profile.displayName' />
|
||||
</Form.Label>
|
||||
<Form.Control
|
||||
type="text"
|
||||
size="sm"
|
||||
placeholder={ t('profile.displayName') }
|
||||
value={ displayName }
|
||||
className="bg-dark text-light"
|
||||
onChange={ changeNameField }
|
||||
isValid={ submittable }
|
||||
isInvalid={ error }
|
||||
type='text'
|
||||
size='sm'
|
||||
placeholder={t('profile.displayName')}
|
||||
value={displayName}
|
||||
className='bg-dark text-light'
|
||||
onChange={changeNameField}
|
||||
isValid={submittable}
|
||||
isInvalid={error}
|
||||
required
|
||||
/>
|
||||
<Form.Text><Trans i18nKey="profile.displayNameInfo"/></Form.Text>
|
||||
<Form.Text>
|
||||
<Trans i18nKey='profile.displayNameInfo' />
|
||||
</Form.Text>
|
||||
</Form.Group>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
variant="primary"
|
||||
disabled={ !submittable }>
|
||||
<Trans i18nKey="common.save"/>
|
||||
<Button type='submit' variant='primary' disabled={!submittable}>
|
||||
<Trans i18nKey='common.save' />
|
||||
</Button>
|
||||
</Form>
|
||||
</Card.Body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue