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

Sharing file browser #1048

Merged
merged 41 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f3e3208
Started
RyRy79261 May 21, 2021
d5629f6
Merge branch 'dev' into feat/sharing-file-browser-1043
RyRy79261 Jun 1, 2021
2d29c59
Updated with refactors
RyRy79261 Jun 1, 2021
d3ea46f
Skeletoned
RyRy79261 Jun 1, 2021
8844563
lingui extract
actions-user Jun 1, 2021
e8a08a1
Merge branch 'dev' into feat/sharing-file-browser-1043
RyRy79261 Jun 7, 2021
0b4ceaf
Correct api package up
RyRy79261 Jun 8, 2021
6c067bc
Access logic & ID extraction done
RyRy79261 Jun 8, 2021
ef892a2
Bucket extracting ready
RyRy79261 Jun 8, 2021
ad90269
Merge branch 'dev' into feat/sharing-file-browser-1043
RyRy79261 Jun 21, 2021
9c34ec9
Fixing recover
RyRy79261 Jun 21, 2021
e8a2b1a
Trying to fix the routing
RyRy79261 Jun 22, 2021
90586f1
Tried reordering
RyRy79261 Jun 22, 2021
e5d9c61
Merge remote-tracking branch 'origin/dev' into feat/sharing-file-brow…
FSM1 Jun 22, 2021
6fad93e
Fix routing
FSM1 Jun 22, 2021
f4cf514
Fixing small items
RyRy79261 Jun 22, 2021
6dec91e
Fixed crash issue
RyRy79261 Jun 22, 2021
bddce51
Uploading done
RyRy79261 Jun 23, 2021
f3c8da4
Merging dev
RyRy79261 Jun 24, 2021
78aa3c7
Merge branch 'dev' into feat/sharing-file-browser-1043
RyRy79261 Jun 24, 2021
ae23a1b
Fixed routing
RyRy79261 Jun 24, 2021
5b61da7
lingui extract
actions-user Jun 24, 2021
44674f0
Access control done
RyRy79261 Jun 24, 2021
c6d1474
Merge branch 'feat/sharing-file-browser-1043' of github.com:ChainSafe…
RyRy79261 Jun 24, 2021
d44b0dc
DnD access control done
RyRy79261 Jun 24, 2021
707a542
Merge branch 'dev' into feat/sharing-file-browser-1043
RyRy79261 Jun 24, 2021
d84af9f
Owner spacing fixed
RyRy79261 Jun 24, 2021
01a3aa9
Merge branch 'feat/sharing-file-browser-1043' of github.com:ChainSafe…
RyRy79261 Jun 24, 2021
bbe194a
REmoved toto
RyRy79261 Jun 24, 2021
b25bfac
Pruned
RyRy79261 Jun 24, 2021
3d78d5e
lingui extract
actions-user Jun 24, 2021
b5c1c2b
Merge branch 'dev' into feat/sharing-file-browser-1043
RyRy79261 Jun 28, 2021
71d71c8
lingui extract
actions-user Jun 28, 2021
c656f58
Pulling permission object
RyRy79261 Jun 28, 2021
a62aaee
Merge branch 'feat/sharing-file-browser-1043' of github.com:ChainSafe…
RyRy79261 Jun 28, 2021
38af19d
Fixed swith error
RyRy79261 Jun 28, 2021
159ba63
Minor changes
RyRy79261 Jun 28, 2021
fa638f1
Updated route url
RyRy79261 Jun 30, 2021
f097f9c
Merge branch 'dev' into feat/sharing-file-browser-1043
RyRy79261 Jun 30, 2021
392c9ac
fix build
Tbaut Jun 30, 2021
cbc02a0
remove survey and show bucket name
Tbaut Jul 1, 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
27 changes: 14 additions & 13 deletions 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 ShareFilesPage from "./Pages/ShareFilesPage"
import SharedFoldersOverview from "./Modules/FileBrowsers/SharedFoldersOverview"

export const SETTINGS_BASE = "/settings"
Expand All @@ -17,15 +18,17 @@ export const ROUTE_LINKS = {
Terms: "https://files.chainsafe.io/terms-of-service",
ChainSafe: "https://chainsafe.io/",
Drive: (rawCurrentPath: string) => `/drive${rawCurrentPath}`,
Search: (rawSearchTerm: string) => `/search/${rawSearchTerm}`,
Bin: (rawBinPath: string) => `/bin${rawBinPath}`,
Search: (rawSearchTerm: string) => `/search/${rawSearchTerm}`,
ApplyCryptography: "https://medium.com/chainsafe-systems/major-improvement-to-chainsafe-files-ab489d3e52a2",
Settings: `${SETTINGS_BASE}/:path`,
SettingsDefault: `${SETTINGS_BASE}`,
PurchasePlan: "/purchase",
UserSurvey: "https://shrl.ink/kmAL",
GeneralFeedbackForm: "https://shrl.ink/gvVJ",
SharedFolders: "/shared"
SharedFolders: "/shared-overview",
ShareBrowserRoot: "/shared",
ShareExplorer: (bucketId: string, rawCurrentPath: string) => `/shared/${bucketId}${rawCurrentPath}`
}

export const SETTINGS_PATHS = ["profile", "plan", "security"] as const
Expand All @@ -37,32 +40,31 @@ const FilesRoutes = () => {

const isAuthorized = useMemo(() => isLoggedIn && secured && !!publicKey && !isNewDevice && !shouldInitializeAccount,
[isLoggedIn, isNewDevice, publicKey, secured, shouldInitializeAccount])

return (
<Switch>
<ConditionalRoute
path={ROUTE_LINKS.Drive("/")}
exact
path={ROUTE_LINKS.SharedFolders}
isAuthorized={isAuthorized}
component={DrivePage}
component={SharedFoldersOverview}
redirectPath={ROUTE_LINKS.Landing}
/>
<ConditionalRoute
path={ROUTE_LINKS.Bin("/")}
path={ROUTE_LINKS.ShareBrowserRoot}
isAuthorized={isAuthorized}
component={BinPage}
component={ShareFilesPage}
redirectPath={ROUTE_LINKS.Landing}
/>
<ConditionalRoute
path={ROUTE_LINKS.SharedFolders}
path={ROUTE_LINKS.Drive("/")}
isAuthorized={isAuthorized}
component={SharedFoldersOverview}
component={DrivePage}
redirectPath={ROUTE_LINKS.Landing}
/>
<ConditionalRoute
exact
path={ROUTE_LINKS.Search("")}
path={ROUTE_LINKS.Bin("/")}
isAuthorized={isAuthorized}
component={SearchPage}
component={BinPage}
redirectPath={ROUTE_LINKS.Landing}
/>
<ConditionalRoute
Expand All @@ -72,7 +74,6 @@ const FilesRoutes = () => {
component={SearchPage}
redirectPath={ROUTE_LINKS.Landing}
/>

<ConditionalRoute
exact
path={ROUTE_LINKS.SettingsDefault}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,8 @@ import { CSFTheme } from "../../../Themes/types"
import { Bucket } from "@chainsafe/files-api-client"
import SharedFolderItem from "./views/FileSystemItem/SharedFolderRow"

const useStyles = makeStyles(({ breakpoints, constants }: CSFTheme) => {
const useStyles = makeStyles(({ constants }: CSFTheme) => {
return createStyles({
renameInput: {
width: "100%",
[breakpoints.up("md")]: {
margin: 0
},
[breakpoints.down("md")]: {
margin: `${constants.generalUnit * 4.2}px 0`
}
},
modalRoot: {
[breakpoints.down("md")]: {}
},
modalInner: {
[breakpoints.down("md")]: {
bottom:
Number(constants?.mobileButtonHeight) + constants.generalUnit,
borderTopLeftRadius: `${constants.generalUnit * 1.5}px`,
borderTopRightRadius: `${constants.generalUnit * 1.5}px`,
borderBottomLeftRadius: `${constants.generalUnit * 1.5}px`,
borderBottomRightRadius: `${constants.generalUnit * 1.5}px`,
maxWidth: `${breakpoints.width("md")}px !important`
}
},
renameHeader: {
textAlign: "center"
},
renameFooter: {
display: "flex",
flexDirection: "row",
alignItems: "center",
justifyContent: "flex-end"
},
renameModal: {
padding: constants.generalUnit * 4
},
okButton: {
marginLeft: constants.generalUnit
},
cancelButton: {
[breakpoints.down("md")]: {
position: "fixed",
bottom: 0,
left: 0,
width: "100%",
height: constants?.mobileButtonHeight
}
},
menuIcon: {
display: "flex",
justifyContent: "center",
Expand All @@ -64,24 +17,19 @@ const useStyles = makeStyles(({ breakpoints, constants }: CSFTheme) => {
"& svg": {
fill: constants.fileSystemItemRow.menuIcon
}
},
dropdownIcon: {
"& svg": {
fill: constants.fileSystemItemRow.dropdownIcon
}
}
})
})

interface Props {
bucket: Bucket
openSharedFolder: (bucketId: string) => void
}

const SharedFolderRowWrapper = ({ bucket }: Props) => {
const SharedFolderRowWrapper = ({ bucket, openSharedFolder }: Props) => {
const { desktop } = useThemeSwitcher()
const classes = useStyles()


const menuItems: IMenuItem[] = [{
contents: (
<>
Expand Down Expand Up @@ -111,21 +59,23 @@ const SharedFolderRowWrapper = ({ bucket }: Props) => {
// on desktop
} else {
// on mobile
openSharedFolder(bucket.id)
}
},
[desktop]
[desktop, openSharedFolder, bucket]
)

const onDoubleClick = useCallback(
() => {
if (desktop) {
// on desktop
openSharedFolder(bucket.id)
} else {
// on mobile
return
}
},
[desktop]
[desktop, openSharedFolder, bucket]
)

const { click } = useDoubleClick(onSingleClick, onDoubleClick)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import React, { useMemo, useState } from "react"
import { Typography, Table, TableHead, TableRow, TableHeadCell, TableBody, SortDirection, Loading } from "@chainsafe/common-components"
import React, { useCallback, useMemo, useState } from "react"
import {
Typography,
Table,
TableHead,
TableRow,
TableHeadCell,
TableBody,
SortDirection,
Loading,
useHistory
} from "@chainsafe/common-components"
import { useFiles } from "../../../Contexts/FilesContext"
import { Trans } from "@lingui/macro"
import { createStyles, makeStyles, useThemeSwitcher } from "@chainsafe/common-theme"
import { CSFTheme } from "../../../Themes/types"
import { useFilesApi } from "../../../Contexts/FilesApiContext"
import SharedFolderRowWrapper from "./SharedFolderRowWrapper"
import clsx from "clsx"
import { ROUTE_LINKS } from "../../FilesRoutes"

export const desktopSharedGridSettings = "69px 3fr 190px 150px 45px !important"
export const mobileSharedGridSettings = "3fr 50px 45px !important"
Expand Down Expand Up @@ -88,6 +99,7 @@ const SharedFolderOverview = () => {
const { filesApiClient, encryptedEncryptionKey } = useFilesApi()
const [direction, setDirection] = useState<SortDirection>("ascend")
const [column, setColumn] = useState<"name" | "size" | "date_uploaded">("name")
const { redirect } = useHistory()
const { desktop } = useThemeSwitcher()

const bucketsToShow = useMemo(() => buckets.filter(b => b.type === "share"), [buckets])
Expand All @@ -107,6 +119,10 @@ const SharedFolderOverview = () => {
}
}

const openSharedFolder = useCallback((bucketId: string) => {
redirect(ROUTE_LINKS.ShareExplorer(bucketId, "/"))
}, [redirect])

return (
<article
className={classes.root}
Expand Down Expand Up @@ -193,6 +209,7 @@ const SharedFolderOverview = () => {
<SharedFolderRowWrapper
key={bucket.id}
bucket={bucket}
openSharedFolder={openSharedFolder}
/>
)}
</TableBody>
Expand Down
Loading