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

Shared folder overview #1078

Merged
merged 43 commits into from
Jun 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 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
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
64e7c76
loader
Tbaut Jun 17, 2021
10d5be6
nav color
Tbaut Jun 17, 2021
b43bc2e
lingui extract
actions-user Jun 17, 2021
0c4aa89
Merge branch 'dev' into feat/tbaut-shared-overview-1041
Tbaut Jun 17, 2021
9e6da72
please codacy
Tbaut Jun 17, 2021
90c4205
Merge branch 'dev' into feat/tbaut-shared-overview-1041
Tbaut Jun 17, 2021
234714a
Merge branch 'feat/tbaut-shared-overview-1041' of github.com:ChainSaf…
Tbaut Jun 17, 2021
3e423a5
Merge branch 'dev' into feat/tbaut-shared-overview-1041
tanmoyAtb Jun 18, 2021
142bd8d
overflow visible
tanmoyAtb Jun 18, 2021
f56265c
Merge branch 'dev' into feat/tbaut-shared-overview-1041
tanmoyAtb Jun 20, 2021
1fe41b5
Merge branch 'dev' into feat/tbaut-shared-overview-1041
Tbaut Jun 21, 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
7 changes: 7 additions & 0 deletions packages/common-components/src/Icons/icons/UserShare.icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as React from "react"
import createSvgIcon from "../createSvgIcon"
import { ReactComponent as UserShareSvg } from "../svgs/user-share.svg"

export { UserShareSvg }

export default createSvgIcon(<UserShareSvg />)
1 change: 1 addition & 0 deletions packages/common-components/src/Icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export { default as TableIcon, TableSvg } from "./icons/Table.icon"
export { default as UploadIcon, UploadSvg } from "./icons/Upload.icon"
export { default as UnionpayCardIcon, UnionpayCardSvg } from "./icons/UnionpayCard.icon"
export { default as UserIcon, UserSvg } from "./icons/User.icon"
export { default as UserShareIcon, UserShareSvg } from "./icons/UserShare.icon"
export { default as VisaCardIcon, VisaCardSvg } from "./icons/VisaCard.icon"
export { default as WarningIcon, WarningSvg } from "./icons/Warning.icon"
export { default as ZoomInIcon, ZoomInSvg } from "./icons/ZoomIn.icon"
Expand Down
3 changes: 3 additions & 0 deletions packages/common-components/src/Icons/svgs/user-share.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
131 changes: 131 additions & 0 deletions packages/files-ui/src/Components/Elements/SharedUser.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import React, { useState } from "react"
import { makeStyles, createStyles } from "@chainsafe/common-theme"
import { CSFTheme } from "../../Themes/types"
import { Typography, UserIcon } from "@chainsafe/common-components"
import clsx from "clsx"

const useStyles = makeStyles(({ zIndex, animation, constants, palette }: CSFTheme) => {
return createStyles({
root: {
display: "flex"
},
bubble: {
position: "relative",
borderRadius: "50%",
backgroundColor: palette.additional["gray"][6],
color: palette.common.white.main,
width: constants.generalUnit * 5,
height: constants.generalUnit * 5,
display: "flex",
alignItems: "center",
justifyContent: "center",
"& svg": {
fill: palette.common.white.main
},
"&:first-child": {
marginRight: constants.generalUnit
}
},
text : {
textAlign: "center"
},
tooltip: {
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
left: "50%",
top: "-20px",
position: "absolute",
transform: "translate(-50%, -50%)",
zIndex: zIndex?.layer1,
transitionDuration: `${animation.transform}ms`,
opacity: 0,
visibility: "hidden",
backgroundColor: constants.loginModule.flagBg,
color: constants.loginModule.flagText,
padding: `${constants.generalUnit / 2}px ${constants.generalUnit}px`,
borderRadius: 2,
"&:after": {
transitionDuration: `${animation.transform}ms`,
content: "''",
position: "absolute",
top: "100%",
left: "50%",
transform: "translate(-50%,0)",
width: 0,
height: 0,
borderLeft: "5px solid transparent",
borderRight: "5px solid transparent",
borderTop: `5px solid ${constants.loginModule.flagBg}`
},
"&.active": {
opacity: 1,
visibility: "visible"
}

}
})
})

interface Props {
sharedUsers: string[]
}

const SharedUsers = ({ sharedUsers }: Props) => {
const classes = useStyles()

if (!sharedUsers.length) {
return null
}

const UserBubble = ({ text, hover }: {text?: string; hover: string | string[]}) => {
const [isHover, setIsHover] = useState(false)

return (
<div
onMouseEnter={() => setIsHover(true)}
onMouseLeave={() => setIsHover(false)}
className={classes.bubble}
>
<div className={clsx(classes.tooltip, { "active": isHover })}>
{
Array.isArray(hover)
? hover.map((user) => <div key={user}>{user}</div>)
: hover
}
</div>
{text
? <Typography
variant="h4"
className={classes.text}
>
{text}
</Typography>
: <UserIcon/>
}
</div>
)
}

return (
<div className={classes.root}>
<UserBubble
hover={sharedUsers[0]}
/>
{sharedUsers.length > 2 && (
<UserBubble
text={`+${sharedUsers.length - 1}`}
hover={sharedUsers.slice(0, -1)}
/>
)}
{sharedUsers.length === 2 && (
<UserBubble
hover={sharedUsers[1]}
/>
)}
</div>
)
}

export default SharedUsers
10 changes: 9 additions & 1 deletion packages/files-ui/src/Components/FilesRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SearchPage from "./Pages/SearchPage"
import BinPage from "./Pages/BinPage"
import PurchasePlanPage from "./Pages/PurchasePlanPage"
import { useThresholdKey } from "../Contexts/ThresholdKeyContext"
import SharedFoldersOverview from "./Modules/FileBrowsers/SharedFoldersOverview"

export const SETTINGS_BASE = "/settings"
export const ROUTE_LINKS = {
Expand All @@ -23,7 +24,8 @@ export const ROUTE_LINKS = {
SettingsDefault: `${SETTINGS_BASE}`,
PurchasePlan: "/purchase",
UserSurvey: "https://shrl.ink/kmAL",
GeneralFeedbackForm: "https://shrl.ink/gvVJ"
GeneralFeedbackForm: "https://shrl.ink/gvVJ",
SharedFolders: "/shared"
}

export const SETTINGS_PATHS = ["profile", "plan", "security"] as const
Expand All @@ -50,6 +52,12 @@ const FilesRoutes = () => {
component={BinPage}
redirectPath={ROUTE_LINKS.Landing}
/>
<ConditionalRoute
path={ROUTE_LINKS.SharedFolders}
isAuthorized={isAuthorized}
component={SharedFoldersOverview}
redirectPath={ROUTE_LINKS.Landing}
/>
<ConditionalRoute
exact
path={ROUTE_LINKS.Search("")}
Expand Down
19 changes: 18 additions & 1 deletion packages/files-ui/src/Components/Layouts/AppNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
ProgressBar,
Button,
formatBytes,
DeleteSvg } from "@chainsafe/common-components"
DeleteSvg,
UserShareSvg } from "@chainsafe/common-components"
import { ROUTE_LINKS } from "../FilesRoutes"
import { FREE_PLAN_LIMIT } from "../../Utils/Constants"
import { Trans } from "@lingui/macro"
Expand Down Expand Up @@ -155,6 +156,9 @@ const useStyles = makeStyles(
}
},
"& svg": {
"& path" : {
fill: constants.nav.headingColor
},
transitionDuration: `${animation.transform}ms`,
width: Number(constants.svgWidth),
marginRight: constants.generalUnit * 2,
Expand Down Expand Up @@ -293,6 +297,19 @@ const AppNav: React.FC<IAppNav> = ({ navOpen, setNavOpen }: IAppNav) => {
<Trans>Home</Trans>
</Typography>
</Link>
<Link
onClick={handleOnClick}
className={classes.navItem}
to={ROUTE_LINKS.SharedFolders}
>
<UserShareSvg />
<Typography
variant="h5"
className={classes.navItemText}
>
<Trans>Shared</Trans>
</Typography>
</Link>
<Link
onClick={handleOnClick}
className={classes.navItem}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ const DownloadProgressModals: React.FC = () => {

if (downloadsInProgress.length === 0) { return null }

return (
<div className={classes.root}>
{downloadsInProgress.map((downloadInProgress) => (
<DownloadBox
key={downloadInProgress.id}
downloadInProgress={downloadInProgress}
/>
))}
</div>
)
if (downloadsInProgress.length > 0) {
return (
<div className={classes.root}>
{downloadsInProgress.map((downloadInProgress) => (
<DownloadBox
key={downloadInProgress.id}
downloadInProgress={downloadInProgress}
/>
))}
</div>
)} else {
return null
}
}

export default DownloadProgressModals
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ const BinFileBrowser: React.FC<IFileBrowserModuleProps> = ({ controls = false }:
const [loadingCurrentPath, setLoadingCurrentPath] = useState(false)
const [pathContents, setPathContents] = useState<FileSystemItem[]>([])
const { pathname } = useLocation()
const currentPath = useMemo(() =>
extractFileBrowserPathFromURL(pathname, ROUTE_LINKS.Bin("")),
[pathname]
)
const currentPath = useMemo(() => extractFileBrowserPathFromURL(pathname, ROUTE_LINKS.Bin("")), [pathname])
const { redirect } = useHistory()

const bucket = useMemo(() => buckets.find(b => b.type === "trash"), [buckets])
Expand Down Expand Up @@ -159,7 +156,7 @@ const BinFileBrowser: React.FC<IFileBrowserModuleProps> = ({ controls = false }:
<FileBrowserContext.Provider value={{
bucket: bucket,
crumbs: undefined,
deleteItems: deleteItems,
deleteItems,
recoverItems,
currentPath,
moduleRootPath: ROUTE_LINKS.Bin("/"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ const CSFFileBrowser: React.FC<IFileBrowserModuleProps> = () => {
const [loadingCurrentPath, setLoadingCurrentPath] = useState(false)
const [pathContents, setPathContents] = useState<FileSystemItem[]>([])
const { redirect } = useHistory()

const { pathname } = useLocation()
const currentPath = useMemo(() =>
extractFileBrowserPathFromURL(pathname, ROUTE_LINKS.Drive("")),
[pathname]
)
const currentPath = useMemo(() => extractFileBrowserPathFromURL(pathname, ROUTE_LINKS.Drive("")), [pathname])
const bucket = useMemo(() => buckets.find(b => b.type === "csf"), [buckets])

const refreshContents = useCallback((showLoading?: boolean) => {
Expand Down Expand Up @@ -186,7 +182,9 @@ const CSFFileBrowser: React.FC<IFileBrowserModuleProps> = () => {
appearance: "error"
})
} else {
uploadFiles(bucket.id, files, path).then(() => refreshContents()).catch(console.error)
uploadFiles(bucket.id, files, path)
.then(() => refreshContents())
.catch(console.error)
}
}, [addToastMessage, uploadFiles, bucket, refreshContents])

Expand Down
Loading