-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * v1.14 * v1.15-rc1 * show Cids * buckets in nav bar * cleanup * cid instead of pin * in menus * login on refresh - storage ui (#1109) * with local storage * local or session * v2 api spec * v2.1 Co-authored-by: Thibaut Sardan <github@thib.top> Co-authored-by: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Co-authored-by: Tanmoy Basak Anjan <tanmoy3399@gmail.com>
- Loading branch information
1 parent
074dab6
commit 0267f5b
Showing
12 changed files
with
388 additions
and
266 deletions.
There are no files selected for viewing
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,54 @@ | ||
import React from "react" | ||
import { makeStyles, createStyles } from "@chainsafe/common-theme" | ||
import { formatBytes, TableCell, TableRow } from "@chainsafe/common-components" | ||
import { Trans } from "@lingui/macro" | ||
import dayjs from "dayjs" | ||
import { PinObject } from "@chainsafe/files-api-client" | ||
|
||
const useStyles = makeStyles(() => | ||
createStyles({ | ||
root: { | ||
} | ||
}) | ||
) | ||
interface Props { | ||
pinObject: PinObject | ||
} | ||
|
||
const IPFS_GATEWAY = "https://ipfs.infura.io:5001/api/v0/cat/" | ||
|
||
const PinRow = ({ pinObject }: Props) => { | ||
const classes = useStyles() | ||
|
||
return ( | ||
<TableRow | ||
type="grid" | ||
className={classes.root} | ||
> | ||
<TableCell> | ||
{pinObject.pin?.cid} | ||
</TableCell> | ||
<TableCell> | ||
{dayjs(pinObject.created).format("DD MMM YYYY h:mm a")} | ||
</TableCell> | ||
<TableCell> | ||
{/** as any needs to be removed when the api spec will be up to date */} | ||
{formatBytes((pinObject as any).info.size)} | ||
</TableCell> | ||
<TableCell> | ||
<a | ||
href={`${IPFS_GATEWAY}${pinObject.pin?.cid}`} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
<Trans>Open on Gateway</Trans> | ||
</a> | ||
</TableCell> | ||
<TableCell> | ||
|
||
</TableCell> | ||
</TableRow> | ||
) | ||
} | ||
|
||
export default PinRow |
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,79 @@ | ||
import React, { useCallback } from "react" | ||
import { makeStyles, createStyles } from "@chainsafe/common-theme" | ||
import { Table, TableBody, TableHead, TableHeadCell, TableRow, Typography } from "@chainsafe/common-components" | ||
import { useStorage } from "../../Contexts/StorageContext" | ||
import { Trans } from "@lingui/macro" | ||
import PinRow from "../Elements/PinRow" | ||
|
||
const useStyles = makeStyles(() => | ||
createStyles({ | ||
root: { | ||
position: "relative", | ||
minHeight: "100vh", | ||
overflow: "hidden" | ||
}, | ||
tableHead: { | ||
marginTop: 24 | ||
} | ||
}) | ||
) | ||
|
||
const CidsPage = () => { | ||
const classes = useStyles() | ||
const { pins, addPin } = useStorage() | ||
|
||
const onCreateHardcodedPin = useCallback(() => { | ||
addPin("QmNbbff884cwp1pvH8muod4pNaUqHA2ph77nYXP7dps2Xw") | ||
}, [addPin]) | ||
|
||
return ( | ||
<div className={classes.root}> | ||
<Typography variant='h1'>Cids</Typography> | ||
<button onClick={onCreateHardcodedPin}>create pin with hardcoded cid</button> | ||
<Table | ||
fullWidth={true} | ||
striped={true} | ||
hover={true} | ||
className="" | ||
> | ||
<TableHead className={classes.tableHead}> | ||
<TableRow | ||
type="grid" | ||
className="" | ||
> | ||
<TableHeadCell | ||
sortButtons={false} | ||
align="center" | ||
> | ||
<Trans>Cid</Trans> | ||
</TableHeadCell> | ||
<TableHeadCell | ||
sortButtons={false} | ||
align="center" | ||
> | ||
<Trans>Created</Trans> | ||
</TableHeadCell> | ||
<TableHeadCell | ||
sortButtons={false} | ||
align="center" | ||
> | ||
<Trans>Size</Trans> | ||
</TableHeadCell> | ||
<TableHeadCell>{/* IPFS Gateway */}</TableHeadCell> | ||
<TableHeadCell>{/* Menu */}</TableHeadCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
{pins.map((pinObject, index) => | ||
<PinRow | ||
pinObject={pinObject} | ||
key={index} | ||
/> | ||
)} | ||
</TableBody> | ||
</Table> | ||
</div> | ||
) | ||
} | ||
|
||
export default CidsPage |
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
Oops, something went wrong.