-
Notifications
You must be signed in to change notification settings - Fork 1
Settings Progress 2 - Template Edit / Save Proof of Concept #406
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
Conversation
…tch async bugs in programming see potential bug in server-database in WriteTemplateTOML
…p-compatible data
I'm going to rewrite SettingsContext to hold viewData, not a dictionary of layered properties
next use viewstate as Context and pass dotProp instead of propDefs to subcomponents
# Conflicts: # app/view/netcreate/components/NCAdvancedPanel.jsx
…uscate actual errors
… PropertyGroup, TextInput, and useReducer and useContext the TEMPLATE TOML file now has _ui.propertyName and _ui._editor.global for adding UI metadata to control Settings
I can edit a TextInput, and the state updates from direct input.
…rsist to disk yet
…e, but inputValue has to remain for controlled inputs
fix issue 402, remove unnecessary indirection from async and nested functions
…ip out stuff in to-be-deprecated NCTemplate
removes confusion
…t-settings-bridge also ViewLib since we had to use React components, and the yaml versions of template
…STATE' This is only used by the lockstate manager, and the use of "LOCK" reinforces the model instead of obfuscating it
also cleaned-up most debug output
Confirmed tests passed. Additional tests:
@dsriseah Works according to tests. I'm guessing this is is future work, but just noting that we'll have to lock down the settings (and template) during template imports and node and edge imports. I can probably take care of that once this PR is in. |
To confirm: it did work as expected?
Those are different panels, and are outside the scope of Settings Editor and Property Editing UI; getting this part to work independently was the goal. The import system still uses the legacy locking system. |
Adding the Import tests to Next Phase work (not part of this scope) |
I am now starting prop-settings-3 branch |
Sorry. Yes, it did work as expected.
I figured that was true. Just wanted to note it for future reference. Thanks!! |
Reconfirmed with a test merge into dev-dhi. Merging! |
This PR implements a rudimentary user interface that edits the existing TEMPLATE structure as a proof of concept. Currently, only simple settings are supported, but this PR does have the bones to add more user interface features that can be saved to the
[dataset]-template.TOML
file using the existing NetCreate conventions.Phase 3 will handle the six remaining property settings, which require more complex UI programming:
Also:
Currently these can be edited manually in the template. Phase 3 will provide the user interface for these.
Note
Previously in PR #400, we had started to implement a clean slate modular template system to exist alongside the legacy TEMPLATE structure which conformed to clean top-down dataflow architecture used in our simulation systems. However, after many surprises, we found that React itself is highly resistant to this kind of architecture. For expediency, we were forced to abandon the approach and archive it in the URSYS repo for future apps launches (and show React the airlock along the way)
TESTING
danishpowers
Modify Settings
The Settings Panel allows you to change items until you are ready to save them. If you change your mind, you can revert your changes.
Test Settings Locking
Test the Template Files
app-templates/_default.template.toml
and note the addition of the new_ui
key.template.toml
file that doesn't have the_ui
keys, and load it through./nc.js --dataset=olddataset
.template.toml
file again to see that the_ui
keys have been addedKNOWN ISSUES
CHANGE NOTES
default.template.toml
now includes a_ui
object that contains metadata used for rendering the user interface. The template migration and validation methods in server-database.js have been updated as well.React.useReducer()
{draft, hasLock, dispatch }
as<SettingsContext.Provider value>
to make draft settings available to all children, bypassing the need from prop drilling; this value is generated on rerender whenever the React useReducer hook'sdispatch
function is used, which causes all its children to rerender (secret React sauce)useEffect
hooks to to use callLockTemplate()
andReleaseTemplate()
on mounthasLock
throughconst { hasLock } = useContext(SettingsContext)
to determine whether to enable/disable editinguseState
hooks to represent dynamic data, as all React components must be "controlled". When state relies on external data, the values of state is set throughuseEffect
because the initial state assign works only once despite it appearing at the top of the code, thanks to the "magic" of React.