Overview
Given the following scenarios (1)
A user is editing a page on editor/canvas_page/1
The user clicks to edit a code component.
Once the user has finished editing the code component they want to go back to editing editor/canvas_page/1 again.
And (2)
A user is editing a page on editor/canvas_page/1
They create a new code component
After clicking "Add component" to expose the componenent they should be redirected back to editor/canvas_page/1 again
And (3)
A user is editing a page on editor/canvas_page/1
The user prompts the AI to create a component
The AI agent takes them to the code editor and generates a component
The AI needs to return the app to the /editor/canvas_page/1
Currently the "back" navigation is implemented by rendering the /code-editor/ as a child of the /editor/ route.
E.g.
/editor/canvas_page/1/code-editor/code/foo
This leads to issues* when sharing the URL (and adds lots of extra config in our React Routes definition.
* Issues like when a non-privaledged user (who can't edit canvas_page/1) receives a link to edit a code component from a privileged user (who can edit canvas_page/1), they will be shown a "Back" button that takes them to a page they don't have permission to see.
Proposed resolution
Store the previously edited thing in Redux.
Use the value when returning a user to the place from whence they came.
Remove the routes e.g. /editor/canvas_page/1/code-editor/code/foo
so that the only way to get to the code editor is via a route like /code-editor/code/foo
User interface changes