-
Notifications
You must be signed in to change notification settings - Fork 78
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
Standalone React and Headless Rails applications #6287
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
purfectliterature
changed the title
Standalone React application, Headless Rails server
Standalone React and Headless Rails applications
Jul 20, 2023
purfectliterature
force-pushed
the
phillmont/spa-letsgo
branch
11 times, most recently
from
July 25, 2023 06:21
c5dc21a
to
b5c9690
Compare
purfectliterature
force-pushed
the
phillmont/spa-letsgo
branch
5 times, most recently
from
August 1, 2023 03:21
3a3125e
to
d270e32
Compare
purfectliterature
added
Enhancement
Technical Story
Feature
UI
Ruby
Pull requests that update Ruby code
JavaScript
Pull requests that update JavaScript code
labels
Aug 1, 2023
purfectliterature
force-pushed
the
phillmont/spa-letsgo
branch
6 times, most recently
from
August 1, 2023 09:42
3aca1c3
to
9e0489e
Compare
Relevant means if there are >1 enrolled courses or not in CoursesIndex. If in CoursesIndex and there are no enrolled courses, do not show the Courses button.
ekowidianto
force-pushed
the
phillmont/spa-letsgo
branch
from
August 10, 2023 00:58
0d1feca
to
9263d5d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Enhancement
Feature
JavaScript
Pull requests that update JavaScript code
Ruby
Pull requests that update Ruby code
Technical Story
UI
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.
This PR splits Coursemology into two apps: a standalone React app and headless Rails app. Both apps are independent of each other and must be bootstrapped on different processes. The default HTML entry point to the app is now the standalone React app.
Note
At this stage, we cannot afford to make the Rails app API-only. Cookies (and cookie-based sessions), CSRF protection, and more are not available by default in an API-only Rails app. Manual extensions and tests will need to be done to go API-only.
Development changes
lvh.me
to access the app. This enables multi-tenancy on local environments.Run
host lvh.me
on your Terminal to bindlocalhost
and127.0.0.1
tolvh.me
. Then, access the React app onlvh.me:8080
and the Rails app onlvh.me:5000
(or your set ports). You can now develop on other instances, e.g.,nushigh.lvh.me
.It proxies requests with
?format=json
and rewrites theOrigin
header to please CORS. See thedevServer
key onwebpack.dev.js
for more information.Bootstrap both React and Rails app on separate processes. This also makes it way easier to use Byebug since Foreman cannot show standard inputs.
Existing Capybara tests still work, and can be updated or extended if needed as we discover edge cases or bug fixes. But new tests should be written with Playwright.
yarn build:test
now setsBABEL_ENV
to something else thanproduction
.This is done to ensure
data-testid
attributes are not removed during webpack's production build..env
inclient
if you haven't already. Then add this entry for reCAPTCHA.This is the same testing key as the one in the Rails app. If the site key in Rails app changes, make sure you update this too.
Important
We'd probably need to rewrite our Getting Started guide at some point. Maybe sometime after we set up our repo for the Go server.
Note
Playwright tests currently live in
tests/tests
. The idea is to have ALL end-to-end tests undertests
. Then we can havetests/playwright
andtests/capybara
, for example, and bootstrap them with appropriatescripts
intests/package.json
. I'm not sure if we can strip out Capybara tests from the Rails app, though.We're going to move some files and folders around once we start writing some Go codes, anyway. So, I envision the root of the repo will have folders like:
client
,api-v1
,api-v2
,tests
, and any other environments/configs/CI files. We can have one script (maybepackage.json
) containing all the configs (environment variables, ports, etc.) at the root of the project.CircleCI pipeline changes
build_client
job to build and cache client.test_playwright
job for Playwright tests.build_client
,test_playwright
,jslint
, andjstest
now use CircleCI's Node convenience image.jslint
andjstest
now don't build client since it's unnecessary.vendor/recorderjs/node_modules
.i18n
toi18n_en
andi18n_zh
.i18n_en
is now required for merging tomaster
.test
is nowtest_rspec
.lint
is nowfactorybot_lint
.Note
After this PR is merged, we need to remove
ci/circleci: test
andci/circleci: lint
frommaster
's branch protection settings. Until then, ignore the pending results forlint
andtest
in below status checks.Notable changes
Webpack injects the bundled JavaScript scripts with
HtmlWebpackPlugin
.index.tsx
now immediately binds ReactDOM on script load.Sign in, Sign out, Forgot password, Reset password, and Resend confirmation email pages.
These pages are code-split. The contents of these pages are rendered in Markdown. There's a new component,
MarkdownPage
.UnauthenticatedApp
andAuthenticatedApp
.They are code-split.
ScribingViewComponent
now lazy loads itsfabric
- andreact-color
-dependent children.They are code-split.
CssBaseline
.Some components and pages that were using bare HTML elements, e.g.,
h4
,span
, etc., were converted to their appropriate counterparts withTypography
.NotificationPopup
toasts' styles are now standardised./
when authenticated now routes to a dashboard page: list of courses with and sorted by last accessed times.If the user has only one course, it will automatically redirect to that course. If the user has no courses, it will automatically redirect to
/courses
.session
store that stores i18n config and authentication state.This is intended to be extended further in the future to include authentication details, permissions, actual session IDs, etc., if needed.
Before making any non-GET requests, it will request a fresh CSRF token and cache it if not already, expired, or invalid. It will continue requesting GET to
/csrf_token
until the non-GET request gets through, for a maximum of 3 times.CanCan::AccessDenied
403 to the Sign In and Forbidden pages./attempt
URLs.This way, there's no need for manually GET-ting to
/attempt
and redirect programmatically. This also allows users to Open Link in New Tab on these buttons.ErrorBoundary
now also prints out the rawError
stack.lib/server-context.js
.There's no need to infer Rails controller name in React. I18n config and CSRF token are managed by
I18nProvider
and the base Axios client, respectively.lib/axios.js
.Page
now renders aFragment
to reduce extradiv
nesting.PopupMenuButton
now supports asecondary
title/component.Accordion
now supports a customicon
component.expect_forbidden
matcher.login_as
andlogout
performers (supersedes Warden's).devDependencies
.SearchField
s.onKeyDown
function is not invocable inTextField
s.UserEmailSubscriptions
page.CoursesIndex
not opening New Course dialog when?new=true
when loading.For full changelog, refer to the commit history.
Deployment changes
/static/*
,/*
, and?format=json
to rewrite them to the static files,/index.html
, and the Rails server, respectively.