Skip to content

Commit

Permalink
feat: add checkRepoTab
Browse files Browse the repository at this point in the history
  • Loading branch information
gjgd committed Jun 28, 2020
1 parent e35d01c commit 098cf03
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 8 deletions.
67 changes: 67 additions & 0 deletions packages/app/src/components/CheckRepoTab.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React from 'react';
// import LinearProgress from '@material-ui/core/LinearProgress';
import { makeStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
// import { Alert, AlertTitle } from '@material-ui/lab';
import { getFiles } from 'jsonld-checker';
// import ResultTable from './ResultTable';
import { getQueryParameter, updateQueryParameter } from '../utils';
import LoaderButton from './LoaderButton';

const useStyles = makeStyles((theme) => ({
root: {
display: 'flex',
flexWrap: 'wrap',
},
progressBar: {
width: '100%',
marginTop: theme.spacing(2),
marginBottom: theme.spacing(2),
},
}));

const CheckRepoTab: React.FunctionComponent<{}> = () => {
const classes = useStyles();

const [repo, setRepo] = React.useState(() => {
const repoQueryParameter = getQueryParameter('repo');
if (repoQueryParameter) {
return decodeURIComponent(repoQueryParameter);
}
return 'https://github.com/transmute-industries/universal-wallet';
});
const [files, setFiles] = React.useState<Array<{ path: string }>>([]);
console.log(files);

React.useEffect(() => {
updateQueryParameter('repo', repo);
}, [repo]);

const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setRepo(event.target.value);
};

const onClick = async () => {
const filesInRepo = await getFiles('gjgd', 'jsonld-checker');
setFiles(filesInRepo);
};

return (
<div className={classes.root}>
<LoaderButton onClick={onClick} buttonText="Check Repo" />
<TextField
label="Enter the URL of a Github repo"
onChange={onChange}
defaultValue={repo}
style={{ margin: 8 }}
fullWidth
margin="normal"
/>
{files.map((file) => (
<div>{file.path}</div>
))}
</div>
);
};

export default CheckRepoTab;
13 changes: 5 additions & 8 deletions packages/app/src/components/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Tab from '@material-ui/core/Tab';
import Box from '@material-ui/core/Box';
import CheckJsonTab from './CheckJsonTab';
import CheckFileTab from './CheckFileTab';
import CheckRepoTab from './CheckRepoTab';
import { updateQueryParameter, getQueryParameter } from '../utils';

type TabPanelProps = {
Expand Down Expand Up @@ -50,8 +51,8 @@ export default function SimpleTabs() {
let defaultTab: number;
if (tabQueryParameter) {
defaultTab = Number.parseInt(tabQueryParameter, 10);
if (defaultTab > 1) {
defaultTab = 1;
if (defaultTab > 2) {
defaultTab = 0;
}
} else {
defaultTab = 0;
Expand All @@ -60,11 +61,7 @@ export default function SimpleTabs() {
});

const handleChange = (event: ChangeEvent<{}>, newTab: number) => {
if (newTab === 2) {
alert('Not implemented yet');
} else {
setTab(newTab);
}
setTab(newTab);
};

React.useEffect(() => {
Expand All @@ -87,7 +84,7 @@ export default function SimpleTabs() {
<CheckFileTab />
</TabPanel>
<TabPanel value={tab} index={2}>
<div>TODO</div>
<CheckRepoTab />
</TabPanel>
</div>
);
Expand Down

0 comments on commit 098cf03

Please sign in to comment.