From c5bfd45a32a99363ab6cb821e054cc2be85e72a6 Mon Sep 17 00:00:00 2001 From: LucaHaverty Date: Tue, 16 Jul 2024 09:46:34 -0700 Subject: [PATCH 1/5] Fixed build errors with sliders and settings modal --- fission/src/Synthesis.tsx | 2 ++ .../systems/preferences/PreferencesSystem.ts | 8 ++--- .../configuring/ResetAllInputsModal.tsx | 31 ++++++++++--------- .../configuring/scoring/ZoneConfigPanel.tsx | 11 +++---- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/fission/src/Synthesis.tsx b/fission/src/Synthesis.tsx index 073246f140..54eb598f9a 100644 --- a/fission/src/Synthesis.tsx +++ b/fission/src/Synthesis.tsx @@ -58,6 +58,7 @@ import APS from "./aps/APS.ts" import ImportMirabufPanel from "@/ui/panels/mirabuf/ImportMirabufPanel.tsx" import Skybox from "./ui/components/Skybox.tsx" import ConfigureRobotModal from "./ui/modals/configuring/ConfigureRobotModal.tsx" +import ResetAllInputsModal from "./ui/modals/configuring/ResetAllInputsModal.tsx" const DEFAULT_MIRA_PATH = "/api/mira/Robots/Team 2471 (2018)_v7.mira" @@ -215,6 +216,7 @@ const initialModals = [ , , , + ] const initialPanels: ReactElement[] = [ diff --git a/fission/src/systems/preferences/PreferencesSystem.ts b/fission/src/systems/preferences/PreferencesSystem.ts index 9a34a08bb6..4604ad68c9 100644 --- a/fission/src/systems/preferences/PreferencesSystem.ts +++ b/fission/src/systems/preferences/PreferencesSystem.ts @@ -11,9 +11,9 @@ import { class PreferenceEvent extends Event { public prefName: GlobalPreference - public prefValue: object + public prefValue: unknown - constructor(prefName: GlobalPreference, prefValue: object) { + constructor(prefName: GlobalPreference, prefValue: unknown) { super("preferenceChanged") this.prefName = prefName this.prefValue = prefValue @@ -21,7 +21,7 @@ class PreferenceEvent extends Event { } class PreferencesSystem { - private static _preferences: { [key: string]: object } + private static _preferences: { [key: string]: unknown } private static _localStorageKey = "Preferences" /** Event dispatched when any global preference is updated */ @@ -30,7 +30,7 @@ class PreferencesSystem { } /** Sets a global preference to be a value of a specific type */ - public static setGlobalPreference(key: GlobalPreference, value: T) { + public static setGlobalPreference(key: GlobalPreference, value: T) { if (this._preferences == undefined) this.loadPreferences() window.dispatchEvent(new PreferenceEvent(key, value)) diff --git a/fission/src/ui/modals/configuring/ResetAllInputsModal.tsx b/fission/src/ui/modals/configuring/ResetAllInputsModal.tsx index 87471434d8..5816892a69 100644 --- a/fission/src/ui/modals/configuring/ResetAllInputsModal.tsx +++ b/fission/src/ui/modals/configuring/ResetAllInputsModal.tsx @@ -2,8 +2,8 @@ import React from "react" import Modal, { ModalPropsImpl } from "@/components/Modal" import { GrFormClose } from "react-icons/gr" import { useModalControlContext } from "@/ui/ModalContext" -import InputSystem from "@/systems/input/InputSystem" import DefaultInputs from "@/systems/input/DefaultInputs" +import PreferencesSystem from "@/systems/preferences/PreferencesSystem" const ResetAllInputsModal: React.FC = ({ modalId }) => { const { openModal } = useModalControlContext() @@ -14,24 +14,27 @@ const ResetAllInputsModal: React.FC = ({ modalId }) => { icon={} modalId={modalId} onAccept={() => { - let i = 0 - InputSystem.allInputs.forEach(currentScheme => { - const scheme = DefaultInputs.ALL_INPUT_SCHEMES[i] - if (!currentScheme || !scheme) return + const roboPrefs = PreferencesSystem.getAllRobotPreferences() - scheme.inputs.forEach(newInput => { - const currentInput = currentScheme.inputs.find(i => i.inputName == newInput.inputName) + // TODO: This will be improved to make more sense to a user in the "named inputs" PR + Object.values(roboPrefs).forEach(roboPref => { + roboPref.inputsSchemes.forEach(currentScheme => { + const resetScheme = DefaultInputs.ALL_INPUT_SCHEMES[0] + if (!currentScheme || !resetScheme) return - if (currentInput) { - const inputIndex = currentScheme.inputs.indexOf(currentInput) + resetScheme.inputs.forEach(newInput => { + const currentInput = currentScheme.inputs.find(i => i.inputName == newInput.inputName) - currentScheme.inputs[inputIndex] = newInput.getCopy() - } - }) - currentScheme.usesGamepad = scheme.usesGamepad + if (currentInput) { + const inputIndex = currentScheme.inputs.indexOf(currentInput) - i++ + currentScheme.inputs[inputIndex] = newInput.getCopy() + } + }) + currentScheme.usesGamepad = resetScheme.usesGamepad + }) }) + openModal("change-inputs") }} onCancel={() => { diff --git a/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx b/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx index cd58189d8d..be1e3e3353 100644 --- a/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx +++ b/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx @@ -3,7 +3,6 @@ import Input from "@/components/Input" import Panel, { PanelPropsImpl } from "@/components/Panel" import Button from "@/components/Button" import Checkbox from "@/components/Checkbox" -import Slider from "@/components/Slider" import NumberInput from "@/components/NumberInput" export type ScoringZone = { @@ -22,11 +21,11 @@ const ZoneConfigPanel: React.FC = ({ panelId, openLocation, side // then set all default values to the state of the zone const [, setName] = useState("") const [alliance, setAlliance] = useState<"red" | "blue">("blue") - const [, setParent] = useState("") + const [, ] = useState("") const [, setPoints] = useState(1) const [, setDestroy] = useState(false) const [, setPersistent] = useState(false) - const [, setScale] = useState<[number, number, number]>([1, 1, 1]) + const [, ] = useState<[number, number, number]>([1, 1, 1]) return ( @@ -40,7 +39,7 @@ const ZoneConfigPanel: React.FC = ({ panelId, openLocation, side setPoints(v || 1)} /> - = ({ panelId, openLocation, side setScale(s => { s[2] = v return s - }) + } ) } - /> + />*/} ) } From c9c64b07906c9ca068b72407746a83d91c065225 Mon Sep 17 00:00:00 2001 From: LucaHaverty Date: Tue, 16 Jul 2024 09:49:31 -0700 Subject: [PATCH 2/5] Format --- fission/src/Synthesis.tsx | 2 +- fission/src/ui/modals/configuring/ResetAllInputsModal.tsx | 2 +- fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fission/src/Synthesis.tsx b/fission/src/Synthesis.tsx index 54eb598f9a..dfcaa3d63e 100644 --- a/fission/src/Synthesis.tsx +++ b/fission/src/Synthesis.tsx @@ -216,7 +216,7 @@ const initialModals = [ , , , - + , ] const initialPanels: ReactElement[] = [ diff --git a/fission/src/ui/modals/configuring/ResetAllInputsModal.tsx b/fission/src/ui/modals/configuring/ResetAllInputsModal.tsx index 5816892a69..689cb04cde 100644 --- a/fission/src/ui/modals/configuring/ResetAllInputsModal.tsx +++ b/fission/src/ui/modals/configuring/ResetAllInputsModal.tsx @@ -16,7 +16,7 @@ const ResetAllInputsModal: React.FC = ({ modalId }) => { onAccept={() => { const roboPrefs = PreferencesSystem.getAllRobotPreferences() - // TODO: This will be improved to make more sense to a user in the "named inputs" PR + // TODO: This will be improved to make more sense to a user in the "named inputs" PR Object.values(roboPrefs).forEach(roboPref => { roboPref.inputsSchemes.forEach(currentScheme => { const resetScheme = DefaultInputs.ALL_INPUT_SCHEMES[0] diff --git a/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx b/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx index be1e3e3353..80094400cb 100644 --- a/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx +++ b/fission/src/ui/panels/configuring/scoring/ZoneConfigPanel.tsx @@ -21,11 +21,11 @@ const ZoneConfigPanel: React.FC = ({ panelId, openLocation, side // then set all default values to the state of the zone const [, setName] = useState("") const [alliance, setAlliance] = useState<"red" | "blue">("blue") - const [, ] = useState("") + const [,] = useState("") const [, setPoints] = useState(1) const [, setDestroy] = useState(false) const [, setPersistent] = useState(false) - const [, ] = useState<[number, number, number]>([1, 1, 1]) + const [,] = useState<[number, number, number]>([1, 1, 1]) return ( From 8903e629f764a2e9474bb9af6c9967b6394f0a3d Mon Sep 17 00:00:00 2001 From: KyroVibe Date: Tue, 16 Jul 2024 11:45:51 -0600 Subject: [PATCH 3/5] Added build workflow --- .github/workflows/FissionBuild.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/FissionBuild.yml diff --git a/.github/workflows/FissionBuild.yml b/.github/workflows/FissionBuild.yml new file mode 100644 index 0000000000..0ad04fcf19 --- /dev/null +++ b/.github/workflows/FissionBuild.yml @@ -0,0 +1,28 @@ +name: Fission - Build + +on: + workflow_dispatch: {} + pull_request: + branches: [master, dev] + +jobs: + runUnitTests: + name: Unit Tests + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v2 + - name: JavaScript Setup + uses: actions/setup-node@v2 + with: + node-version: 20 + + - name: Install Dependencies + run: | + cd fission + npm install + + - name: Build Fission + run: | + cd fission + npm run build && echo "Build Passed" || (echo "Build Failed" && exit 1) From 42a1174c5d69710e51c2a7a1a857175d45347bab Mon Sep 17 00:00:00 2001 From: KyroVibe Date: Tue, 16 Jul 2024 11:48:11 -0600 Subject: [PATCH 4/5] Updated workflow and added intentional error for testing --- .github/workflows/FissionBuild.yml | 4 ++-- fission/src/ui/components/UserIcon.tsx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/FissionBuild.yml b/.github/workflows/FissionBuild.yml index 0ad04fcf19..fb3387e8bf 100644 --- a/.github/workflows/FissionBuild.yml +++ b/.github/workflows/FissionBuild.yml @@ -6,8 +6,8 @@ on: branches: [master, dev] jobs: - runUnitTests: - name: Unit Tests + buildFission: + name: Build runs-on: ubuntu-latest steps: - name: Checkout Code diff --git a/fission/src/ui/components/UserIcon.tsx b/fission/src/ui/components/UserIcon.tsx index 3d8f359abb..ea41c86b14 100644 --- a/fission/src/ui/components/UserIcon.tsx +++ b/fission/src/ui/components/UserIcon.tsx @@ -1,6 +1,7 @@ import APS, { APS_USER_INFO_UPDATE_EVENT } from "@/aps/APS" import { useEffect, useState } from "react" import { FaQuestion } from "react-icons/fa" +import { HiDownload } from "react-icons/hi" interface UserIconProps { className: string From 18874ad26f97ab5f4d1e45b9f7f01d551c653138 Mon Sep 17 00:00:00 2001 From: KyroVibe Date: Tue, 16 Jul 2024 11:49:51 -0600 Subject: [PATCH 5/5] Worked, fixing error --- fission/src/ui/components/UserIcon.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/fission/src/ui/components/UserIcon.tsx b/fission/src/ui/components/UserIcon.tsx index ea41c86b14..3d8f359abb 100644 --- a/fission/src/ui/components/UserIcon.tsx +++ b/fission/src/ui/components/UserIcon.tsx @@ -1,7 +1,6 @@ import APS, { APS_USER_INFO_UPDATE_EVENT } from "@/aps/APS" import { useEffect, useState } from "react" import { FaQuestion } from "react-icons/fa" -import { HiDownload } from "react-icons/hi" interface UserIconProps { className: string