Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | import React, { useState, FC } from 'react'
import { useTranslation } from 'react-i18next'
import { Alert, Button, Label, Input } from 'reactstrap'
import Tips from './Tips'
import FormRow from '../FormRow'
interface Props {
settingForm: object
update: (settings: object) => void
alert: {
status: string
show: boolean
message: string
}
}
const AWSSettings: FC<Props> = ({ settingForm, update, alert }) => {
const [t] = useTranslation()
const [region, setRegion] = useState(settingForm['aws:region'])
const [bucket, setBucket] = useState(settingForm['aws:bucket'])
const [awsAccessKeyId, setAwsAccessKeyId] = useState(settingForm['aws:awsAccessKeyId'])
const [awsSecretAccessKey, setAwsSecretAccessKey] = useState(settingForm['aws:awsSecretAccessKey'])
const handleSubmit = e => {
e.preventDefault()
update({
'aws:region': region,
'aws:bucket': bucket,
'aws:awsAccessKeyId': awsAccessKeyId,
'aws:awsSecretAccessKey': awsSecretAccessKey,
})
}
return (
<form className="form-horizontal" role="form" onSubmit={handleSubmit}>
<fieldset>
<legend>{t('admin.aws.legend')}</legend>
<Alert color={alert.status} isOpen={!!alert.show}>
{alert.message}
</Alert>
<Tips>
{t('admin.aws.tips1')}
<br />
{t('admin.aws.tips2')}
<br />
<span className="mt-2 text-danger">
<i className="mdi mdi-alert" /> {t('admin.aws.notice')}
</span>
</Tips>
<FormRow>
<Label for="awsRegion">{t('admin.aws.region')}</Label>
<Input id="awsRegion" placeholder="例: ap-northeast-1" value={region} onChange={e => setRegion(e.target.value)} />
</FormRow>
<FormRow>
<Label for="awsBucket">{t('admin.aws.bucket')}</Label>
<Input id="awsBucket" placeholder="例: crowi" value={bucket} onChange={e => setBucket(e.target.value)} />
</FormRow>
<FormRow>
<Label for="awsAccessKeyId">{t('admin.aws.access_key_id')}</Label>
<Input id="awsAccessKeyId" value={awsAccessKeyId} onChange={e => setAwsAccessKeyId(awsAccessKeyId)} />
</FormRow>
<FormRow>
<Label for="awsSecretAccessKey">{t('admin.aws.secret_access_key')}</Label>
<Input id="awsSecretAccessKey" value={awsSecretAccessKey} onChange={e => setAwsSecretAccessKey(awsSecretAccessKey)} />
</FormRow>
<FormRow>
<Button color="primary">{t('Update')}</Button>
</FormRow>
</fieldset>
</form>
)
}
export default AWSSettings
|