Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add password field in file upload ui #169

Merged
merged 1 commit into from Sep 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/pages/Upload.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Collapse, Group, Progress, Select, Title } from '@mantine/core';
import { Button, Collapse, Group, Progress, Select, Title, PasswordInput } from '@mantine/core';
import { randomId, useClipboard } from '@mantine/hooks';
import { showNotification, updateNotification } from '@mantine/notifications';
import Dropzone from 'components/dropzone/Dropzone';
Expand Down Expand Up @@ -48,6 +48,7 @@ export default function Upload() {
const [progress, setProgress] = useState(0);
const [loading, setLoading] = useState(false);
const [expires, setExpires] = useState('never');
const [password, setPassword] = useState('');

useEffect(() => {
window.addEventListener('paste', (e: ClipboardEvent) => {
Expand Down Expand Up @@ -143,6 +144,7 @@ export default function Upload() {
req.open('POST', '/api/upload');
req.setRequestHeader('Authorization', user.token);
expires !== 'never' && req.setRequestHeader('Expires-At', 'date=' + expires_at.toISOString());
password !== '' && req.setRequestHeader('Password', password);

req.send(body);
};
Expand All @@ -162,6 +164,12 @@ export default function Upload() {
</Collapse>

<Group position='right' mt='md'>
<PasswordInput
style={{width: '252px'}}
placeholder='Password'
value={password}
onChange={(e) => setPassword(e.currentTarget.value)}
/>
<Select
value={expires}
onChange={(e) => setExpires(e)}
Expand Down