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

Storage buckets overview #1140

Merged
merged 69 commits into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
0bed9ca
fix broken things
FSM1 May 18, 2021
0a327c1
rewire for new apis
FSM1 May 19, 2021
cce9198
lingui extract
actions-user May 19, 2021
6bbb233
clean up linting errors
FSM1 May 20, 2021
6bda362
Align paths and test
FSM1 May 20, 2021
d8e2997
Merge remote-tracking branch 'origin/dev' into mnt/update-api-client-…
FSM1 May 20, 2021
5b2d466
post merge fixes
FSM1 May 20, 2021
331deef
Apply suggestions from code review
FSM1 May 20, 2021
d96583b
Update packages/files-ui/src/Utils/pathUtils.ts
FSM1 May 20, 2021
c66e332
Merge remote-tracking branch 'origin/dev' into mnt/update-api-client-…
FSM1 May 21, 2021
7cb0cb0
update context and hook names
FSM1 May 21, 2021
fbb22c1
fix search
FSM1 May 21, 2021
09bfff7
fix bin folder navigation
FSM1 May 21, 2021
6d6eebc
fix grid item navigation
FSM1 May 21, 2021
702e554
init
Tbaut May 21, 2021
2e0e6ad
add permission to buckets
Tbaut May 28, 2021
d687229
Nav and filtering
Tbaut May 31, 2021
d1f28d6
merge dev and fix conflicts
Tbaut Jun 1, 2021
678613f
lingui extract
actions-user Jun 1, 2021
a62c580
with some todos
Tbaut Jun 1, 2021
c0dbea3
Merge branch 'feat/tbaut-shared-overview-1041' of github.com:ChainSaf…
Tbaut Jun 1, 2021
e855e8e
merge dev
Tbaut Jun 10, 2021
d5417d5
lint
Tbaut Jun 10, 2021
4c3378c
Merge branch 'dev' into feat/tbaut-shared-overview-1041
Tbaut Jun 11, 2021
c976022
basics
Tbaut Jun 11, 2021
c38c7c7
lingui extract
actions-user Jun 11, 2021
edd8d71
User circles
Tbaut Jun 14, 2021
c55af18
Merge branch 'feat/tbaut-shared-overview-1041' of github.com:ChainSaf…
Tbaut Jun 14, 2021
9ebd6b7
Merge branch 'dev' into feat/tbaut-shared-overview-1041
Tbaut Jun 15, 2021
6095398
add storage bucket list and bucket details
FSM1 Jun 15, 2021
adae31a
clean up file browser modals
FSM1 Jun 15, 2021
8b2973f
Merge branch 'dev' into feat/storage-buckets-overview-1104
FSM1 Jun 15, 2021
3eb13fb
fix linting
FSM1 Jun 15, 2021
df484b2
fix CRLF
FSM1 Jun 15, 2021
a9a108b
Merge branch 'dev' into feat/storage-buckets-overview-1104
FSM1 Jun 15, 2021
0105a5b
wire up file upload
FSM1 Jun 15, 2021
be5e3cf
clean up styling
FSM1 Jun 16, 2021
a77c9ee
refresh buckets on delete
FSM1 Jun 16, 2021
b574274
remove some styling
FSM1 Jun 16, 2021
e1841f3
remove bulk ops
FSM1 Jun 16, 2021
89c3972
Merge branch 'dev' of github.com:ChainSafe/files-ui into feat/tbaut-s…
Tbaut Jun 16, 2021
13c5ccf
user icons with tooltip
Tbaut Jun 16, 2021
d9e7e6d
Merge branch 'feat/tbaut-shared-overview-1041' of github.com:ChainSaf…
Tbaut Jun 16, 2021
bdf5fdc
Merge branch 'dev' into feat/storage-buckets-overview-1104
FSM1 Jun 16, 2021
6c8a65a
Merge branch 'feat/tbaut-shared-overview-1041' of github.com:ChainSaf…
Tbaut Jun 17, 2021
3b0c058
loader
Tbaut Jun 17, 2021
e16b80b
lingui extract
actions-user Jun 17, 2021
cd41eb4
Merge branch 'dev' into feat/storage-buckets-overview-1104
tanmoyAtb Jun 17, 2021
9666ba4
nav color
Tbaut Jun 17, 2021
bbdb632
Merge branch 'feat/storage-buckets-overview-1104' of github.com:Chain…
Tbaut Jun 17, 2021
4aa4b0e
Revert "nav color"
Tbaut Jun 17, 2021
9bf40f0
Revert "loader"
Tbaut Jun 17, 2021
9816d38
lingui extract
actions-user Jun 17, 2021
49fa8e7
Merge branch 'dev' into feat/storage-buckets-overview-1104
FSM1 Jun 17, 2021
48c231c
Merge branch 'dev' into feat/storage-buckets-overview-1104
tanmoyAtb Jun 18, 2021
5f9bd2d
Revert "Merge branch 'feat/tbaut-shared-overview-1041' of github.com:…
Tbaut Jun 18, 2021
f98a3a5
Apply suggestions from code review
FSM1 Jun 18, 2021
82ba2c5
implement feedback
FSM1 Jun 18, 2021
0c0e743
more cleaning up
FSM1 Jun 18, 2021
62ff04a
clean up unused imports
FSM1 Jun 18, 2021
f60926c
show the failed pins
Tbaut Jun 18, 2021
3ff88e2
add pinning bucket to size calc
FSM1 Jun 18, 2021
6b3d1cb
Merge branch 'feat/storage-buckets-overview-1104' of github.com:Chain…
Tbaut Jun 18, 2021
277f6dc
Hide facebook login
FSM1 Jun 18, 2021
7ad2cb9
Merge branch 'feat/storage-buckets-overview-1104' of https://github.c…
FSM1 Jun 18, 2021
131b9ec
remove title
FSM1 Jun 18, 2021
3cf4c44
fix broken import and remove unused icon
FSM1 Jun 18, 2021
a5a82f0
fix app name
FSM1 Jun 18, 2021
aae17d1
rename to Storage
FSM1 Jun 18, 2021
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
107 changes: 107 additions & 0 deletions packages/storage-ui/src/Components/Elements/BucketRow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import React from "react"
FSM1 marked this conversation as resolved.
Show resolved Hide resolved
import { makeStyles, createStyles } from "@chainsafe/common-theme"
import { DeleteSvg, formatBytes, MenuDropdown, MoreIcon, TableCell, TableRow, useHistory } from "@chainsafe/common-components"
import { Trans } from "@lingui/macro"
import { Bucket } from "@chainsafe/files-api-client"
import { CSSTheme } from "../../Themes/types"
import { useStorage } from "../../Contexts/StorageContext"
import { desktopGridSettings, mobileGridSettings } from "../Pages/BucketsPage"
import { ROUTE_LINKS } from "../StorageRoutes"

const useStyles = makeStyles(({ animation, constants, breakpoints }: CSSTheme) =>
createStyles({
dropdownIcon: {
"& svg": {
fill: constants.fileSystemItemRow.dropdownIcon
}
},
dropdownOptions: {
backgroundColor: constants.fileSystemItemRow.optionsBackground,
color: constants.fileSystemItemRow.optionsColor,
border: `1px solid ${constants.fileSystemItemRow.optionsBorder}`
},
dropdownItem: {
backgroundColor: constants.fileSystemItemRow.itemBackground,
color: constants.fileSystemItemRow.itemColor
},
menuIcon: {
display: "flex",
justifyContent: "center",
alignItems: "center",
width: 20,
marginRight: constants.generalUnit * 1.5,
"& svg": {
fill: constants.fileSystemItemRow.menuIcon
}
},
name: {
textAlign: "left",
whiteSpace: "nowrap",
textOverflow: "ellipsis",
overflow: "hidden",
"&.editing": {
overflow: "visible"
}
},
tableRow: {
border: "2px solid transparent",
transitionDuration: `${animation.transform}ms`,
[breakpoints.up("md")]: {
gridTemplateColumns: desktopGridSettings
},
[breakpoints.down("md")]: {
gridTemplateColumns: mobileGridSettings
},
cursor: "pointer"
}
})
)
interface Props {
bucket: Bucket
}

const BucketRow = ({ bucket }: Props) => {
const classes = useStyles()
const { removeBucket } = useStorage()
const { redirect } = useHistory()
return (
<TableRow
type="grid"
className={classes.tableRow}
>
<TableCell className={classes.name}
onClick={() => redirect(ROUTE_LINKS.Bucket(bucket.id, "/"))}>
{bucket.name}
</TableCell>
<TableCell>
{formatBytes(bucket.size)}
</TableCell>
<TableCell align="right">
<MenuDropdown
testId='bucketDropdown'
animation="none"
anchor={"bottom-right"}
menuItems={[{
contents: (
<>
<DeleteSvg className={classes.menuIcon} />
<span data-cy="menu-share">
<Trans>Delete bucket</Trans>
</span>
</>
),
onClick: () => removeBucket(bucket.id)
FSM1 marked this conversation as resolved.
Show resolved Hide resolved
}]}
classNames={{
icon: classes.dropdownIcon,
options: classes.dropdownOptions,
item: classes.dropdownItem
}}
indicator={MoreIcon}
/>
</TableCell>
</TableRow>
)
}

export default BucketRow
2 changes: 1 addition & 1 deletion packages/storage-ui/src/Components/Layouts/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const AppHeader = ({ navOpen, setNavOpen }: IAppHeader) => {

<section className={classes.accountControls}>
<MenuDropdown
title='TBC'
title=''
anchor="bottom-right"
classNames={{
icon: classes.icon,
Expand Down
2 changes: 1 addition & 1 deletion packages/storage-ui/src/Components/Layouts/AppNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const AppNav: React.FC<IAppNav> = ({ navOpen, setNavOpen }: IAppNav) => {
>
<ChainsafeLogo />
<Typography variant="body1">
ChainSafe Storage
Storage
</Typography>
</Link>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import {
Button,
FormikTextInput,
Grid,
Typography
} from "@chainsafe/common-components"
import * as yup from "yup"
import {
createStyles,
makeStyles,
useMediaQuery
} from "@chainsafe/common-theme"
import React, { useRef, useEffect, useState } from "react"
import { Formik, Form } from "formik"
import CustomModal from "../../Elements/CustomModal"
import CustomButton from "../../Elements/CustomButton"
import { t, Trans } from "@lingui/macro"
import { CSSTheme } from "../../../Themes/types"
import { useFileBrowser } from "../../../Contexts/FileBrowserContext"
import { useStorageApi } from "../../../Contexts/StorageApiContext"


const useStyles = makeStyles(
({ breakpoints, constants, typography, zIndex }: CSSTheme) => {
return createStyles({
root: {
padding: constants.generalUnit * 4,
flexDirection: "column"
},
modalRoot: {
zIndex: zIndex?.blocker,
[breakpoints.down("md")]: {}
},
modalInner: {
backgroundColor: constants.createFolder.backgroundColor,
color: constants.createFolder.color,
[breakpoints.down("md")]: {
bottom:
Number(constants?.mobileButtonHeight) + constants.generalUnit,
borderTopLeftRadius: `${constants.generalUnit * 1.5}px`,
borderTopRightRadius: `${constants.generalUnit * 1.5}px`,
maxWidth: `${breakpoints.width("md")}px !important`
}
},
input: {
marginBottom: constants.generalUnit * 2
},
okButton: {
marginLeft: constants.generalUnit
},
cancelButton: {
[breakpoints.down("md")]: {
position: "fixed",
bottom: 0,
left: 0,
width: "100%",
height: constants?.mobileButtonHeight
}
},
label: {
fontSize: 14,
lineHeight: "22px"
},
heading: {
color: constants.createFolder.color,
fontWeight: typography.fontWeight.semibold,
textAlign: "center",
marginBottom: constants.generalUnit * 4
}
})
}
)

interface ICreateFolderModalProps {
modalOpen: boolean
close: () => void
}

const CreateFolderModal: React.FC<ICreateFolderModalProps> = ({
modalOpen,
close
}: ICreateFolderModalProps) => {
const classes = useStyles()
const { storageApiClient } = useStorageApi()
const { currentPath, refreshContents, bucket } = useFileBrowser()
const [creatingFolder, setCreatingFolder] = useState(false)
const desktop = useMediaQuery("md")
const inputRef = useRef<any>(null)

useEffect(() => {
if (modalOpen) {
setTimeout(() => inputRef.current?.focus(), 100)
}
}, [modalOpen])

const folderNameValidator = yup.object().shape({
name: yup
.string()
.required(t`Folder name is required`)
.test(
"Invalid name",
FSM1 marked this conversation as resolved.
Show resolved Hide resolved
t`Folder name cannot contain '/' character`,
(val: string | null | undefined) => !!val && !val.includes("/")
)
})

return (
<CustomModal
className={classes.modalRoot}
injectedClass={{
inner: classes.modalInner
}}
active={modalOpen}
closePosition="none"
maxWidth="sm"
>
<Formik
initialValues={{
name: ""
}}
validationSchema={folderNameValidator}
validateOnChange={false}
onSubmit={async (values, helpers) => {
if (!bucket) return
helpers.setSubmitting(true)
try {
setCreatingFolder(true)
await storageApiClient.addBucketDirectory(bucket.id, { path: `${currentPath}/${values.name}` })
refreshContents && await refreshContents()
setCreatingFolder(false)
helpers.resetForm()
close()
} catch (errors) {
setCreatingFolder(false)
if (errors[0].message.includes("Entry with such name can")) {
helpers.setFieldError("name", t`Folder name is already in use`)
} else {
helpers.setFieldError("name", errors[0].message)
}
}
helpers.setSubmitting(false)
}}
>
<Form>
<div className={classes.root}>
{!desktop && (
<Grid
item
xs={12}
sm={12}
>
<Typography
className={classes.heading}
variant="h5"
component="h5"
>
<Trans>Create Folder</Trans>
</Typography>
</Grid>
)}
<Grid
item
xs={12}
sm={12}
className={classes.input}
>
<FormikTextInput
name="name"
size="large"
placeholder={t`Name`}
labelClassName={classes.label}
label={t`Folder Name`}
ref={inputRef}
/>
</Grid>
<Grid
item
flexDirection="row"
justifyContent="flex-end"
>
<CustomButton
onClick={() => close()}
size="medium"
className={classes.cancelButton}
variant={desktop ? "outline" : "gray"}
type="button"
>
<Trans>Cancel</Trans>
</CustomButton>
<Button
size={desktop ? "medium" : "large"}
variant="primary"
type="submit"
className={classes.okButton}
loading={creatingFolder}
>
{desktop ? <Trans>OK</Trans> : <Trans>Create</Trans>}
</Button>
</Grid>
</div>
</Form>
</Formik>
</CustomModal>
)
}

export default CreateFolderModal
Loading