Skip to content

Commit

Permalink
Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
brockfanning committed Oct 4, 2023
1 parent 57110ee commit 8df0d28
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
11 changes: 11 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import { JsonForms } from '@jsonforms/react';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import DownloadButton from './DownloadButton';
import GoToRepositoryButton from './GoToRepositoryButton';
import GithubLoginButton from './GithubLoginButton';
import GithubPushButton from './GithubPushButton';
import GroupWithDescription, {
Expand Down Expand Up @@ -117,7 +118,10 @@ const App = () => {
githubProxyUrl,
githubRepo,
githubOwner,
repoUrl,
repositoryLink,
} = opensdg.configForm;
console.log(opensdg.configForm);
const [formData, setFormData] = useState(initialData);
const [formErrors, setFormErrors] = useState(null);
const jsonformsConfig = {
Expand All @@ -130,6 +134,7 @@ const App = () => {
formData={formData}
formErrors={formErrors}
filename={configFilename}
uiSchema={uiSchema}
/>
{ githubClientId && githubProxyUrl &&
<GithubLoginButton
Expand All @@ -147,6 +152,12 @@ const App = () => {
githubOwner={githubOwner}
/>
}
{ !githubClientId && !githubProxyUrl && repoUrl && repositoryLink &&
<GoToRepositoryButton
repoUrl={repoUrl}
repositoryLink={repositoryLink}
/>
}
<div style={{display: 'flex'}}>
<ThemeProvider theme={theme}>
<JsonForms
Expand Down
3 changes: 3 additions & 0 deletions src/DownloadButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ const DownloadButton = (props) => {
if (formErrors.length > 0) {
const errorMessages = formErrors.map((error) => '- ' + error.parentSchema.title + ': ' + error.message);
let message = 'Please correct the following errors: \n';
console.log(formData, 'formData');
console.log(formErrors, 'formErrors');
alert(message + errorMessages.join('\n'));
}
else {
alert('After downloading the file, click "Go to repository" and then upload the file there.');
const yaml = dump(formData);
saveAsFile(yaml, filename, 'text/plain;charset=utf-8');
}
Expand Down
3 changes: 0 additions & 3 deletions src/FlatArrayWithDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export const FlatArrayWithDescription = (props) => {
const [rowData, setRowData] = useState(undefined);
const { removeItems, visible } = props;

console.log('here');

const openDeleteDialog = useCallback((p, rowIndex) => {
setOpen(true);
setPath(p);
Expand All @@ -25,7 +23,6 @@ export const FlatArrayWithDescription = (props) => {
}, [setOpen, path, rowData]);
const deleteClose = useCallback(() => setOpen(false), [setOpen]);

console.log(props, 'props in ObjectArrayWithDescription');
return (
<Hidden xsUp={!visible}>
<MaterialTableControl
Expand Down
16 changes: 16 additions & 0 deletions src/GoToRepositoryButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { Button } from '@mui/material';

const GoToRepositoryButton = (props) => {
const { repoUrl, repositoryLink } = props;
const clickHandler = (e) => {
window.open(repoUrl + repositoryLink, '_blank').focus();
}
return (
<Button sx={{ mt:2, mb:2, mr: 2 }} variant="contained" onClick={clickHandler}>
Go to repository
</Button>
)
}

export default GoToRepositoryButton;
23 changes: 2 additions & 21 deletions src/GroupWithDescription.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import {
Card,
CardContent,
CardHeader,
CardActions,
Link,
Tooltip,
IconButton,
Hidden
Hidden,
} from '@mui/material';
import HelpIcon from '@mui/icons-material/Help';
import {
Expand All @@ -25,30 +21,15 @@ export const groupTester = rankWith(2, uiTypeIs('Group'));
const style = { marginBottom: '10px' };

const GroupWithDescriptionComponent = React.memo(({ visible, enabled, uischema, label, ...props }) => {
let link, linkText;
const description = props.schema.description;
if (props.schema.links && props.schema.links.length > 0) {
link = props.schema.links[0].href;
linkText = props.schema.links[0].rel;
}

return (
<Hidden xsUp={!visible}>
<Card style={style}>
{!isEmpty(label) && (
<CardHeader
title={label}
action={(
<Tooltip title={description}>
<IconButton
aria-label={linkText + ' (opens in a new tab)'}
href={link}
target="_blank"
>
<HelpIcon />
</IconButton>
</Tooltip>
)}
subheader={description}
/>
)}
<CardContent>
Expand Down

0 comments on commit 8df0d28

Please sign in to comment.