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

add-button-sign-github #744

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
18 changes: 15 additions & 3 deletions services/app/assets/js/widgets/containers/GameList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import Loading from '../components/Loading';
import GamesHeatmap from '../components/GamesHeatmap';
import Card from '../components/Card';
import UserInfo from './UserInfo';
import { makeCreateGameBotUrl } from '../utils/urlBuilders';
import { makeCreateGameBotUrl, getSignInGithubUrl } from '../utils/urlBuilders';
import PlayWithBotDropdown from '../components/PlayWithBotDropdown';
import CreateGameDropdown from '../components/CreateGameDropdown';
import PlayWithFriendDropdown from '../components/PlayWithFriendDropdown';
import i18n from '../../i18n';

class GameList extends React.Component {
levelToClass = {
Expand Down Expand Up @@ -119,6 +120,8 @@ class GameList extends React.Component {
const gameUrlJoin = makeCreateGameBotUrl(game.id, 'join');
const currentUser = Gon.getAsset('current_user');
const gameState = game.state;
const signInUrl = getSignInGithubUrl();


if (gameState === GameStatusCodes.playing) {
return this.renderShowButton(gameUrl);
Expand All @@ -139,8 +142,17 @@ class GameList extends React.Component {
</div>
);
}
if (currentUser.id === 'anonymous') {
return null;
if (currentUser.guest) {
return (
<button
type="button"
className="btn btn-outline-success btn-sm"
data-method="get"
data-to={signInUrl}
>
{i18n.t('Sign in with %{name}', { name: 'Github' })}
</button>
);
}
return (
<div className="btn-group">
Expand Down
1 change: 1 addition & 0 deletions services/app/assets/js/widgets/utils/urlBuilders.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export const makeCreateGameUrlDefault = (gameLevel, gameType, timeoutSeconds) =>
};

export const makeCreateGameBotUrl = (...paths) => `/games/${paths.join('/')}/`;
export const getSignInGithubUrl = () => '/auth/github';