-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add website and folder upload and download (#260)
* feat: add website and folder upload and download * feat: download-share-upload navigation * fix: check for files length in hasIndexDocument * fix: change router dependency * refactor: switch to @ethersphere/manfest-js * fix: hide previews on dropzone, fix spinner align, hide 0 size display * feat: add upload and download history * refactor: change drag and drop text * feat: make history ux better * refactor: improve code based on review * build: add missing react-router dependency * ci: remove beeload * revert(ci): remove beeload This reverts commit 4ce6cb0.
- Loading branch information
Showing
26 changed files
with
838 additions
and
268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ReactElement, useEffect, useState } from 'react' | ||
import { getPrettyDateString } from '../utils/date' | ||
import { getHistorySafe, HistoryItem, HISTORY_KEYS } from '../utils/local-storage' | ||
import ExpandableList from './ExpandableList' | ||
import ExpandableListItemLink from './ExpandableListItemLink' | ||
|
||
interface Props { | ||
title: string | ||
localStorageKey: HISTORY_KEYS | ||
} | ||
|
||
export function History({ title, localStorageKey }: Props): ReactElement | null { | ||
const [items, setItems] = useState<HistoryItem[]>([]) | ||
|
||
useEffect(() => { | ||
setItems(getHistorySafe(localStorageKey)) | ||
}, [localStorageKey]) | ||
|
||
if (!items.length) { | ||
return null | ||
} | ||
|
||
return ( | ||
<ExpandableList label={title} defaultOpen> | ||
{items.map((x, i) => ( | ||
<ExpandableListItemLink | ||
label={getPrettyDateString(new Date(x.createdAt))} | ||
value={x.name} | ||
link={'/files/hash/' + x.hash} | ||
key={i} | ||
navigationType="HISTORY_PUSH" | ||
allowClipboard={false} | ||
/> | ||
))} | ||
</ExpandableList> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Box, createStyles, Grid, makeStyles, Typography } from '@material-ui/core' | ||
import { ArrowBack } from '@material-ui/icons' | ||
import { ReactElement } from 'react' | ||
import { useHistory } from 'react-router-dom' | ||
|
||
interface Props { | ||
children: string | ||
} | ||
|
||
const useStyles = makeStyles(() => | ||
createStyles({ | ||
pressable: { | ||
cursor: 'pointer', | ||
}, | ||
icon: { | ||
color: '#242424', | ||
}, | ||
}), | ||
) | ||
|
||
export function HistoryHeader({ children }: Props): ReactElement { | ||
const classes = useStyles() | ||
const history = useHistory() | ||
|
||
function goBack() { | ||
history.goBack() | ||
} | ||
|
||
return ( | ||
<Box mb={4}> | ||
<Grid container direction="row"> | ||
<Box mr={2}> | ||
<div className={classes.pressable} onClick={goBack}> | ||
<ArrowBack className={classes.icon} /> | ||
</div> | ||
</Box> | ||
<Typography variant="h1">{children}</Typography> | ||
</Grid> | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { CircularProgress, Grid } from '@material-ui/core' | ||
import { ReactElement } from 'react' | ||
|
||
export function Loading(): ReactElement { | ||
return ( | ||
<Grid container direction="row" justifyContent="center" alignItems="center"> | ||
<CircularProgress /> | ||
</Grid> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Box, Typography } from '@material-ui/core' | ||
import { ReactElement } from 'react' | ||
import ExpandableListItemKey from '../../components/ExpandableListItemKey' | ||
import ExpandableListItemLink from '../../components/ExpandableListItemLink' | ||
|
||
interface Props { | ||
hash: string | ||
} | ||
|
||
export function AssetSummary({ hash }: Props): ReactElement { | ||
return ( | ||
<> | ||
<Box mb={4}> | ||
<ExpandableListItemKey label="Swarm hash" value={hash} /> | ||
<ExpandableListItemLink label="Share on Swarm Gateway" value={`https://gateway.ethswarm.org/access/${hash}`} /> | ||
</Box> | ||
<Typography> | ||
The Swarm Gateway is graciously provided by the Swarm Foundation. This service is under development and provided | ||
for testing purposes only. Learn more at{' '} | ||
<a href="https://gateway.ethswarm.org/">https://gateway.ethswarm.org/</a>. | ||
</Typography> | ||
</> | ||
) | ||
} |
Oops, something went wrong.