Skip to content

Commit

Permalink
Gaming dashboard - API keys as cards (#1575)
Browse files Browse the repository at this point in the history
* Dashboard cards done

* lingui extract

* extra padding

* Apply suggestions from code review

Co-authored-by: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com>

* lingui extract

* Feedback

* Removed link

* Apply suggestions from code review

* Made warning bigger

* lingui extract

Co-authored-by: GitHub Actions <actions@github.com>
Co-authored-by: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com>
Co-authored-by: Michael Yankelev <12774278+FSM1@users.noreply.github.com>
  • Loading branch information
4 people committed Sep 28, 2021
1 parent e049d76 commit 5d3ac19
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 253 deletions.
1 change: 1 addition & 0 deletions packages/common-components/src/index.ts
Expand Up @@ -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"
Expand Down
86 changes: 86 additions & 0 deletions 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 (
<Paper className={classes.root}>
<Typography variant="h4"
component="h4">
<Trans>
Id:
</Trans>
</Typography>
<Typography
variant="body1"
component="p"
>
{ apiKey.id }
</Typography>
<Typography variant="h4"
component="h4">
<Trans>
Status:
</Trans>
</Typography>
<Typography
variant="body1"
component="p">
{ apiKey.status }
</Typography>
<Typography
variant="h4"
component="h4"
>
<Trans>
Created on:
</Trans>
</Typography>
<Typography
variant="body1"
component="p"
>
{ dayjs(apiKey.created_at).format("DD MMM YYYY h:mm a") }
</Typography>
<Button
className={classes.button}
variant="secondary"
fullsize={true}
onClick={deleteKey}
>
<Trans>
Delete key
</Trans>
</Button>
</Paper>
)
}

export default ApiKeyCard
4 changes: 3 additions & 1 deletion packages/gaming-ui/src/Components/GamingRoutes.tsx
Expand Up @@ -31,7 +31,9 @@ const GamingRoutes = () => {
/>
<ConditionalRoute
path={ROUTE_LINKS.SettingsRoot}
isAuthorized={isLoggedIn}
isAuthorized={false}
// Settings not required yet
// isAuthorized={isLoggedIn}
component={SettingsPage}
redirectPath={ROUTE_LINKS.Landing}
/>
Expand Down
35 changes: 1 addition & 34 deletions packages/gaming-ui/src/Components/Layouts/AppNav.tsx
Expand Up @@ -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"
Expand Down Expand Up @@ -240,39 +237,9 @@ const AppNav: React.FC<IAppNav> = ({ navOpen, setNavOpen }: IAppNav) => {
)}
<div className={classes.linksArea}>
<nav className={classes.navMenu}>
<Link
data-cy="settings-nav"
onClick={handleOnClick}
className={classes.navItem}
to={ROUTE_LINKS.SettingsRoot}
>
<SettingSvg />
<Typography
variant="h5"
className={classes.navItemText}
>
<Trans>Settings</Trans>
</Typography>
</Link>
</nav>
</div>
<section>
{desktop && (
<div>
{/* <Typography
variant="body2"
className={classes.spaceUsedMargin}
component="p"
>{`${formatBytes(spaceUsed, 2)} of ${formatBytes(
FREE_PLAN_LIMIT, 2
)} used`}</Typography>
<ProgressBar
className={classes.spaceUsedMargin}
progress={(spaceUsed / FREE_PLAN_LIMIT) * 100}
size="small"
/> */}
</div>
)}
{!desktop && (
<div
className={classes.navItem}
Expand Down

0 comments on commit 5d3ac19

Please sign in to comment.