Visual update and fix for scenario and scene selection #259
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This ticklet is an amalgamation of what should have been three separate PRs. Given the time constraints before demo, I am opting to do one PR to avoid merge conflicts.
SceneSelectionPage
.Proposed Visual Updates
Originally, this was going to be a simple home page touch up. However, due to the highly coupled nature of
ListContainer
which displays the user-created scenarios, assigned scenarios and scenes, a larger refactor was required.See below for the old design of the home page:
There were several improvements identified:
There are also underlying code structure issues:
ListContainer
effectively couplingListContainer
and outer components likeScenarioSelectionPage
andSceneSelectionPage
ListContainer
with duplicated code (literally copy+paste with minor modifications).ListContainer
is littered with conditional elements to also work as the scene selection page alongside the scenario selection page.The new design aims to address this with a major structural refactor.
Sidebar now is split into three distinct sections. 1) uoa logo, 2) scenario-related actions 3) app-related actions.
Sidebar buttons have now had icons added.
ListContainer
has now been refactored intoThumbnailList
which purely displays a list of thumbnails. The outer component pages are responsible for the heading and positioning of this list.MonaSans
has been applied to the titles, alongside an icon for good measureFixes to
SceneSelectionPage
When directly trying to access the scene's authoring tool, (e.g. via copy and pasting a URL with the scenario included like
http://localhost:5173/scenario/66ff60318aa1f312a9a9cf58
), the application would incorrectly return a 401 code, even when logged in.The expected behaviour here is that the authoring tool correctly loads.
The issue is due to insufficient consideration of our authentication loop, where the requests to fetch the scenario (by the ScenarioContext) are sent before the auth loop updates the user object to the logged-in user. This in turn results in a 401 as we do not have the Bearer token at the time of the requests.
The solution fixes the first oversight by adding a
skipRequest
flag to theuseGet
hook to conditionally skip the request (like when we do not have a user object) and simply re-requesting when we obtain the user object.However, because we don't actually load the "selected scenario" anywhere other than the main page (even though it is in our URL!), we must also fix the scene selection page to retrieve the scenario specified in the URL if the currently selected scenario is missing.
Fixes to the backend scenario endpoints
During testing of the above, another bug was exposed where the backend server would crash if given a malformed scenario ID. It implicitly trusted that all scenario ids requested would be well-formed, which is a poor assumption.
We introduce another middleware that checks for scenario ID validity, and rejecting any that is malformed before it gets to the data access objects. (Note that we check for validity, not existence!)