Skip to content

Commit

Permalink
Merge pull request #492 from battlecode/jerrym-scrim-request
Browse files Browse the repository at this point in the history
Small changes to scrimmage request team search
  • Loading branch information
j-mao authored Jan 9, 2023
2 parents 5f7ab58 + 2d22d5c commit d1c4f5f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
13 changes: 6 additions & 7 deletions frontend/src/components/rankingTeamList.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ class RankingTeamList extends Component {
</div>
);
} else {
const teamRows = props.teams.map((team) => {
const teamsToShow = props.teams.filter((team) => {
return team.has_active_submission || !this.props.canRequest;
});
const teamRows = teamsToShow.map((team) => {
let buttonContent = "Request";
if (state.pendingRequests[team.id]) {
buttonContent = <i className="fa fa-circle-o-notch fa-spin"></i>;
Expand All @@ -111,7 +114,7 @@ class RankingTeamList extends Component {
</span>
))}
</td>
{!this.props.canRequest && <td>{team.profile.quote}</td>}
<td>{team.profile.quote}</td>
{!this.props.canRequest && (
<td>
{this.props.episode_info.eligibility_criteria.map(
Expand All @@ -128,9 +131,6 @@ class RankingTeamList extends Component {
)}
</td>
)}
{this.props.canRequest && (
<td>{team.has_active_submission ? "Yes" : "No"}</td>
)}
<td>{team.profile.auto_accept_ranked ? "Yes" : "No"}</td>
<td>{team.profile.auto_accept_unranked ? "Yes" : "No"}</td>
{this.props.canRequest && (
Expand Down Expand Up @@ -180,9 +180,8 @@ class RankingTeamList extends Component {
<th>Rating</th>
<th>Team</th>
<th>Members</th>
{!this.props.canRequest && <th>Quote</th>}
<th>Quote</th>
{!this.props.canRequest && <th>Eligibility</th>}
{this.props.canRequest && <th>Submitted?</th>}
<th>Auto-Accept Ranked</th>
<th>Auto-Accept Unranked</th>
</tr>
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/components/scrimmageRequestForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const PLAYER_ORDERS = [
{ value: "-", name: "Requester last" },
];

// Team statuses that allow ranked matches.
const ALLOWS_RANKED = ["R"];

class ScrimmageRequestForm extends Component {
constructor(props) {
super(props);
Expand All @@ -31,6 +34,15 @@ class ScrimmageRequestForm extends Component {
this.requestScrimmage = this.requestScrimmage.bind(this);
}

componentDidUpdate(prevProps, prevState, snapshot) {
if (prevProps.team !== this.props.team) {
let is_ranked =
this.props.team === null ||
ALLOWS_RANKED.includes(this.props.team.status);
this.setState({ is_ranked });
}
}

getRandomMaps(available_maps) {
const possible_maps = available_maps.slice();
// Pick a random subset of 3 maps, assuming that there are at least 3 possible maps
Expand Down Expand Up @@ -209,6 +221,11 @@ class ScrimmageRequestForm extends Component {
}}
id="is_ranked"
checked={this.state.is_ranked}
// Only regular teams get ranked matches
disabled={
this.props.team !== null &&
!ALLOWS_RANKED.includes(this.props.team.status)
}
/>
</div>
</div>
Expand Down

0 comments on commit d1c4f5f

Please sign in to comment.