diff --git a/.github/pr-labeler.yml b/.github/pr-labeler.yml new file mode 100644 index 0000000000..d4e1e9790d --- /dev/null +++ b/.github/pr-labeler.yml @@ -0,0 +1,3 @@ +"Type: Feature": ['feature/*', 'feat/*'] +"Type: Bug Fix": fix/* +"Type: Maintenance": ['chore/*', 'mnt/*'] diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 850e66e72e..d547bb0822 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -5,15 +5,13 @@ tag-template: "v$RESOLVED_VERSION" categories: - title: "🚀 Features" labels: - - "Feature" - - "Enhancement" + - "Type: Feature" - title: "🐛 Bug Fixes" labels: - - "Bug" - - "Bugfix" - - "fix" + - "Type: Bug Fix" - title: "🧰 Maintenance" - label: "Maintenance" + label: + - "Type: Maintenance" change-template: "- $TITLE @$AUTHOR (#$NUMBER)" change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. version-resolver: diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml new file mode 100644 index 0000000000..37c870fca0 --- /dev/null +++ b/.github/workflows/pr-labeler.yml @@ -0,0 +1,14 @@ +name: PR Labeler +on: + pull_request: + types: [opened] + +jobs: + pr-labeler: + runs-on: ubuntu-latest + steps: + - uses: TimonVS/pr-labeler-action@v3 + with: + configuration-path: .github/pr-labeler.yml # optional, .github/pr-labeler.yml is the default value + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/prod_release.yml b/.github/workflows/prod_release.yml deleted file mode 100644 index 5f9ccf7a79..0000000000 --- a/.github/workflows/prod_release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Release Production -on: - push: - branches: - - "prod" - -jobs: - build: - name: Release Production - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Short SHA - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: prod-${{ steps.vars.outputs.sha_short }} - release_name: prod-${{ steps.vars.outputs.sha_short }} - draft: false - prerelease: false diff --git a/.github/workflows/stage_release.yml b/.github/workflows/stage_release.yml deleted file mode 100644 index 0ea0baa4e0..0000000000 --- a/.github/workflows/stage_release.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Release Staging -on: - push: - branches: - - "dev" - -jobs: - build: - name: Release Staging - runs-on: ubuntu-20.04 - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Short SHA - id: vars - run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: stage-${{ steps.vars.outputs.sha_short }} - release_name: stage-${{ steps.vars.outputs.sha_short }} - draft: false - prerelease: true diff --git a/package.json b/package.json index c02314dbba..991a0662c6 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,12 @@ "dependencies": {}, "devDependencies": { "@sentry/cli": "1.60.1", + "@typescript-eslint/eslint-plugin": "^4.15.2", + "@typescript-eslint/parser": "^4.15.2", "chalk": "^4.1.0", + "eslint": "^6.8.0", + "eslint-plugin-cypress": "^2.11.3", + "eslint-plugin-react": "^7.22.0", "eslint-plugin-react-hooks": "^4.2.0", "npm-run-all": "^4.1.5", "typescript": "^4.0.5", @@ -22,7 +27,7 @@ }, "scripts": { "postinstall": "yarn build:common && yarn wsrun -p files-ui -c compile", - "build:common": "yarn build:theme && yarn build:components && yarn build:contexts", + "build:common": "yarn build:theme && yarn build:components", "build:contexts": "yarn wsrun -t -p @chainsafe/common-contexts -c build", "build:components": "yarn wsrun -t -p @chainsafe/common-components -c build", "build:theme": "yarn wsrun -t -p @chainsafe/common-theme -c build", @@ -31,9 +36,9 @@ "build:files-ui": "yarn wsrun -p files-ui -c build", "release:files-ui": "yarn wsrun -p files-ui -c release", "start:files-ui": "yarn wsrun -p files-ui -c start", - "build:chainsafex": "yarn wsrun -p chainsafex -c build", - "release:chainsafex": "yarn wsrun -p chainsafex -c release", - "start:chainsafex": "yarn wsrun -p chainsafex -c start", + "build:storage-ui": "yarn wsrun -p storage-ui -c build", + "release:storage-ui": "yarn wsrun -p storage-ui -c release", + "start:storage-ui": "yarn wsrun -p storage-ui -c start", "clean:dependencies": "rm -rf ./node_modules && rm -rf ./*/**/node_modules", "clean:dist": "rm -rf ./*/**/dist && rm -rf ./*/**/build && rm -rf ./*/**/storybook-static", "clean": "yarn clean:dependencies && yarn clean:dist", diff --git a/packages/chainsafex/.env.example b/packages/chainsafex/.env.example deleted file mode 100644 index 5134d7e8f0..0000000000 --- a/packages/chainsafex/.env.example +++ /dev/null @@ -1,9 +0,0 @@ -PORT=3000 -HTTPS=true - -REACT_APP_API_URL= -REACT_APP_STRIPE_PK= -REACT_APP_SENTRY_DSN_URL= -REACT_APP_SENTRY_RELEASE=development -REACT_APP_HOTJAR_ID= -SENTRY_AUTH_TOKEN= diff --git a/packages/chainsafex/package.json b/packages/chainsafex/package.json deleted file mode 100644 index 39d7ac3516..0000000000 --- a/packages/chainsafex/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "chainsafex", - "version": "1.0.0", - "private": true, - "dependencies": { - "@sentry/react": "^5.28.0", - "clsx": "^1.1.1", - "ethers": "^5.0.24", - "react": "^16.14.0", - "react-dom": "^16.14.0", - "react-scripts": "3.4.4", - "yup": "^0.32.8" - }, - "devDependencies": { - "@craco/craco": "^5.9.0", - "@testing-library/jest-dom": "^5.11.6", - "@testing-library/react": "^11.2.2", - "@testing-library/user-event": "^12.5.0", - "@types/jest": "^26.0.16", - "@types/node": "^14.14.10", - "@types/react": "^17.0.0", - "@types/react-dom": "^16.9.10", - "@types/react-pdf": "^5.0.0" - }, - "scripts": { - "start": "craco --max_old_space_size=4096 start", - "build": "craco --max_old_space_size=4096 build", - "sentry": "(export REACT_APP_SENTRY_RELEASE=$(sentry-cli releases propose-version); node scripts/sentry.js)", - "release": "(export REACT_APP_SENTRY_RELEASE=$(sentry-cli releases propose-version); yarn build && node scripts/sentry.js)", - "test": "react-scripts test", - "analyze": "source-map-explorer 'build/static/js/*.js'" - }, - "eslintConfig": { - "extends": "react-app" - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } -} diff --git a/packages/chainsafex/public/ChainSafe-logo.png b/packages/chainsafex/public/ChainSafe-logo.png deleted file mode 100644 index 95ee5385b9..0000000000 Binary files a/packages/chainsafex/public/ChainSafe-logo.png and /dev/null differ diff --git a/packages/chainsafex/public/favicon.ico b/packages/chainsafex/public/favicon.ico deleted file mode 100644 index 0c72c7154d..0000000000 Binary files a/packages/chainsafex/public/favicon.ico and /dev/null differ diff --git a/packages/chainsafex/src/App.tsx b/packages/chainsafex/src/App.tsx deleted file mode 100644 index fee246b00b..0000000000 --- a/packages/chainsafex/src/App.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React, { useEffect } from "react" -import { - init as initSentry, - ErrorBoundary, - showReportDialog -} from "@sentry/react" -import { ThemeSwitcher } from "@chainsafe/common-theme" -import { CssBaseline, Router } from "@chainsafe/common-components" -import AppWrapper from "./Components/Layouts/AppWrapper" -import { lightTheme } from "./Themes/LightTheme" -import { darkTheme } from "./Themes/DarkTheme" -import { useHotjar } from "react-use-hotjar" -import Routes from "./Components/Routes" - -if ( - process.env.NODE_ENV === "production" && - process.env.REACT_APP_SENTRY_DSN_URL && - process.env.REACT_APP_SENTRY_RELEASE -) { - initSentry({ - dsn: process.env.REACT_APP_SENTRY_DSN_URL, - release: process.env.REACT_APP_SENTRY_RELEASE - }) -} - -const App: React.FC<{}> = () => { - const { initHotjar } = useHotjar() - const hotjarId = process.env.REACT_APP_HOTJAR_ID - - // const apiUrl = - // process.env.REACT_APP_API_URL || "http://3.236.79.100:8000/api/v1" - - useEffect(() => { - if (hotjarId && process.env.NODE_ENV === "production") { - initHotjar(hotjarId, "6", () => console.log("Hotjar initialized")) - } - }, [hotjarId, initHotjar]) - - return ( - ( -
-

- An error occurred and has been logged. If you would like to provide - additional info to help us debug and resolve the issue, click the - "Provide Additional Details" button -

-

{error?.message.toString()}

-

{componentStack}

-

{eventId}

- - -
- )} - onReset={() => window.location.reload()} - > - - - - - - - - -
- ) -} - -export default App diff --git a/packages/chainsafex/src/Components/Layouts/AppWrapper.tsx b/packages/chainsafex/src/Components/Layouts/AppWrapper.tsx deleted file mode 100644 index 9edf14e8e9..0000000000 --- a/packages/chainsafex/src/Components/Layouts/AppWrapper.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { createStyles, makeStyles } from "@chainsafe/common-theme" -import React from "react" -import { ReactNode } from "react" - -interface IAppWrapper { - children: ReactNode | ReactNode[] -} - -const useStyles = makeStyles(() => { - return createStyles({ - root: {} - }) -}) - -const AppWrapper: React.FC = ({ children }: IAppWrapper) => { - const classes = useStyles() - - return
{children}
-} - -export default AppWrapper diff --git a/packages/chainsafex/src/Components/Pages/HomePage.tsx b/packages/chainsafex/src/Components/Pages/HomePage.tsx deleted file mode 100644 index cf47bb8c6d..0000000000 --- a/packages/chainsafex/src/Components/Pages/HomePage.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { Typography } from "@chainsafe/common-components" -import React from "react" - -const HomePage = () => { - return Home Page -} - -export default HomePage diff --git a/packages/chainsafex/src/Components/Routes.tsx b/packages/chainsafex/src/Components/Routes.tsx deleted file mode 100644 index fa81c00e51..0000000000 --- a/packages/chainsafex/src/Components/Routes.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from "react" -import { Switch, ConditionalRoute } from "@chainsafe/common-components" -import HomePage from "./Pages/HomePage" - -export const ROUTE_LINKS = { - Landing: "/" -} - -const Routes = () => { - return ( - - - - ) -} - -export default Routes diff --git a/packages/chainsafex/src/Themes/DarkTheme.ts b/packages/chainsafex/src/Themes/DarkTheme.ts deleted file mode 100644 index 7045bbe126..0000000000 --- a/packages/chainsafex/src/Themes/DarkTheme.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { createTheme } from "@chainsafe/common-theme" - -export const darkTheme = createTheme({ - themeConfig: { - palette: { - primary: { - main: "#FFF" - }, - secondary: { - main: "#000" - } - } - } -}) diff --git a/packages/chainsafex/src/Themes/LightTheme.ts b/packages/chainsafex/src/Themes/LightTheme.ts deleted file mode 100644 index 2bb193e537..0000000000 --- a/packages/chainsafex/src/Themes/LightTheme.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { createTheme } from "@chainsafe/common-theme" - -export const lightTheme = createTheme({ - themeConfig: { - palette: { - primary: { - main: "#262626", - hover: "#FFF" - }, - secondary: { - main: "#FFF", - hover: "#000" - } - }, - constants: {}, - overrides: { - Typography: {}, - Button: {} - } - } -}) diff --git a/packages/chainsafex/src/Utils/Constants.ts b/packages/chainsafex/src/Utils/Constants.ts deleted file mode 100644 index 7c13663893..0000000000 --- a/packages/chainsafex/src/Utils/Constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const placeholder = "" diff --git a/packages/common-components/package.json b/packages/common-components/package.json index 5c357b9403..c52cba5ae6 100644 --- a/packages/common-components/package.json +++ b/packages/common-components/package.json @@ -13,7 +13,7 @@ "build:storybook": "build-storybook", "build": "rollup -c", "start": "rollup -c -w", - "lint": "eslint 'src/**/*.{js,ts,tsx}' --quiet --fix" + "lint": "eslint './{src, cypress}/**/*.{js,jsx,ts,tsx}'" }, "dependencies": { "@material-ui/styles": "^4.11.2", @@ -57,11 +57,7 @@ "@types/react-blockies": "^1.4.0", "@types/react-router-dom": "^5.1.6", "@types/react-toast-notifications": "^2.4.0", - "@typescript-eslint/eslint-plugin": "^4.15.2", - "@typescript-eslint/parser": "^4.15.2", "babel-loader": "8.1.0", - "eslint": "^7.20.0", - "eslint-plugin-react": "^7.22.0", "fork-ts-checker-webpack-plugin": "^6.0.5", "formik": "^2.2.5", "react": "16.14.0", diff --git a/packages/common-components/rollup.config.js b/packages/common-components/rollup.config.js index a9cfaf3ae7..cf32c5eaa8 100644 --- a/packages/common-components/rollup.config.js +++ b/packages/common-components/rollup.config.js @@ -18,8 +18,8 @@ export default { strict: true }, plugins: [ - image(), peerDepsExternal(), + image(), resolve(), commonjs(), typescript(), diff --git a/packages/common-components/src/FileInput/FileInput.tsx b/packages/common-components/src/FileInput/FileInput.tsx index 969fb0d48c..2d83792b43 100644 --- a/packages/common-components/src/FileInput/FileInput.tsx +++ b/packages/common-components/src/FileInput/FileInput.tsx @@ -229,7 +229,7 @@ const FileInput = ({ > {file.name} */} diff --git a/packages/files-ui/src/Components/Modules/FileBrowsers/SearchFileBrowser.tsx b/packages/files-ui/src/Components/Modules/FileBrowsers/SearchFileBrowser.tsx index 6c580ff653..ad8294333a 100644 --- a/packages/files-ui/src/Components/Modules/FileBrowsers/SearchFileBrowser.tsx +++ b/packages/files-ui/src/Components/Modules/FileBrowsers/SearchFileBrowser.tsx @@ -9,7 +9,7 @@ import { getArrayOfPaths, getParentPathFromFilePath, getURISafePathFromArray } f import { ROUTE_LINKS } from "../../FilesRoutes" import { t } from "@lingui/macro" import { FileBrowserContext } from "../../../Contexts/FileBrowserContext" -import { useFilesApi } from "@chainsafe/common-contexts" +import { useFilesApi } from "../../../Contexts/FilesApiContext" const SearchFileBrowser: React.FC = ({ controls = false }: IFileBrowserModuleProps) => { const { pathname } = useLocation() diff --git a/packages/files-ui/src/Components/Modules/FileBrowsers/types.ts b/packages/files-ui/src/Components/Modules/FileBrowsers/types.ts index 48bb82c8a1..d2c3d175fa 100644 --- a/packages/files-ui/src/Components/Modules/FileBrowsers/types.ts +++ b/packages/files-ui/src/Components/Modules/FileBrowsers/types.ts @@ -13,6 +13,7 @@ export type FileOperation = | "view_folder" export type BrowserView = "grid" | "table" +export type MoveModalMode = "move" | "recover" export interface IFileBrowserModuleProps { heading?: string @@ -34,7 +35,7 @@ export interface IFilesTableBrowserProps downloadFile?: (cid: string) => Promise deleteFiles?: (cid: string[]) => Promise recoverFile?: (cid: string) => Promise - recoverFiles?: (cid: string[]) => Promise + recoverFiles?: (cid: string[], newPath: string) => Promise viewFolder?: (cid: string) => void allowDropUpload?: boolean diff --git a/packages/files-ui/src/Components/Modules/FileBrowsers/views/FileSystemItem/FileSystemItem.tsx b/packages/files-ui/src/Components/Modules/FileBrowsers/views/FileSystemItem/FileSystemItem.tsx index bb97978d0b..51ddf85f76 100644 --- a/packages/files-ui/src/Components/Modules/FileBrowsers/views/FileSystemItem/FileSystemItem.tsx +++ b/packages/files-ui/src/Components/Modules/FileBrowsers/views/FileSystemItem/FileSystemItem.tsx @@ -30,6 +30,7 @@ import FileItemTableItem from "./FileSystemTableItem" import FileItemGridItem from "./FileSystemGridItem" import { FileSystemItem as FileSystemItemType } from "../../../../../Contexts/FilesContext" import { useFileBrowser } from "../../../../../Contexts/FileBrowserContext" +import { getPathWithFile } from "../../../../../Utils/pathUtils" const useStyles = makeStyles(({ breakpoints, constants }: CSFTheme) => { return createStyles({ @@ -291,7 +292,7 @@ const FileSystemItem = ({ accept: DragTypes.MOVABLE_FILE, canDrop: () => isFolder, drop: (item: {ids: string[]}) => { - moveItems && moveItems(item.ids, `${currentPath}${name}/`) + moveItems && moveItems(item.ids, getPathWithFile(currentPath, name)) }, collect: (monitor) => ({ isOverMove: monitor.isOver() diff --git a/packages/files-ui/src/Components/Modules/FileBrowsers/views/FilesList.tsx b/packages/files-ui/src/Components/Modules/FileBrowsers/views/FilesList.tsx index 185cc775b7..6e0f73ca1e 100644 --- a/packages/files-ui/src/Components/Modules/FileBrowsers/views/FilesList.tsx +++ b/packages/files-ui/src/Components/Modules/FileBrowsers/views/FilesList.tsx @@ -32,7 +32,7 @@ import clsx from "clsx" import { plural, t, Trans } from "@lingui/macro" import { NativeTypes } from "react-dnd-html5-backend" import { useDrop } from "react-dnd" -import { BrowserView, FileOperation } from "../types" +import { BrowserView, FileOperation, MoveModalMode } from "../types" import { FileSystemItem as FileSystemItemType } from "../../../../Contexts/FilesContext" import FileSystemItem from "./FileSystemItem/FileSystemItem" import FilePreviewModal from "../../FilePreviewModal" @@ -289,7 +289,6 @@ const FilesList = () => { crumbs, renameItem: handleRename, deleteItems: deleteFiles, - recoverItems, viewFolder, currentPath, refreshContents, @@ -458,10 +457,10 @@ const FilesList = () => { const [isMoveFileModalOpen, setIsMoveFileModalOpen] = useState(false) const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false) const [isDeletingFiles, setIsDeletingFiles] = useState(false) - const [isRecoveringFiles, setIsRecoveringFiles] = useState(false) const [fileInfoPath, setFileInfoPath] = useState( undefined ) + const [moveModalMode, setMoveModalMode] = useState() const [browserView, setBrowserView] = useState("table") @@ -537,20 +536,6 @@ const FilesList = () => { }) }, [deleteFiles, selectedCids]) - const handleRecoverFiles = useCallback((e: React.MouseEvent) => { - e.preventDefault() - e.stopPropagation() - if (!recoverItems) return - - setIsRecoveringFiles(true) - recoverItems(selectedCids) - .catch(console.error) - .finally(() => { - setIsRecoveringFiles(false) - setSelectedCids([]) - }) - }, [recoverItems, selectedCids]) - const getItemOperations = useCallback( (contentType: string) => { const result = Object.keys(itemOperations).reduce( @@ -745,7 +730,10 @@ const FilesList = () => { <> {validBulkOps.indexOf("move") >= 0 && ( @@ -909,12 +899,17 @@ const FilesList = () => { moveFile={() => { setSelectedCids([file.cid]) setIsMoveFileModalOpen(true) + setMoveModalMode("move") }} setFileInfoPath={setFileInfoPath} itemOperations={getItemOperations(file.content_type)} resetSelectedFiles={resetSelectedCids} browserView="table" - recoverFile={() => recoverItems && recoverItems([file.cid])} + recoverFile={() => { + setSelectedCids([file.cid]) + setIsMoveFileModalOpen(true) + setMoveModalMode("recover") + }} /> ))} @@ -951,10 +946,16 @@ const FilesList = () => { moveFile={() => { setSelectedCids([file.cid]) setIsMoveFileModalOpen(true) + setMoveModalMode("move") }} setFileInfoPath={setFileInfoPath} itemOperations={getItemOperations(file.content_type)} resetSelectedFiles={resetSelectedCids} + recoverFile={() => { + setSelectedCids([file.cid]) + setIsMoveFileModalOpen(true) + setMoveModalMode("recover") + }} browserView="grid" /> ))} @@ -1010,8 +1011,13 @@ const FilesList = () => { onClose={() => { setIsMoveFileModalOpen(false) setSelectedCids([]) + setMoveModalMode(undefined) + }} + onCancel={() => { + setIsMoveFileModalOpen(false) + setMoveModalMode(undefined) }} - onCancel={() => setIsMoveFileModalOpen(false)} + mode={moveModalMode} /> ) diff --git a/packages/files-ui/src/Components/Modules/LoginModule/AuthenticationFactors.tsx b/packages/files-ui/src/Components/Modules/LoginModule/AuthenticationFactors.tsx index a79feddf2b..ae91c195f9 100644 --- a/packages/files-ui/src/Components/Modules/LoginModule/AuthenticationFactors.tsx +++ b/packages/files-ui/src/Components/Modules/LoginModule/AuthenticationFactors.tsx @@ -235,7 +235,7 @@ const AuthenticationFactors = ({ goToComplete, goToMnemonic, goToPassword, goToS
- Backup phrase + Backup secret phrase { diff --git a/packages/files-ui/src/Components/Modules/LoginModule/Complete.tsx b/packages/files-ui/src/Components/Modules/LoginModule/Complete.tsx index 0d62a5a9ba..db59fe7b49 100644 --- a/packages/files-ui/src/Components/Modules/LoginModule/Complete.tsx +++ b/packages/files-ui/src/Components/Modules/LoginModule/Complete.tsx @@ -154,7 +154,7 @@ const Complete = ({ className }: IComplete) => { {hasMnemonicShare &&
- Backup phrase + Backup secret phrase diff --git a/packages/files-ui/src/Components/Modules/LoginModule/InitialScreen.tsx b/packages/files-ui/src/Components/Modules/LoginModule/InitialScreen.tsx index ab454167e2..43f1972f38 100644 --- a/packages/files-ui/src/Components/Modules/LoginModule/InitialScreen.tsx +++ b/packages/files-ui/src/Components/Modules/LoginModule/InitialScreen.tsx @@ -1,15 +1,16 @@ import React, { useState } from "react" -import { Button, FacebookLogoIcon, GithubLogoIcon, GoogleLogoIcon, Loading, Typography } from "@chainsafe/common-components" +import { Button, FacebookLogoIcon, GithubLogoIcon, MailIcon, GoogleLogoIcon, Loading, Typography } from "@chainsafe/common-components" import { createStyles, makeStyles, useThemeSwitcher } from "@chainsafe/common-theme" import { CSFTheme } from "../../../Themes/types" import { t, Trans } from "@lingui/macro" -import { useFilesApi } from "@chainsafe/common-contexts" +import { useFilesApi } from "../../../Contexts/FilesApiContext" import { useWeb3 } from "@chainsafe/web3-context" import { useThresholdKey } from "../../../Contexts/ThresholdKeyContext" import { LOGIN_TYPE } from "@toruslabs/torus-direct-web-sdk" import { ROUTE_LINKS } from "../../FilesRoutes" import clsx from "clsx" import { IdentityProvider } from "@chainsafe/files-api-client" +import PasswordlessEmail from "./PasswordlessEmail" const useStyles = makeStyles( ({ constants, palette, breakpoints, typography }: CSFTheme) => @@ -141,7 +142,7 @@ const InitialScreen = ({ className }: IInitialScreen) => { const { wallet } = useWeb3() const { login, status, resetStatus } = useThresholdKey() const classes = useStyles() - const [loginMode, setLoginMode] = useState<"web3" | LOGIN_TYPE | undefined>() + const [loginMode, setLoginMode] = useState<"web3" | "email" | LOGIN_TYPE | undefined>() const [error, setError] = useState() const maintenanceMode = process.env.REACT_APP_MAINTENANCE_MODE === "true" const [isConnecting, setIsConnecting] = useState(false) @@ -201,222 +202,232 @@ const InitialScreen = ({ className }: IInitialScreen) => { setIsConnecting(false) } + const ConnectWallet = () => { + if (!wallet) { + console.error("No wallet found") + return null + } + + return ( +
+
+ + +
+ + Go back + +
+
+
+
+ )} + + const WalletConnection = () => { + return ( +
+ Connect Wallet to Files + {status === "awaiting confirmation" && + + You will need to sign a message in your wallet to complete sign in. + } + {status === "logging in" && <> + + Hold on, we are logging you in... + + + } +
+ ) + } + + const WalletSelection = () => { + return ( + <> +
+ + +
+
+ + ) + } + const Footer = () => ( ) return (
- { - ((desktop && !isConnecting && !error) || (isConnecting && loginMode !== "web3")) && ( - - - Get Started - - - ) - } - { - !error ? - loginMode !== "web3" ? ( - <> -
- {maintenanceMode && ( - - - The system is undergoing maintenance, thank you for being patient. - - - )} - - - - -
- - - ) : ( - wallet ? - !isConnecting ? ( - <> -
- - -
- Go back -
-
-
- - ) : ( - <> -
- Connect Wallet to Files - {status === "awaiting confirmation" && - - You will need to sign a message in your wallet to complete sign in. - } - {status === "logging in" && <> - - Hold on, we are logging you in... - - - } -
- - ) - : <> -
- - -
-
- - ) : ( - <> -
- Connection failed - - {error} + {loginMode !== "email" && ((desktop && !isConnecting && !error) || (isConnecting && loginMode !== "web3")) && ( + + Get Started + + )} + {!error && ( + loginMode !== "web3" && loginMode !== "email" + ? <> +
+ {maintenanceMode && ( + + The system is undergoing maintenance, thank you for being patient. - -
- - ) - } + )} + + + + +
+ + + : loginMode === "email" + ? + : wallet + ? !isConnecting + ? + : + : + )} + {!!error && ( + <> +
+ + Connection failed + + + {error} + + +
+ + )}
) } diff --git a/packages/files-ui/src/Components/Modules/LoginModule/MigrateAccount.tsx b/packages/files-ui/src/Components/Modules/LoginModule/MigrateAccount.tsx index 1965afe09e..64cb8718ad 100644 --- a/packages/files-ui/src/Components/Modules/LoginModule/MigrateAccount.tsx +++ b/packages/files-ui/src/Components/Modules/LoginModule/MigrateAccount.tsx @@ -7,7 +7,7 @@ import { } from "@chainsafe/common-components" import clsx from "clsx" import { useFiles } from "../../../Contexts/FilesContext" -import { useFilesApi } from "@chainsafe/common-contexts" +import { useFilesApi } from "../../../Contexts/FilesApiContext" import { useThresholdKey } from "../../../Contexts/ThresholdKeyContext" import ConciseExplainer from "./ConciseExplainer" import { CSFTheme } from "../../../Themes/types" diff --git a/packages/files-ui/src/Components/Modules/LoginModule/MissingShares.tsx b/packages/files-ui/src/Components/Modules/LoginModule/MissingShares.tsx index 2cc26b2a1f..9313bd28ac 100644 --- a/packages/files-ui/src/Components/Modules/LoginModule/MissingShares.tsx +++ b/packages/files-ui/src/Components/Modules/LoginModule/MissingShares.tsx @@ -142,7 +142,7 @@ const MissingShares = ({ className }: IMissingShares) => { inputMnemonicShare(mnemonic) .catch(() => { setIsLoading(false) - setError(t`Backup phrase does not match user account, please double-check and try again.`) + setError(t`Backup secret phrase does not match user account, please double-check and try again.`) }) } @@ -200,7 +200,7 @@ const MissingShares = ({ className }: IMissingShares) => { size="large" onClick={() => setWithMnemonic(true)} > - Restore with backup phrase + Restore with backup secret phrase
@@ -242,7 +242,7 @@ const MissingShares = ({ className }: IMissingShares) => { {withMnemonic && (
- Enter backup phrase: + Enter backup secret phrase: