Skip to content

Commit

Permalink
feat(Information Overlay Added): Retrieves latest release information…
Browse files Browse the repository at this point in the history
… from GitHub, e2e tests added.
  • Loading branch information
thomas-gale committed Mar 30, 2020
1 parent edfbd14 commit 7ea610a
Show file tree
Hide file tree
Showing 6 changed files with 348 additions and 15 deletions.
4 changes: 2 additions & 2 deletions cypress/integration/information/overlay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ context('Factory', () => {

it('view information overview', () => {
cy.get('[aria-label="info"]').click();
cy.get('.MuiBox-root > .MuiTypography-root');
cy.get('[id="InformationOverlay"]');
});

it('dismiss information overview', () => {
cy.get('[aria-label="info"]').click();
cy.get('.MuiBackdrop-root').click('left');
cy.get('[id="InformationOverlay"]').click('left');
cy.get('canvas').click();
});
});
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
"@types/redux-saga": "^0.10.5",
"@types/uuid": "^7.0.0",
"acorn": "^7.1.1",
"axios": "^0.19.2",
"gh-pages": "^2.2.0",
"minimist": "^1.2.2",
"normalizr": "^3.6.0",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-markdown": "^4.3.1",
"react-redux": "^7.2.0",
"react-scripts": "^3.4.1",
"react-sizeme": "^2.6.12",
Expand Down
4 changes: 4 additions & 0 deletions src/env/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ export const config = {
topNav: {
gitHubURL: 'https://github.com/ThomasGale/bits-to-atoms',
},
information: {
gitHubAPILatestReleaseEndPoint:
'https://api.github.com/repos/thomasgale/bits-to-atoms/releases/latest',
},
market: {
simpleMarketSaga: {
partNames: [
Expand Down
4 changes: 4 additions & 0 deletions src/store/information/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface GitHubLatestReleaseAPIResponse {
name: string;
body: string;
}
43 changes: 37 additions & 6 deletions src/views/components/information/InformationOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
import { Box, Typography } from '@material-ui/core';
import React from 'react';
import { Card, makeStyles } from '@material-ui/core';
import axios from 'axios';
import React, { useEffect, useState } from 'react';
import ReactMarkdown from 'react-markdown';
import { config } from '../../../env/config';
import { GitHubLatestReleaseAPIResponse } from '../../../store/information/types';

const useStyles = makeStyles((theme) => ({
InformationOverlay: {
width: '50%',
padding: theme.spacing(2),
},
}));

export function InformationOverlay() {
const classes = useStyles();
const [info, setInfo] = useState('Retriving release information...');

useEffect(() => {
const fetchData = async () => {
const result = await axios(
config.information.gitHubAPILatestReleaseEndPoint
);
if (result.status === 200) {
const releaseResponse = result.data as GitHubLatestReleaseAPIResponse;
setInfo(releaseResponse.body);
} else {
setInfo(
`Unabled to get release information :( (status: ${result.status})`
);
}
};
fetchData();
}, []);

export function InformationOverlay(): JSX.Element {
return (
<Box>
<Typography>Markdown Formatted Release Information</Typography>
</Box>
<Card id="InformationOverlay" className={classes.InformationOverlay}>
<ReactMarkdown source={info} />
</Card>
);
}
Loading

0 comments on commit 7ea610a

Please sign in to comment.