From 3fbca58aaf0236cb35439c7c9ccd8608281878b6 Mon Sep 17 00:00:00 2001 From: Gregor Billing Date: Tue, 29 Sep 2020 15:37:13 +0200 Subject: [PATCH 1/5] Show dummy ProgressBar upon clicking Scramble --- .jshintrc | 4 +--- tnoodle-ui/src/main/components/EventPicker.jsx | 17 ++++++++++++++--- tnoodle-ui/src/main/components/Main.jsx | 17 +++++++---------- tnoodle-ui/src/main/redux/ActionCreators.js | 7 ++++++- tnoodle-ui/src/main/redux/Reducers.js | 5 +++++ tnoodle-ui/src/main/redux/Types.js | 1 + 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/.jshintrc b/.jshintrc index ce7eed7d7..897804370 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,11 +1,9 @@ { "browser": true, - "jquery": true, - "mootools": true, - "node": true, "undef": true, "sub": true, "newcap": false, + "esversion": 9, "indent": 4, "globals": { "alert": true, diff --git a/tnoodle-ui/src/main/components/EventPicker.jsx b/tnoodle-ui/src/main/components/EventPicker.jsx index ca53a08a3..2a9489826 100644 --- a/tnoodle-ui/src/main/components/EventPicker.jsx +++ b/tnoodle-ui/src/main/components/EventPicker.jsx @@ -9,11 +9,13 @@ import { import MbldDetail from "./MbldDetail"; import FmcTranslationsDetail from "./FmcTranslationsDetail"; import "./EventPicker.css"; +import { ProgressBar } from "react-bootstrap"; const mapStateToProps = (store) => ({ editingDisabled: store.editingDisabled, wcif: store.wcif, wcaFormats: store.wcaFormats, + generatingScrambles: store.generatingScrambles }); const mapDispatchToProps = { @@ -185,10 +187,18 @@ const EventPicker = connect( ); }; - render() { - let wcaEvent = this.props.wcif.events.find( - (event) => event.id === this.props.event.id + maybeShowProgressBar = (rounds) => { + if (!this.props.generatingScrambles || rounds.length === 0) { + return; + } + + return ( + ); + }; + + render() { + let wcaEvent = this.props.wcifEvent; let rounds = wcaEvent != null ? wcaEvent.rounds : []; return ( @@ -219,6 +229,7 @@ const EventPicker = connect(
{this.props.event.name}
+ {this.maybeShowProgressBar(rounds)} diff --git a/tnoodle-ui/src/main/components/Main.jsx b/tnoodle-ui/src/main/components/Main.jsx index 257162750..39090c5f3 100644 --- a/tnoodle-ui/src/main/components/Main.jsx +++ b/tnoodle-ui/src/main/components/Main.jsx @@ -4,7 +4,7 @@ import EventPickerTable from "./EventPickerTable"; import Interceptor from "./Interceptor"; import VersionInfo from "./VersionInfo"; import { fetchZip } from "../api/tnoodle.api"; -import { updateFileZipBlob } from "../redux/ActionCreators"; +import { updateFileZipBlob, updateGeneratingScrambles } from "../redux/ActionCreators"; import { connect } from "react-redux"; import { isUsingStaging } from "../api/wca.api"; import "./Main.css"; @@ -17,10 +17,12 @@ const mapStateToProps = (store) => ({ officialZip: store.officialZip, fileZipBlob: store.fileZipBlob, translations: store.translations, + generatingScrambles: store.generatingScrambles }); const mapDispatchToProps = { updateFileZipBlob, + updateGeneratingScrambles }; const Main = connect( @@ -32,14 +34,13 @@ const Main = connect( super(props); this.state = { - generatingScrambles: false, competitionNameFileZip: "", }; } onSubmit = (evt) => { evt.preventDefault(); - if (this.state.generatingScrambles) { + if (this.props.generatingScrambles) { return; } @@ -50,17 +51,13 @@ const Main = connect( } }; - setGeneratingScrambles = (flag) => { - this.setState({ ...this.state, generatingScrambles: flag }); - }; - generateZip = () => { // If user navigates during generation proccess, we still get the correct name this.setState({ ...this.state, competitionNameFileZip: this.props.wcif.name, - generatingScrambles: true, }); + this.props.updateGeneratingScrambles(true); fetchZip( this.props.wcif, this.props.mbld, @@ -68,7 +65,7 @@ const Main = connect( this.props.translations ).then((blob) => { this.props.updateFileZipBlob(blob); - this.setGeneratingScrambles(false); + this.props.updateGeneratingScrambles(false); }); }; @@ -100,7 +97,7 @@ const Main = connect( }; scrambleButton = () => { - if (this.state.generatingScrambles) { + if (this.props.generatingScrambles) { return (