diff --git a/packages/common-components/src/index.ts b/packages/common-components/src/index.ts index 8684f17bf5..a6d8a17044 100644 --- a/packages/common-components/src/index.ts +++ b/packages/common-components/src/index.ts @@ -20,6 +20,7 @@ export * from "./Icons" export * from "./Modal" export * from "./NumberInput" export * from "./MenuDropdown" +export * from "./Paper" export * from "./ProgressBar" export * from "./RadioInput" export * from "./Router" diff --git a/packages/gaming-ui/src/Components/Elements/ApiKeyCard.tsx b/packages/gaming-ui/src/Components/Elements/ApiKeyCard.tsx new file mode 100644 index 0000000000..db489b7d8b --- /dev/null +++ b/packages/gaming-ui/src/Components/Elements/ApiKeyCard.tsx @@ -0,0 +1,86 @@ +import React from "react" +import { AccessKey } from "@chainsafe/files-api-client" +import { makeStyles, createStyles } from "@chainsafe/common-theme" +import { CSGTheme } from "../../Themes/types" +import { Button, Typography, Paper } from "@chainsafe/common-components" +import { Trans } from "@lingui/macro" +import dayjs from "dayjs" + + +const useStyles = makeStyles(({ constants }: CSGTheme) => + createStyles({ + root: { + position: "relative", + margin: constants.generalUnit, + borderRadius: constants.generalUnit / 2, + maxWidth: 250, + padding: `${constants.generalUnit * 2}px ${constants.generalUnit}px` + }, + button: { + marginTop: constants.generalUnit * 2 + } + }) +) + +interface IApiKeyCard { + apiKey: AccessKey + deleteKey: () => void +} + +const ApiKeyCard = ({ apiKey, deleteKey }: IApiKeyCard) => { + const classes = useStyles() + + return ( + + + + Id: + + + + { apiKey.id } + + + + Status: + + + + { apiKey.status } + + + + Created on: + + + + { dayjs(apiKey.created_at).format("DD MMM YYYY h:mm a") } + + + + ) +} + +export default ApiKeyCard \ No newline at end of file diff --git a/packages/gaming-ui/src/Components/GamingRoutes.tsx b/packages/gaming-ui/src/Components/GamingRoutes.tsx index 45b6928323..3936871e6b 100644 --- a/packages/gaming-ui/src/Components/GamingRoutes.tsx +++ b/packages/gaming-ui/src/Components/GamingRoutes.tsx @@ -31,7 +31,9 @@ const GamingRoutes = () => { /> diff --git a/packages/gaming-ui/src/Components/Layouts/AppNav.tsx b/packages/gaming-ui/src/Components/Layouts/AppNav.tsx index b312cb4e21..7746860bf1 100644 --- a/packages/gaming-ui/src/Components/Layouts/AppNav.tsx +++ b/packages/gaming-ui/src/Components/Layouts/AppNav.tsx @@ -9,10 +9,7 @@ import { Link, Typography, PowerDownSvg, - // ProgressBar, - // formatBytes, - ChainsafeLogo, - SettingSvg + ChainsafeLogo } from "@chainsafe/common-components" import { ROUTE_LINKS } from "../GamingRoutes" import { Trans } from "@lingui/macro" @@ -240,39 +237,9 @@ const AppNav: React.FC = ({ navOpen, setNavOpen }: IAppNav) => { )}
- {desktop && ( -
- {/* {`${formatBytes(spaceUsed, 2)} of ${formatBytes( - FREE_PLAN_LIMIT, 2 - )} used`} - */} -
- )} {!desktop && (
+const useStyles = makeStyles(({ breakpoints, constants, palette, zIndex }: CSGTheme) => createStyles({ root: { - position: "relative" + position: "relative", + margin: constants.generalUnit }, header: { display: "flex", @@ -48,41 +31,30 @@ const useStyles = makeStyles(({ constants, breakpoints, animation, zIndex, palet marginLeft: constants.generalUnit } }, - tableHead: { - marginTop: 24 - }, - tableRow: { - border: "2px solid transparent", - transitionDuration: `${animation.transform}ms`, - [breakpoints.up("md")]: { - gridTemplateColumns: desktopGridSettings - }, - [breakpoints.down("md")]: { - gridTemplateColumns: mobileGridSettings - } - }, - 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: { + dataArea: { + marginTop: constants.generalUnit * 2, display: "flex", - justifyContent: "center", - alignItems: "center", - width: 20, - marginRight: constants.generalUnit * 1.5, - "& svg": { - fill: constants.fileSystemItemRow.menuIcon + flexDirection: "row", + justifyContent: "space-between", + flexWrap: "wrap", + "& > *": { + margin: constants.generalUnit, + width:"100%", + [breakpoints.up("xs")]: { + maxWidth: `calc(100% - ${constants.generalUnit * 2}px)` + }, + [breakpoints.up("sm")]: { + maxWidth: `calc(50% - ${constants.generalUnit * 2}px)` + }, + [breakpoints.up("md")]: { + maxWidth: `calc(33% - ${constants.generalUnit * 2}px)` + }, + [breakpoints.up("lg")]: { + maxWidth: `calc(25% - ${constants.generalUnit * 2}px)` + }, + [breakpoints.up("xl")]: { + maxWidth: `calc(20% - ${constants.generalUnit * 2}px)` + } } }, modalRoot: { @@ -137,7 +109,7 @@ const useStyles = makeStyles(({ constants, breakpoints, animation, zIndex, palet }) ) -const ApiKeys = () => { +const DashboardModule = () => { const classes = useStyles() const { gamingApiClient } = useGamingApi() const [keys, setKeys] = useState([]) @@ -161,15 +133,17 @@ const ApiKeys = () => { const fetchAccessKeys = useCallback(() => { gamingApiClient.listAccessKeys() - .then(setKeys) + .then(keys => setKeys(keys.filter(key => key.type === "gaming"))) .catch(console.error) }, [gamingApiClient]) - const createStorageAccessKey = useCallback(() => { + const createGamingAccessKey = useCallback(() => { gamingApiClient.createAccessKey({ type: "gaming" }) - .then(setNewKey) - .then(fetchAccessKeys) - .then(() => setIsNewKeyModalOpen(true)) + .then((key) => { + setNewKey(key) + fetchAccessKeys() + setIsNewKeyModalOpen(true) + }) .catch(console.error) }, [fetchAccessKeys, gamingApiClient]) @@ -193,16 +167,16 @@ const ApiKeys = () => { data-cy="api-keys-header" > - API Keys + Dashboard
- - - - - Id - - - Type - - - Status - - - Created At - - {/* Menu */} - - - - {keys.map(k => - - - - {k.id} - - - - - {k.type} - - - - - {k.status} - - - - - {dayjs(k.created_at).format("DD MMM YYYY h:mm a")} - - - - - - - Delete Key - - - ), - onClick: () => deleteAccessKey(k.id) - }]} - classNames={{ - icon: classes.dropdownIcon, - options: classes.dropdownOptions, - item: classes.dropdownItem - }} - indicator={MoreIcon} - /> - - )} - -
+
+ { + keys.map((key: AccessKey, index: number) => ( + deleteAccessKey(key.id)} + apiKey={key} />)) + } +
{
- + Make sure to save the secret, as it can only be displayed once. {copiedSecret && ( @@ -351,13 +247,12 @@ const ApiKeys = () => {
@@ -365,4 +260,4 @@ const ApiKeys = () => { ) } -export default ApiKeys +export default DashboardModule \ No newline at end of file diff --git a/packages/gaming-ui/src/Components/Pages/DashboardPage.tsx b/packages/gaming-ui/src/Components/Pages/DashboardPage.tsx index 8a3df055c5..2cd132244a 100644 --- a/packages/gaming-ui/src/Components/Pages/DashboardPage.tsx +++ b/packages/gaming-ui/src/Components/Pages/DashboardPage.tsx @@ -1,27 +1,10 @@ import React from "react" -import { makeStyles, createStyles } from "@chainsafe/common-theme" -import { Typography } from "@chainsafe/common-components" - -const useStyles = makeStyles(() => - createStyles({ - root: { - position: "relative" - } - }) -) +import DashboardModule from "../Modules/DashboardModule" const DashboardPage = () => { - const classes = useStyles() return ( -
- - Dashboard - -
+ ) } diff --git a/packages/gaming-ui/src/Components/Pages/SettingsPage.tsx b/packages/gaming-ui/src/Components/Pages/SettingsPage.tsx index d7aa60c146..e1ab8bb179 100644 --- a/packages/gaming-ui/src/Components/Pages/SettingsPage.tsx +++ b/packages/gaming-ui/src/Components/Pages/SettingsPage.tsx @@ -1,21 +1,17 @@ import React, { useCallback } from "react" import { Tabs, - TabPane as TabPaneOrigin, + // TabPane as TabPaneOrigin, Typography, Divider, useParams, - useHistory, - ITabPaneProps, - CaretRightIcon, - LockIcon + useHistory } from "@chainsafe/common-components" import { makeStyles, createStyles, useThemeSwitcher } from "@chainsafe/common-theme" import { ROUTE_LINKS, SettingsPath } from "../GamingRoutes" -import { t, Trans } from "@lingui/macro" +import { Trans } from "@lingui/macro" import clsx from "clsx" -import ApiKeys from "../Modules/ApiKeys" import { CSGTheme } from "../../Themes/types" -const TabPane = (props: ITabPaneProps) => TabPaneOrigin(props) +// const TabPane = (props: ITabPaneProps) => TabPaneOrigin(props) const useStyles = makeStyles(({ constants, breakpoints, palette }: CSGTheme) => createStyles({ title: { @@ -165,16 +161,6 @@ const SettingsPage: React.FC = () => { classes.injectedTabList) }} > - } - iconRight={} - title={t`Api Keys`} - tabKey="apiKeys" - testId="apiKeys-tab" - > - - } diff --git a/packages/gaming-ui/src/locales/en/messages.po b/packages/gaming-ui/src/locales/en/messages.po index e314e4a4a9..4c44a4d96d 100644 --- a/packages/gaming-ui/src/locales/en/messages.po +++ b/packages/gaming-ui/src/locales/en/messages.po @@ -13,21 +13,18 @@ msgstr "" "Language-Team: \n" "Plural-Forms: \n" -msgid "API Keys" -msgstr "API Keys" - msgid "Add API Key" msgstr "Add API Key" -msgid "Api Keys" -msgstr "Api Keys" - msgid "By connecting your wallet, you agree to our <0>Terms of Service and <1>Privacy Policy" msgstr "By connecting your wallet, you agree to our <0>Terms of Service and <1>Privacy Policy" msgid "Check your inbox! We've sent another email." msgstr "Check your inbox! We've sent another email." +msgid "Close" +msgstr "Close" + msgid "Connect Wallet to Gaming" msgstr "Connect Wallet to Gaming" @@ -55,11 +52,14 @@ msgstr "Continue with Web3 Wallet" msgid "Copied!" msgstr "Copied!" -msgid "Created At" -msgstr "Created At" +msgid "Created on:" +msgstr "Created on:" -msgid "Delete Key" -msgstr "Delete Key" +msgid "Dashboard" +msgstr "Dashboard" + +msgid "Delete key" +msgstr "Delete key" msgid "Didn't receive the email ?" msgstr "Didn't receive the email ?" @@ -94,8 +94,8 @@ msgstr "Go back" msgid "Hold on, we are logging you in…" msgstr "Hold on, we are logging you in…" -msgid "Id" -msgstr "Id" +msgid "Id:" +msgstr "Id:" msgid "Key ID" msgstr "Key ID" @@ -142,8 +142,8 @@ msgstr "Something went wrong!" msgid "Something went wrong! Please try again." msgstr "Something went wrong! Please try again." -msgid "Status" -msgstr "Status" +msgid "Status:" +msgstr "Status:" msgid "Terms and Conditions" msgstr "Terms and Conditions" @@ -163,9 +163,6 @@ msgstr "There was an error connecting your wallet" msgid "Try again" msgstr "Try again" -msgid "Type" -msgstr "Type" - msgid "Use a different login method" msgstr "Use a different login method" diff --git a/packages/storage-ui/src/Components/Modules/ApiKeys.tsx b/packages/storage-ui/src/Components/Modules/ApiKeys.tsx index 7a5a9abb2f..2835108dc0 100644 --- a/packages/storage-ui/src/Components/Modules/ApiKeys.tsx +++ b/packages/storage-ui/src/Components/Modules/ApiKeys.tsx @@ -347,7 +347,7 @@ const ApiKeys = () => {
- + Make sure to save the secret, as it can only be displayed once. {copiedSecret && (