2018-11-10 11:18:45 +00:00
|
|
|
import React, { useCallback } from 'react';
|
2017-06-21 06:40:28 +00:00
|
|
|
import Navicon from 'containers/Navicon';
|
2018-11-04 06:22:46 +00:00
|
|
|
import Button from 'components/ui/Button';
|
2018-10-15 06:56:17 +00:00
|
|
|
import Checkbox from 'components/ui/Checkbox';
|
2017-06-21 06:40:28 +00:00
|
|
|
import FileInput from 'components/ui/FileInput';
|
2017-05-27 05:30:22 +00:00
|
|
|
|
2018-10-15 06:56:17 +00:00
|
|
|
const Settings = ({
|
|
|
|
settings,
|
2018-11-10 11:18:45 +00:00
|
|
|
installable,
|
2018-10-15 06:56:17 +00:00
|
|
|
setSetting,
|
|
|
|
onCertChange,
|
|
|
|
onKeyChange,
|
2018-11-10 11:18:45 +00:00
|
|
|
onInstall,
|
2018-10-15 06:56:17 +00:00
|
|
|
uploadCert
|
|
|
|
}) => {
|
2018-04-25 03:36:27 +00:00
|
|
|
const status = settings.uploadingCert ? 'Uploading...' : 'Upload';
|
|
|
|
const error = settings.certError;
|
2017-05-27 05:30:22 +00:00
|
|
|
|
2018-11-10 11:18:45 +00:00
|
|
|
const handleInstallClick = useCallback(
|
|
|
|
async () => {
|
|
|
|
installable.prompt();
|
|
|
|
await installable.userChoice;
|
|
|
|
onInstall();
|
|
|
|
},
|
|
|
|
[installable]
|
|
|
|
);
|
|
|
|
|
2017-05-27 05:30:22 +00:00
|
|
|
return (
|
2018-10-15 06:56:17 +00:00
|
|
|
<div className="settings-container">
|
|
|
|
<div className="settings">
|
|
|
|
<Navicon />
|
|
|
|
<h1>Settings</h1>
|
2018-11-10 11:18:45 +00:00
|
|
|
{installable && (
|
|
|
|
<Button className="button-install" onClick={handleInstallClick}>
|
|
|
|
<h2>Install</h2>
|
|
|
|
</Button>
|
|
|
|
)}
|
2018-10-15 06:56:17 +00:00
|
|
|
<div className="settings-section">
|
|
|
|
<h2>Visuals</h2>
|
|
|
|
<Checkbox
|
|
|
|
name="coloredNicks"
|
|
|
|
label="Colored nicks"
|
|
|
|
checked={settings.coloredNicks}
|
|
|
|
onChange={e => setSetting('coloredNicks', e.target.checked)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="settings-section">
|
|
|
|
<h2>Client Certificate</h2>
|
|
|
|
<div className="settings-cert">
|
|
|
|
<div className="settings-file">
|
|
|
|
<p>Certificate</p>
|
|
|
|
<FileInput
|
|
|
|
name={settings.certFile || 'Select Certificate'}
|
|
|
|
onChange={onCertChange}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="settings-file">
|
|
|
|
<p>Private Key</p>
|
|
|
|
<FileInput
|
|
|
|
name={settings.keyFile || 'Select Key'}
|
|
|
|
onChange={onKeyChange}
|
|
|
|
/>
|
|
|
|
</div>
|
2018-11-04 06:22:46 +00:00
|
|
|
<Button
|
|
|
|
type="submit"
|
|
|
|
className="settings-button"
|
|
|
|
onClick={uploadCert}
|
|
|
|
>
|
2018-10-15 06:56:17 +00:00
|
|
|
{status}
|
2018-11-04 06:22:46 +00:00
|
|
|
</Button>
|
2018-10-15 06:56:17 +00:00
|
|
|
{error ? <p className="error">{error}</p> : null}
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-05-27 05:30:22 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Settings;
|