Skip to content

Vps 137/Create State Variables #286

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

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Conversation

RLee64
Copy link
Contributor

@RLee64 RLee64 commented May 25, 2025

Describe the issue

The current flag system is fairly limited with what it can achieve since they can only be true or false. We want to implement a new 'State Variable' system that allows multiple data types to be stored and manipulated by a scenario author.

Describe the solution

This is the first PR of a planned 4-5 pull requests involving the implementation of this system from the authoring side. Here we're concerned entirely with the creation of State Variables, which is achieved through a new state variable menu. This PR is really big, so following the commits should be helpful for context (note that I sometimes have mistakes in my commits that I only manage to find and fix later on).

Summary of changes are as follows

  • Created StateVariableMenu.jsx component as a menu for creating and updating State Variables and their initial values
  • Created CreateStateVariable.jsx component which handles all the State Variable creation logic
  • Created StateTypes.jsx as a sort of enum for state types (more need to be added later as well like arrays and maps)
  • Created Toast.jsx as a generic toast component (currently only used by CreateStateVariable, but I plan to leverage it in later PRs as well)
  • Updated backend so that scenario can store state variables and create new ones
  • Updated toolbar to provide for an entry point into the State Variable Menu
  • Created OpenStateVariableMenu as a means of handling whether to show or close the State Variable Menu

image
image

Risk

  • Pre-existing state variables don't load upon opening the menu
  • No backend validation exists yet. One consequence of this is that users can make state variables under the same name.

Notes

Hopefully this doesn't cause any issues, but I'd like to do the documentation closer to the end (in case some stuff changes while working on the other PRs).

Definition of Done

  • Code peer-reviewed
  • Wiki Documentation is written and up to date
  • Unit tests written and passing
  • Integration tests written and passing
  • Continuous Integration build passing
  • Acceptance criteria met
  • Deployed to production environment

Reviewed By

Who reviewed your PR - for commit history once merged

RLee64 added 16 commits May 18, 2025 15:47
State variables should are shared across a scenario, so this feel like the most fitting place to include them. I've had to change a bit of naming to make things work though (hopefully that's okay)
The styling present is just a temporary solution since we'll be changing things (and borrowed from the Material UI Modal example)
A lot of code here, but it's all about making some sort of interface for users to create state variables with.

Currently we've got three state types - String, number, and boolean. Note that the number type allows for the possibility of floating numbers.

The new state types file will probably be used across other state variable files to ensure naming consistency (it works like an enum).

As of this commit, state variables don't save (gotta figure out how all that scenario/authoring context stuff works first)
StateVariables should be an array of objects for each scenario
Can now create state variables by calling the new endpoint
Implemented the frontend logic for creating new state variables

CreateStateVariable.jsx has the code for sending the API request

StateVariableMenu.jsx displays the state variables to the user (currently very crudely and should be updated)

Also note that the scenario is reFetch'd when the modal is closed
Boolean values weren't being displayed before
1. Resetting to default value was done improperly, it should be correct now

2. Numbers were being stored as strings, the change on line 129 should hopefully fix this
I keep forgetting I don't have it configured to format on save
Not sure what the status on UI updates is rn, but I thought I might as well quickly make a toast component (I don't think one exists yet??)
I feel so stupid for not noticing this
Turns out currentScenario and reFetch don't actually fetch the stateVariables (nor the role list). Since this PR is already kinda big, I'm just gonna remove it here and work on adding it back in next PR.
We want to allow decimals so Number() makes more sense
damn prettier so picky 🙄
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.

1 participant