Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Central_v2] - Merge backend changes #1232

Open
wants to merge 89 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
dac8013
auth updates
drewjhart Mar 4, 2024
753198b
auth updates
drewjhart Mar 11, 2024
b3b6e42
Merge branch 'dev' into drew-hart--backend-auth
drewjhart Mar 29, 2024
92d3dac
new auth
drewjhart Apr 1, 2024
6849c04
new dev env
drewjhart Apr 1, 2024
a0f12d8
fixes auth issue
drewjhart Apr 1, 2024
5999a38
initial setup
drewjhart Apr 1, 2024
3cf212d
adds authorization entirely to networking via authapiclient
drewjhart Apr 1, 2024
064817c
apiclient updates
drewjhart Apr 4, 2024
923f88f
unauthorized user not wokring
drewjhart Apr 4, 2024
017a267
update for test env
drewjhart Apr 18, 2024
0c5e57d
updates auth for guest and login
drewjhart Apr 24, 2024
0e4be2a
upgrades networking amplify from v5 to v6
drewjhart Apr 24, 2024
0e2b4ab
removes commented code from BaseAPIClient
drewjhart Apr 24, 2024
d2a3a28
federated signin now works
drewjhart Apr 24, 2024
c232b9d
fixes federated signin
drewjhart Apr 25, 2024
348e9c8
updates central aws-amplify from v5 to v6
drewjhart Apr 25, 2024
007af63
Merge branch 'drew-hart--amplify-v5-to-v6' into drew-hart--auth-feder…
drewjhart Apr 25, 2024
bf8b8c7
adds hub listener to track when federated signin occurs
drewjhart Apr 25, 2024
1b7c2f3
federated signin setup
drewjhart Apr 26, 2024
ab3ec82
move central auth to apiclients
drewjhart Apr 26, 2024
05155e6
moves auth from apiclient to authapiclient
drewjhart Apr 26, 2024
15d08c7
removes aws-amplify from all apps except networking
drewjhart Apr 29, 2024
b1d5ec4
updates apiclients and authclinet
drewjhart May 1, 2024
54afd83
auth troubleshooting
drewjhart May 3, 2024
67499b7
fixes updateGameSession mutation
drewjhart May 6, 2024
99d9b2f
update app apiclients for play
drewjhart May 7, 2024
92697dc
fixes auth on mutations and subscriptions
drewjhart May 8, 2024
11b1e97
clean up
drewjhart May 8, 2024
8ee7252
formatting
drewjhart May 8, 2024
a67b15c
formatting
drewjhart May 9, 2024
7dce8fc
formatting
drewjhart May 9, 2024
537ff0b
formatting
drewjhart May 9, 2024
8bbe844
formatting
drewjhart May 9, 2024
34fa94b
formatting
drewjhart May 9, 2024
5fcfed1
Merge branch 'dev' into drew-hart--central_v2-setup
drewjhart May 9, 2024
adfef19
Merge branch 'drew-hart--backend-auth' into drew-hart--central_v2-setup
drewjhart May 9, 2024
950da92
Merge branch 'drew-hart--central_v2-setup' into drew-hart--apiclients
drewjhart May 9, 2024
8edf6fe
Merge branch 'drew-hart--apiclients' into drew-hart--amplify-v5-to-v6
drewjhart May 9, 2024
c25d97c
merge branch 'drew-hart--amplify-v5-to-v6' into drew-hart--auth-feder…
drewjhart May 9, 2024
7947db7
corrections from merge
drewjhart May 9, 2024
957ea2f
public/private filter by UI in SortByDropdown
drewjhart May 9, 2024
02e4282
updates schema for two tables
drewjhart May 10, 2024
010d982
updates APIClients to reflect public private
drewjhart May 14, 2024
b6f1031
updates central for new public private apiclient
drewjhart May 14, 2024
f435f01
updates to enum
drewjhart May 14, 2024
77700e9
updates other central code
drewjhart May 14, 2024
a9695f3
corrections to APIClients
drewjhart May 15, 2024
05691ed
two table progress
drewjhart May 17, 2024
3a8b123
fixes
drewjhart May 27, 2024
69a6a54
fixes
drewjhart May 28, 2024
b5c9795
resolves private game template
drewjhart May 29, 2024
4f75246
reverts UI changes for a separate PR
drewjhart May 29, 2024
d23dbda
removes isPublic
drewjhart May 29, 2024
2ad937f
adds UI updates to handle API changes
drewjhart May 29, 2024
0ce37f7
removes unused import
drewjhart May 29, 2024
5be5abb
changes username set up so that username is visible for games
drewjhart May 30, 2024
ba0a5c8
Merge branch 'drew-hart--backend-public-private' into drew-hart--publ…
drewjhart May 30, 2024
b4438fe
shows created by owner in public games
drewjhart May 30, 2024
5b49c10
adjust question templates to mirror game templates re auth
drewjhart May 30, 2024
6b04582
wip
drewjhart May 31, 2024
7828fd0
update parsers to include public/private logic
drewjhart May 31, 2024
2c587bb
bug fixes
drewjhart Jun 3, 2024
6ea4132
changes
drewjhart Jun 4, 2024
ff58728
move networking changes from child branch back to backend changes branch
drewjhart Jun 4, 2024
d892538
Merge branch 'drew-hart--backend-public-private' into drew-hart--publ…
drewjhart Jun 4, 2024
9555689
adds owner info to question card, removes console logs
drewjhart Jun 5, 2024
c85fcd0
various bug fixes
drewjhart Jun 5, 2024
39f3aec
removes unused import
drewjhart Jun 5, 2024
bf0acf1
removes console.log
drewjhart Jun 5, 2024
4db334d
removes console.logs
drewjhart Jun 5, 2024
bbc87ae
Merge branch 'drew-hart--backend-public-private' into drew-hart--publ…
drewjhart Jun 5, 2024
27aaf5f
Merge branch 'drew-hart--publicprivate-ui' into drew-hart--publicpriv…
drewjhart Jun 5, 2024
c8f2ed1
card animation
drewjhart Sep 18, 2024
9caa38f
progress
drewjhart Sep 19, 2024
fe76b6e
fixes listGameTemplates
drewjhart Oct 3, 2024
3dfc3e9
Merge branch 'drew-hart--loading-poc' into drew-hart--centralv2-us1-g…
drewjhart Oct 3, 2024
0485576
fixes select button and adds animations
drewjhart Oct 4, 2024
777b49c
updates choose grade label with cases per figma
drewjhart Oct 7, 2024
30a9aa9
Fixes search bar layout for mobile
drewjhart Oct 7, 2024
d29b2dd
adds chromatic and storybook
drewjhart Oct 7, 2024
af948ae
Merge branch 'drew-hart--publicprivate-bugs' into drew-hart--centralv…
drewjhart Oct 7, 2024
3ff5895
codegen AWS resources
drewjhart Oct 7, 2024
d2f6a44
resolving merge issues pt 1
drewjhart Oct 7, 2024
3d83871
fixes graphql.schema to be a merge
drewjhart Oct 8, 2024
dce114b
backend updates pushed to amplify
drewjhart Oct 8, 2024
f1c9cab
fixes for test backend
drewjhart Oct 8, 2024
ce52fb3
progress
drewjhart Oct 9, 2024
dc2b268
backend dev fixes
drewjhart Oct 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion central/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
"@material-ui/lab": "^4.0.0-alpha.48",
"@mui/icons-material": "^5.6.2",
"@mui/material": "^5.13.3",
"@react-oauth/google": "^0.12.1",
"@types/lodash": "^4.14.202",
"@types/react-router-dom": "^5.1.5",
"aws-amplify": "^4.3.36",
"aws-sdk": "^2.1573.0",
"axios": "^1.6.0",
"babel-loader": "8.1.0",
"classnames": "^2.2.6",
"glob-parent": "^6.0.2",
"jwt-decode": "^4.0.0",
"lodash": "^4.17.21",
"nth-check": "^2.1.1",
"postcss": "^8.4.31",
Expand Down
25 changes: 15 additions & 10 deletions central/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
createTheme,
ThemeProvider,
} from '@material-ui/core/styles';
import { APIClients, Environment, AppType } from '@righton/networking';
import { GoogleOAuthProvider } from '@react-oauth/google';
import { useAPIClients, Environment, AppType } from '@righton/networking';
import { RouteContainer } from './containers/RouteContainer';
import AlertContext, { Alert } from './context/AlertContext';

Expand All @@ -26,20 +27,24 @@ const theme = createTheme({

function App() {
const [alert, setAlert] = useState<Alert | null>(null);
const apiClients = new APIClients(Environment.Developing, AppType.CENTRAL);
const { apiClients, loading } = useAPIClients(Environment.Developing, AppType.CENTRAL);
const alertContext = {
alert,
setAlert,
};

return (
<ThemeProvider theme={theme}>
<AlertContext.Provider value={alertContext}>
<Router>
<RouteContainer setAlert={setAlert} apiClients={apiClients}/>
</Router>
</AlertContext.Provider>
</ThemeProvider>
<GoogleOAuthProvider clientId="23009502295-0ut6vmh3km13funjo26p409mgmbkeb76.apps.googleusercontent.com">
<ThemeProvider theme={theme}>
<AlertContext.Provider value={alertContext}>
<Router>
{ apiClients &&
<RouteContainer setAlert={setAlert} apiClients={apiClients}/>
}
</Router>
</AlertContext.Provider>
</ThemeProvider>
</GoogleOAuthProvider>
);
}

Expand Down
34 changes: 25 additions & 9 deletions central/src/components/GameCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@ import {
import MoreVertIcon from '@material-ui/icons/MoreVert';
import CCSS from './CCSSText';
import RightOnPlaceHolder from '../images/RightOnPlaceholder.svg';
import { PublicPrivateType } from '@righton/networking';
export default function GameCard({
game,
index,
handleClick,
handleClose,
editHandler,
cloneHandler,
deleteHandler,
addquestion,
match,
isUserAuth,
onClick,
anchorEl,
activeIndex
activeIndex,
publicPrivateQueryType
}) {
const classes = useStyles();
const { id, title, description, cluster, domain, grade, standard, imageUrl } = game;
const { id, title, description, cluster, domain, grade, standard, imageUrl, owner } = game;
const questionCount = game?.questionTemplates.length || 0;
const history = useHistory();
return (
Expand All @@ -48,9 +51,16 @@ export default function GameCard({
</Typography>
</Grid>
</Grid>
<Typography className={classes.title} >
{title}
</Typography>
<>
<Typography className={classes.title} >
{title}
</Typography>
{ publicPrivateQueryType === PublicPrivateType.PUBLIC &&
<Typography className={classes.owner} >
Created by: {owner}
</Typography>
}
</>
<Typography className={classes.textSecondary} color="textSecondary" >
{description}
</Typography>
Expand All @@ -76,9 +86,9 @@ export default function GameCard({
onClose={handleClose}
onClick={(event) => { if (!match) event.stopPropagation(); }}
>
<MenuItem onClick={(event) => { history.push(`/gamemaker/${game.id}`); event.stopPropagation(); handleClose(); }}>Edit</MenuItem>
<MenuItem onClick={cloneHandler(game)}>Clone</MenuItem>
<MenuItem onClick={deleteHandler(game.id)}>Delete</MenuItem>
<MenuItem onClick={(event) => editHandler(game, event)}> Edit </MenuItem>
<MenuItem onClick={(event) => cloneHandler(game, event)}>Clone</MenuItem>
<MenuItem onClick={(event) => deleteHandler(game, event)}>Delete</MenuItem>
</Menu>
</Grid>
}
Expand Down Expand Up @@ -125,7 +135,13 @@ const useStyles = makeStyles(theme => ({
},
title: {
fontWeight: 700,
height: '80%',
lineHeight: '1.2',
color: '#384466',
textOverflow: 'ellipsis',
},
owner: {
fontWeight: 400,
height: '60%',
color: '#384466',
display: '-webkit-box',
WebkitBoxOrient: 'vertical',
Expand Down
59 changes: 49 additions & 10 deletions central/src/components/GameDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import LoadingIndicator from './LoadingIndicator';
import GameCard from './GameCard';
import InfiniteScroll from 'react-infinite-scroll-component';

export default function GameDashboard({ loading, nextToken, games, handleScrollDown, deleteGame, cloneGameTemplate, gameId, isUserAuth }) {
export default function GameDashboard({ checkGameOwner, loading, nextToken, publicPrivateQueryType, games, handleScrollDown, deleteGame, cloneGameTemplate, gameId, isUserAuth, setGameDetails }) {
const classes = useStyles();
const history = useHistory();
const match = useRouteMatch('/games/:gameIndex');
Expand All @@ -19,19 +19,55 @@ export default function GameDashboard({ loading, nextToken, games, handleScrollD
event.stopPropagation();
};
const handleClose = () => {
setAnchorEl(null);
setActiveIndex(null);
};
const cloneHandler = (game) => () => {
cloneGameTemplate(game);
handleClose();
const editHandler = async (game) => {
try {
const isOwner = await checkGameOwner(game);
if (isOwner){
setGameDetails(game);
history.push(`/gamemaker/${game.id}`);
handleClose();
} else {
handleClose();
alert('You do not have the required authorization to edit this game.');
}
}catch (error){
console.log(error);
}
};

const cloneHandler = async (game, event) => {
try {
const isOwner = await checkGameOwner(game);
if (isOwner){
cloneGameTemplate(game);
handleClose();
} else {
handleClose();
alert('You do not have the required authorization to clone this game.');
}
} catch (error){
console.log(error);
}
};
const deleteHandler = (id) => () => {
const confirmDelete = window.confirm('Are you sure you want to delete this game?');
if (confirmDelete) {
deleteGame(id);

const deleteHandler = async (game) => {
try {
const isOwner = await checkGameOwner(game);
if (isOwner){
const confirmDelete = window.confirm('Are you sure you want to delete this game?');
if (confirmDelete) {
deleteGame(game.id);
}
handleClose();
} else {
handleClose();
alert('You do not have the required authorization to delete this game.');
}
} catch (error) {
console.log(error);
}
handleClose();
};

const renderGames = (loading) => {
Expand Down Expand Up @@ -80,6 +116,7 @@ export default function GameDashboard({ loading, nextToken, games, handleScrollD
index={index}
handleClick={handleClick}
handleClose={handleClose}
editHandler={editHandler}
cloneHandler={cloneHandler}
deleteHandler={deleteHandler}
addquestion={addquestion}
Expand All @@ -88,6 +125,7 @@ export default function GameDashboard({ loading, nextToken, games, handleScrollD
anchorEl={anchorEl}
activeIndex={activeIndex}
onClick={() => history.push(`/games/${game.id}`)}
publicPrivateQueryType={publicPrivateQueryType}
/>
</Grid>
) :
Expand All @@ -107,6 +145,7 @@ const useStyles = makeStyles(theme => ({
loadingContainer: {
margin: 'auto',
width: '60%',
height: `calc(100vh - 156px)`
},
loadingTitle: {
fontSize: '24px',
Expand Down
4 changes: 2 additions & 2 deletions central/src/components/GameLaunch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const useStyles = makeStyles(theme => ({
},
}));

function GameLaunch({ loading, game, gameId, saveGame, deleteQuestion, handleDeleteGameTemplate, handleCloneGameTemplate, isUserAuth, handleDeleteGameQuestion }) {
function GameLaunch({ publicPrivateQueryType, loading, game, gameId, saveGame, deleteQuestion, handleDeleteGameTemplate, handleCloneGameTemplate, isUserAuth, handleDeleteGameQuestion }) {
useEffect(() => {
document.title = 'RightOn! | Game launcher';
return () => { document.title = 'RightOn! | Game management'; }
Expand Down Expand Up @@ -171,7 +171,7 @@ function GameLaunch({ loading, game, gameId, saveGame, deleteQuestion, handleDel
if (loading) return <Skeleton variant="rect" height={500} />;
const questions = game?.questionTemplates || [];
const questionCount = game?.questionTemplates.length || 0;
const LAUNCH_GAME_URL = `http://host.rightoneducation.com/new/${game.id}`;
const LAUNCH_GAME_URL = `http://localhost:3001/new/${publicPrivateQueryType}/${game.id}`;

return (
<Box className={classes.root}>
Expand Down
55 changes: 32 additions & 23 deletions central/src/components/GameMaker.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useState, useEffect } from 'react';
import { Route, Switch, useHistory } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import { Button, IconButton, Divider, Grid, MenuItem, TextField, Typography, Card, CardContent, Box } from '@material-ui/core';
import { Button, IconButton, Divider, Grid, MenuItem, TextField, Typography, Card, CardContent, Box, Radio } from '@material-ui/core';
import { Cancel } from '@material-ui/icons';
import { isNullOrUndefined } from '@righton/networking';
import { PublicPrivateType, isNullOrUndefined } from '@righton/networking';
import RightOnPlaceHolder from './../images/RightOnPlaceholder.svg';
import CCSSText from './CCSSText';
import GameCCSS from './GameMakerCCSS';
Expand All @@ -14,18 +14,6 @@ import SortByDropdown from './SortByDropdown';
import QuestionDashboard from './QuestionDashboard';
import { v4 as uuidv4 } from 'uuid';

// New "empty" game
const newGame = {
title: '',
description: '',
grade: '',
domain: '',
phaseOneTime: 180,
phaseTwoTime: 180,
imageUrl: '',
questionTemplates: [],
}

// Preset times
const times = [
{
Expand Down Expand Up @@ -53,9 +41,12 @@ const times = [
export default function GameMaker({
loading,
questions,
gameDetails,
setGameDetails,
game,
games,
handleQuestionBankClick,
handleCreateQuestionTemplateClick,
selectedQuestions,
setSelectedQuestions,
saveGameTemplate,
Expand All @@ -79,21 +70,16 @@ export default function GameMaker({
nextToken,
localQuestionTemplates,
setLocalQuestionTemplates,
publicPrivateQueryType,
handlePublicPrivateChange
}) {
useEffect(() => {
document.title = 'RightOn! | Game editor';
return () => { document.title = 'RightOn! | Game management'; }
}, []);
const classes = useStyles();
const history = useHistory();
const [gameDetails, setGameDetails] = useState(() => {
if (game) {
return { ...game };
}
else {
return {id: gameId, ...newGame};
}
});

const calculateCCSS = (localQuestionTemplates) => {
if (localQuestionTemplates === 'Mashup')
return localQuestionTemplates;
Expand Down Expand Up @@ -162,6 +148,7 @@ export default function GameMaker({
setSelectedQuestions([]);
setLocalQuestionTemplates([]);
gameDetails.questionTemplates = localQuestionTemplates;
gameDetails.id = gameId;
if (CCSS === 'Mashup' || CCSS === undefined){
gameDetails.grade = 'Mashup';
gameDetails.domain = '';
Expand All @@ -179,6 +166,7 @@ export default function GameMaker({
return { questionTemplateId: question.questionTemplate.id, index: index };
});
saveGameTemplate(game, gameDetails);
setGameDetails({});
event.preventDefault();
history.push('/');
};
Expand Down Expand Up @@ -276,6 +264,27 @@ export default function GameMaker({
<Grid container item xs={12} sm={4} justifyContent='center'>
{gameDetails.imageUrl ? <img src={gameDetails.imageUrl} alt="" width={'60%'} /> : <img src={RightOnPlaceHolder} alt="Placeholder" height={'275px'} />}
</Grid>
<Grid container item xs={12} sm={4} style={{display: 'flex', alignItems: 'center', gap: 10}}>
<Typography style={{ fontWeight: 200, fontSize: '1 rem', color: 'rgba(0,0,0,0.75)' }}> Game Type: </Typography>
<Box style={{ display: 'flex', justifyContainer: 'center', alignItems: 'center'}}>
<Typography style={{ fontWeight: 200, fontSize: '15px', color: 'rgba(0,0,0,0.75)' }}> Public </Typography>
<Radio
checked={publicPrivateQueryType === PublicPrivateType.PUBLIC}
value={PublicPrivateType.PUBLIC}
onChange={handlePublicPrivateChange}
color='default'
/>
</Box>
<Box style={{display: 'flex', justifyContainer: 'center', alignItems: 'center'}}>
<Typography style={{ fontWeight: 200, fontSize: '15px', color: 'rgba(0,0,0,0.75)'}}> Private </Typography>
<Radio
checked={publicPrivateQueryType === PublicPrivateType.PRIVATE}
value={PublicPrivateType.PRIVATE}
onChange={handlePublicPrivateChange}
color='default'
/>
</Box>
</Grid>
</Grid>
</Grid>

Expand Down Expand Up @@ -356,7 +365,7 @@ export default function GameMaker({
</Grid>

<Grid container item xs={6} justifyContent='center'>
<Button variant='contained' disableElevation className={classes.greenButton} onClick={() => history.push(`/gamemaker/${gameDetails.id}/questionmaker/${uuidv4()}`)}>
<Button variant='contained' disableElevation className={classes.greenButton} onClick={() => handleCreateQuestionTemplateClick(gameDetails)}>
Create Question
</Button>
</Grid>
Expand Down
Loading