Skip to content

Commit efa8015

Browse files
committed
#259 fix upload, improve error look
1 parent f271a14 commit efa8015

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This changelog covers all three packages, as they are (for now) updated as a who
1111
- Add cookie based authentication #241
1212
- Get rid of `useWindowSize` #256
1313
- `canWrite` check should succeed for `publicAgent` #252
14+
- Improve error look & text
1415

1516
## v0.32.1
1617

data-browser/src/components/ErrorLook.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { lighten } from 'polished';
22
import styled from 'styled-components';
33
import React from 'react';
4-
import { Details } from './Details';
54
import { FaExclamationTriangle } from 'react-icons/fa';
65

76
export const ErrorLook = styled.span`
@@ -21,30 +20,24 @@ export function ErrorBlock({ error, showTrace }: ErrorBlockProps): JSX.Element {
2120
<FaExclamationTriangle />
2221
Something went wrong
2322
</BiggerText>
24-
<Details title={<span>Show Details</span>}>
25-
<pre>
26-
<CodeBlock>{error.message}</CodeBlock>
27-
</pre>
28-
{showTrace && (
29-
<>
30-
<span>Stack trace:</span>
31-
<pre>
32-
<CodeBlock>{error.stack}</CodeBlock>
33-
</pre>
34-
</>
35-
)}
36-
</Details>
23+
<CodeBlock>{error.message}</CodeBlock>
24+
{showTrace && (
25+
<>
26+
<span>Stack trace:</span>
27+
<CodeBlock>{error.stack}</CodeBlock>
28+
</>
29+
)}
3730
</ErrorLookBig>
3831
);
3932
}
4033

4134
const ErrorLookBig = styled.div`
42-
background-color: ${p => lighten(0.4, p.theme.colors.alert)};
4335
color: ${p => p.theme.colors.alert};
4436
font-size: 1rem;
4537
padding: ${p => p.theme.margin}rem;
4638
border-radius: ${p => p.theme.radius};
4739
border: 1px solid ${p => lighten(0.2, p.theme.colors.alert)};
40+
background-color: ${p => p.theme.colors.bg1};
4841
`;
4942

5043
const CodeBlock = styled.code`

data-browser/src/components/forms/FileDropzone/useUpload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
AtomicError,
23
properties,
34
Resource,
45
uploadFiles,
@@ -44,7 +45,7 @@ export function useUpload(parentResource: Resource): UseUploadResult {
4445

4546
return allUploaded;
4647
} catch (e) {
47-
setError(e);
48+
setError(new AtomicError(e?.message));
4849
setIsUploading(false);
4950

5051
return [];

lib/src/client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,14 @@ export async function uploadFiles(
201201
throw new AtomicError(`No agent present. Can't sign the upload request.`);
202202
}
203203

204+
// TODO: Use cookie authentication here if possible
205+
// https://github.com/atomicdata-dev/atomic-data-browser/issues/253
206+
const signedHeaders = await signRequest(uploadURL.toString(), agent, {});
207+
204208
const options = {
205209
method: 'POST',
206210
body: formData,
211+
headers: signedHeaders,
207212
};
208213

209214
const resp = await fetch(uploadURL.toString(), options);

0 commit comments

Comments
 (0)