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

Admin next fixes #777

Merged
merged 4 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/login_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class LoginController < Devise::SessionsController

skip_before_action :require_no_authentication
skip_before_action :verify_signed_out_user
skip_before_action :verify_authenticity_token, only: [:destroy]

def self.controller_path
'login'
Expand Down
8 changes: 4 additions & 4 deletions app/graphql/types/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def field(id:)
field :teams, [Types::Team], null: true

def teams
context[:tournament].teams.all
context[:tournament].teams.includes(:division).all
end

field :team, Types::Team, null: true do
argument :id, ID, required: true
end

def team(id:)
context[:tournament].teams.find(i)
context[:tournament].teams.find(id)
end

field :divisions, [Types::Division], null: true
Expand All @@ -59,7 +59,7 @@ def division(id:)
end

def games(scheduled: false, has_team: false)
scope = context[:tournament].games
scope = context[:tournament].games.includes(:division)

scope = scope.scheduled if scheduled
scope = scope.has_team if has_team
Expand All @@ -73,7 +73,7 @@ def games(scheduled: false, has_team: false)
end

def game(id:)
context[:tournament].game.find(:id)
context[:tournament].game.find(id)
end

field :score_reports, [Types::ScoreReport], auth: :required, null: true
Expand Down
6 changes: 3 additions & 3 deletions clients/admin_next/public/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en" style="height: 100%;">
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
Expand All @@ -22,11 +22,11 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" />
<title>Ultimate Tournament Admin</title>
</head>
<body style="height: 100%;">
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root" style="height: 100%;"></div>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand Down
10 changes: 3 additions & 7 deletions clients/admin_next/src/assets/jss/styles.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const App = {
root: {
flexGrow: 1,
height: "100%",
flexGrow: 1
}
};

Expand Down Expand Up @@ -30,7 +29,7 @@ const NavItems = {
const Loader = {
container: {
display: "flex",
height: "100%",
height: "92vh",
justifyContent: "center",
alignItems: "center"
},
Expand All @@ -42,12 +41,9 @@ const Loader = {
const BlankSlate = {
container: {
display: "flex",
height: "100%",
height: "92vh",
justifyContent: "center",
alignItems: "center"
},
content: {
height: 100
}
};

Expand Down
2 changes: 1 addition & 1 deletion clients/admin_next/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class App extends React.Component<Props, State> {
const { classes } = this.props;

return (
<Router>
<Router basename={process.env.PUBLIC_URL}>
<div className={classes.root}>
<TopBar openNav={this.openNav} />
<SideBar
Expand Down
2 changes: 1 addition & 1 deletion clients/admin_next/src/components/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Schedule from "./pages/Schedule";
import Games from "./pages/Games";

const Routes = () => (
<div style={{height: "100%"}}>
<div>
<Route exact path="/" component={Home} />
<Route path="/teams" component={Teams} />
<Route path="/divisions" component={Divisions} />
Expand Down
24 changes: 14 additions & 10 deletions clients/admin_next/src/components/layout/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,46 @@ interface Props extends WithStyles<typeof styles> {}

interface State {
open: boolean;
anchorEl: any;
}

class UserMenu extends React.Component<Props, State> {
state = {
open: false,
anchorEl: undefined
};

handleOpen = () => {
this.setState({ open: true });
handleOpen = (event: any) => {
this.setState({ open: true, anchorEl: event.currentTarget });
}

handleClose = () => {
this.setState({ open: false });
this.setState({ open: false, anchorEl: undefined });
}

handleLogout = () => {
fetch("/sign_out", {method: "DELETE", credentials: "include"});
}

render() {
const { open } = this.state;
const { open, anchorEl } = this.state;

return (
<div>
<IconButton
onClick={this.handleOpen}
color="inherit"
>
<IconButton onClick={this.handleOpen}>
<Avatar alt="Kevin Hughes" src="https://www.gravatar.com/avatar/a14e0880b9ef8720734a7db6b6c4ade0" />
</IconButton>
<Menu
id="menu-appbar"
id="user-menu"
anchorEl={anchorEl}
anchorOrigin={{vertical: "top", horizontal: "right"}}
transformOrigin={{vertical: "top", horizontal: "right"}}
open={open}
onClose={this.handleClose}
>
<MenuItem onClick={this.handleClose}>Profile</MenuItem>
<MenuItem onClick={this.handleClose}>Settings</MenuItem>
<MenuItem onClick={this.handleClose}>Logout</MenuItem>
<MenuItem onClick={this.handleLogout}>Logout</MenuItem>
</Menu>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion clients/admin_next/src/components/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Home extends React.Component<Props> {

return (
<div className={classes.container}>
<span className={classes.content}>Home</span>
<span>Home</span>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion clients/admin_next/src/components/pages/Schedule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Schedule extends React.Component<Props> {

return (
<div className={classes.container}>
<span className={classes.content}>Schedule</span>
<span>Schedule</span>
</div>
);
}
Expand Down