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

Allow tournament administrators to clone tournaments #2579

Conversation

dexonsmith
Copy link
Contributor

Add a "Clone Tournament" button to the tournament page that allows an existing tournament to be cloned.

  • Button shows up for anyone that can administer the tournament.
  • Takes the user to the "new tournament" page in the same group.
  • All tournament settings are pre-loaded to match the source tournament.

This makes it easy to create new tournaments in a series, without the laborious and error-prone process of re-entering the settings.

Replaces #2573.

In case it's easier to look at them individually, there are three commits here, the first two of which are prep commits which would be nice to land even if this PR doesn't:

  • d6ec4d5 Remove extra state variables to track what has loaded
  • b7b7541 Delay editing new tournaments until the group has loaded
  • 30251cb Allow tournament administrators to clone tournaments

Instead of using extra state to track whether the tournament, rounds,
and players have loaded, detect it:

- Stop setting `tournament.id`, then test for `tournament.id === tournament_id`.
- Initialize `raw_rounds` to null, then test for non-null.
- Introduce `raw_players and initialize to null, then test for non-null.
Add a "Clone Tournament" button to the tournament page that allows an existing
tournament to be cloned.

- Button shows up for anyone that can administer the tournament.
- Takes the user to the "new tournament" page in the same group.
- All tournament settings are pre-loaded to match the source tournament.

This makes it easy to create new tournaments in a series, without the laborious
and error-prone process of re-entering the settings.
Copy link

github-actions bot commented Feb 12, 2024

Uffizzi Preview deployment-46413 was deleted.

Comment on lines 264 to 268
// this is so anoek (user id 1) can quickly test tournaments
React.useEffect(() => {
if (user.id === 1 && tournament_id === 0) {
setTournament({
...tournament,
...default_tournament,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anoek, for obvious reasons, I haven't been able to test this part of the code. I also suspect it blocks "Clone Tournament" from working for you.

Two options to consider:

  • Delete this block entirely now that we have "Clone Tournament". It seems like the only thing you're gaining vs. clicking "Clone Tournament" is not having to set time_start.
  • Lift this up, changing how default_tournament gets set based on user.id === 1 instead of modifying the tournament later via useEffect. This would be easier to reason about.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented and pushed the second option in 80e5e8f. But it might be nice to delete this entirely, or limit it just to a time_start override, if you can use "Clone Tournament" instead.

@dexonsmith
Copy link
Contributor Author

Oh, forgot to add screenshots.

Here's what the button looks like for tournaments that have started:
Image

and for tournaments that haven't started:
Image 2

(The edit interface looks exactly like it does for other new tournaments... just that the details have been filled in... so not going to post a screenshot of that.)

@dexonsmith
Copy link
Contributor Author

dexonsmith commented Feb 13, 2024

One other consideration is what to do for the tournament title. If the tournament-to-clone's name was "abc #7", here are some options for the default name for the new tournament:

  • "abc #7" (this is what the patch does)
  • "abc #8"
  • "abc #7 (cloned)" (with a translation for clone)

I like the simplicity of just taking the old title verbatim. The user can fix/change it.

Fix [sentry
issues](online-go#2577 (comment))
by delaying computation of rounds until everything is loaded.
@dexonsmith
Copy link
Contributor Author

Merged in the fix for #2580 and resolved the conflict in 6cd4629.

@anoek
Copy link
Member

anoek commented Feb 13, 2024

Slick, thanks!

@anoek anoek merged commit 4572234 into online-go:devel Feb 13, 2024
4 checks passed
@dexonsmith dexonsmith deleted the allow-tournament-administrators-to-clone-tournaments branch February 13, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants