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

Navigation position style fixes [storage] #2193

Merged
merged 4 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
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
43 changes: 23 additions & 20 deletions packages/storage-ui/src/Components/Elements/CidRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { makeStyles, createStyles } from "@chainsafe/common-theme"
import { makeStyles, createStyles, useThemeSwitcher } from "@chainsafe/common-theme"
import { DeleteSvg, ExternalIcon, formatBytes, MenuDropdown, MoreIcon, TableCell, TableRow } from "@chainsafe/common-components"
import { Trans } from "@lingui/macro"
import dayjs from "dayjs"
Expand Down Expand Up @@ -71,6 +71,7 @@ const IPFS_GATEWAY = process.env.REACT_APP_IPFS_GATEWAY || "https://ipfs.io/ipfs
const CidRow = ({ pinStatus }: Props) => {
const classes = useStyles()
const { unpin } = useStorage()
const { desktop } = useThemeSwitcher()

return (
<TableRow
Expand All @@ -80,35 +81,37 @@ const CidRow = ({ pinStatus }: Props) => {
>
<TableCell
className={classes.cid}
align='left'
align='center'
data-cy="cell-pin-name"
>
{pinStatus.pin?.name || "-"}
</TableCell>
<TableCell
className={classes.cid}
align='left'
align='center'
data-cy="cell-pin-cid"
>
{pinStatus.pin?.cid}
</TableCell>
<TableCell>
{dayjs(pinStatus.created).format("DD MMM YYYY h:mm a")}
</TableCell>
<TableCell>
{pinStatus.info?.size ? formatBytes(pinStatus.info?.size, 2) : "-"}
</TableCell>
<TableCell>
{pinStatus.status}
</TableCell>
<TableCell className={classes.externalIconCell}>
{pinStatus.status === "pinned" && (
<ExternalIcon
className={classes.icon}
onClick={() => window.open(`${trimChar(IPFS_GATEWAY, "/")}/${pinStatus.pin?.cid}`)}
/>
)}
</TableCell>
{desktop && <>
<TableCell>
{dayjs(pinStatus.created).format("DD MMM YYYY h:mm a")}
</TableCell>
<TableCell>
{pinStatus.info?.size ? formatBytes(pinStatus.info?.size, 2) : "-"}
</TableCell>
<TableCell>
{pinStatus.status}
</TableCell>
<TableCell className={classes.externalIconCell}>
{pinStatus.status === "pinned" && (
<ExternalIcon
className={classes.icon}
onClick={() => window.open(`${trimChar(IPFS_GATEWAY, "/")}/${pinStatus.pin?.cid}`)}
/>
)}
</TableCell>
</>}
<TableCell align="right">
<MenuDropdown
testId='cid-kebab'
Expand Down
78 changes: 46 additions & 32 deletions packages/storage-ui/src/Components/Pages/CidsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
Pagination,
SearchBar
} from "@chainsafe/common-components"
import { makeStyles, createStyles, debounce } from "@chainsafe/common-theme"
import { makeStyles, createStyles, debounce, useThemeSwitcher } from "@chainsafe/common-theme"
import { useStorage } from "../../Contexts/StorageContext"
import { t, Trans } from "@lingui/macro"
import CidRow from "../Elements/CidRow"
Expand All @@ -25,7 +25,7 @@ import { Helmet } from "react-helmet-async"
import { cid as isCid } from "is-ipfs"

export const desktopGridSettings = "2fr 3fr 180px 110px 80px 20px 70px !important"
export const mobileGridSettings = "2fr 3fr 180px 110px 80px 20px 70px !important"
export const mobileGridSettings = "2fr 4fr 50px !important"

const useStyles = makeStyles(({ animation, breakpoints, constants }: CSSTheme) =>
createStyles({
Expand All @@ -39,9 +39,15 @@ const useStyles = makeStyles(({ animation, breakpoints, constants }: CSSTheme) =
justifyContent: "space-between",
alignItems: "center",
[breakpoints.down("md")]: {
marginTop: constants.generalUnit
margin: `${constants.generalUnit}px ${constants.generalUnit * 2}px 0`
}
},
title: {
marginRight: constants.generalUnit * 1.5
},
pinButton: {
minWidth: 110
},
controls: {
display: "flex",
flexDirection: "row",
Expand All @@ -67,7 +73,10 @@ const useStyles = makeStyles(({ animation, breakpoints, constants }: CSSTheme) =
pagination: {
margin: `${constants.generalUnit * 3}px 0`,
display: "flex",
justifyContent: "flex-end"
justifyContent: "flex-end",
[breakpoints.down("md")]: {
marginRight: constants.generalUnit * 2
}
}
})
)
Expand All @@ -77,6 +86,7 @@ type SortDirection = "ascend" | "descend"

const CidsPage = () => {
const classes = useStyles()
const { desktop } = useThemeSwitcher()
const {
pins,
onNextPins,
Expand Down Expand Up @@ -165,6 +175,7 @@ const CidsPage = () => {
<Typography
variant="h1"
component="h1"
className={classes.title}
>
<Trans>CIDs</Trans>
</Typography>
Expand All @@ -183,6 +194,7 @@ const CidsPage = () => {
onClick={() => setAddCIDOpen(true)}
variant="outline"
size="large"
className={classes.pinButton}
disabled={accountRestricted}
>
<PlusIcon />
Expand Down Expand Up @@ -220,34 +232,36 @@ const CidsPage = () => {
>
<Trans>Cid</Trans>
</TableHeadCell>
<TableHeadCell
data-cy="table-header-created"
sortButtons={true}
onSortChange={() => handleSortToggle("date_uploaded")}
sortDirection={sortColumn === "date_uploaded" ? sortDirection : undefined}
sortActive={sortColumn === "date_uploaded"}
align="center"
>
<Trans>Created</Trans>
</TableHeadCell>
<TableHeadCell
data-cy="table-header-size"
sortButtons={true}
onSortChange={() => handleSortToggle("size")}
sortDirection={sortColumn === "size" ? sortDirection : undefined}
sortActive={sortColumn === "size"}
align="center"
>
<Trans>Size</Trans>
</TableHeadCell>
<TableHeadCell
data-cy="table-header-status"
sortButtons={false}
align="center"
>
<Trans>Status</Trans>
</TableHeadCell>
<TableHeadCell>{/* IPFS Gateway */}</TableHeadCell>
{desktop && <>
<TableHeadCell
data-cy="table-header-created"
sortButtons={true}
onSortChange={() => handleSortToggle("date_uploaded")}
sortDirection={sortColumn === "date_uploaded" ? sortDirection : undefined}
sortActive={sortColumn === "date_uploaded"}
align="center"
>
<Trans>Created</Trans>
</TableHeadCell>
<TableHeadCell
data-cy="table-header-size"
sortButtons={true}
onSortChange={() => handleSortToggle("size")}
sortDirection={sortColumn === "size" ? sortDirection : undefined}
sortActive={sortColumn === "size"}
align="center"
>
<Trans>Size</Trans>
</TableHeadCell>
<TableHeadCell
data-cy="table-header-status"
sortButtons={false}
align="center"
>
<Trans>Status</Trans>
</TableHeadCell>
<TableHeadCell>{/* IPFS Gateway */}</TableHeadCell>
</>}
<TableHeadCell>{/* Menu */}</TableHeadCell>
</TableRow>
</TableHead>
Expand Down