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

GameHistory: Click on a row opens the game #1354

Merged
merged 2 commits into from
Jan 13, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/views/User/User.styl
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,10 @@
}

.game_name {
max-width: 12rem;
max-width: 15rem;
overflow: hidden;
padding-left: 0.5em;
text-overflow: ellipsis;
}

.player {
Expand Down
9 changes: 6 additions & 3 deletions src/views/User/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {longRankString, rankString, getUserRating, humble_rating, effective_outc
import {durationString, daysOnlyDurationString} from "TimeControl";
import {openModerateUserModal} from "ModerateUser";
import {PaginatedTable} from "PaginatedTable";
import {errorAlerter} from "misc";
import {errorAlerter, shouldOpenNewTab} from "misc";
import * as player_cache from "player_cache";
import {getPrivateChat} from "PrivateChat";
import {PlayerAutocomplete} from "PlayerAutocomplete";
Expand All @@ -45,6 +45,7 @@ import {Markdown} from "Markdown";
import {RatingsChart} from 'RatingsChart';
import {UIPush} from "UIPush";
import {associations} from 'associations';
import {browserHistory} from "ogsHistory";

declare let swal;

Expand Down Expand Up @@ -906,14 +907,15 @@ export class User extends React.PureComponent<UserProperties, any> {
}}
orderBy={["-ended"]}
groom={game_history_groomer}
onRowClick={(ref, ev) => shouldOpenNewTab(ev) ? window.open(ref.href, "_blank") : browserHistory.push(ref.href)}
columns={[ /* I wish we could set properties at the row level! */
{header: _("User"), className: (X) => ("user_info" + ((X && X.annulled) ? " annulled" : "")), render: (X) => (<React.Fragment>{(X.played_black ? <span>⚫</span> : <span>⚪</span>)}{this.maskedRank(`[${rankString(X.player)}]`)}</React.Fragment>)},
{header: _(""), className: (X) => ("winner_marker" + ((X && X.annulled) ? " annulled" : "")), render: (X) => (X.player_won ? <i className="fa fa-trophy game-history-winner"/> : "")},
{header: _("Date"), className: (X) => ("date" + ((X && X.annulled) ? " annulled" : "")), render: (X) => moment(X.date).format("YYYY-MM-DD")},
{header: _("Opponent"), className: (X) => ("player" + ((X && X.annulled) ? " annulled" : "")), render: (X) => <Player user={X.opponent} disableCacheUpdate />} ,
{header: _(""), className: (X) => ("speed" + ((X && X.annulled) ? " annulled" : "")), render: (X) => <i className={X.speed_icon_class} title={X.speed} />},
{header: _("Size"), className: (X) => ("board_size" + ((X && X.annulled) ? " annulled" : "")), render: (X) => `${X.width}x${X.height}`},
{header: _("Name"), className: (X) => ("game_name" + ((X && X.annulled) ? " annulled" : "")), render: (X) => <Link to={X.href}>{X.name || interpolate('{{black_username}} vs. {{white_username}}', {'black_username': X.black.username, 'white_username': X.white.username}) }</Link>},
{header: _("Name"), className: (X) => ("game_name" + ((X && X.annulled) ? " annulled" : "")), render: (X) => X.name || interpolate('{{black_username}} vs. {{white_username}}', {'black_username': X.black.username, 'white_username': X.white.username}) },
{header: _("Result"), className: (X) => (X ? X.result_class + (X.annulled ? " annulled" : "") : ""), render: (X) => X.result},
]}
/>
Expand Down Expand Up @@ -942,9 +944,10 @@ export class User extends React.PureComponent<UserProperties, any> {
}}
orderBy={["-created"]}
groom={review_history_groomer}
onRowClick={(ref, ev) => shouldOpenNewTab(ev) ? window.open(ref.href, "_blank") : browserHistory.push(ref.href)}
columns={[
{header: _("Date"), className: () => "date", render: (X) => moment(X.date).format("YYYY-MM-DD")},
{header: _("Name"), className: () => "name", render: (X) => <Link to={X.href}>{X.name}</Link>},
{header: _("Name"), className: () => "name", render: (X) => X.name},
{header: _("Black"), className: (X) => ("player " + (X ? X.black_class : "")), render: (X) => <Player user={X.historical.black} disableCacheUpdate />},
{header: _("White"), className: (X) => ("player " + (X ? X.white_class : "")), render: (X) => <Player user={X.historical.white} disableCacheUpdate />},
]}
Expand Down