-
Notifications
You must be signed in to change notification settings - Fork 184
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
Remove non-React UI code #1891
Remove non-React UI code #1891
Conversation
✅ Deploy Preview for fx-relay-demo canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes (mostly removals) in the python look good. Let's leave the url-referenced no-op views and empty templates in place just to minimize the risk of knock-on effects in this change (which is already really large).
I'd like @maxxcrawford, @codemist , and/or @lloan to check thru the SCSS changes too.
let foreground = FgImage.src; | ||
if (lang === "fr") { | ||
foreground = FgImageFr.src; | ||
} | ||
if (lang === "de") { | ||
foreground = FgImageDe.src; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion (non-blocking) kill let
with fire ...
let foreground = FgImage.src; | |
if (lang === "fr") { | |
foreground = FgImageFr.src; | |
} | |
if (lang === "de") { | |
foreground = FgImageDe.src; | |
} | |
const foreground = lang === "de" ? FgImageDe.src : lang === "fr" ? FgImageFr.src : FgImage.src; |
Though I think maybe in the past I asked to REMOVE a nested ternary expression? I guess I dislike let
more than I dislike nested ternary expressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can have neither using your old trick :) fe363f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vinnl @groovecoder if you want to get crazy, you could do this too, lol.
const foreground = {"de": FgImageDe.src, "fr": FgImageFr.src}[lang] ?? FgImage.src;
path('premium', views.premium_promo, name='premium-promo'), | ||
path('', views.home, name='home'), | ||
] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): Looks like we can also remove these entire view functions from privaterelay.views
: profile
, settings_view
, settings_update_view
, premium_promo
. Since they are not bound to any urls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, good one: 42131f0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need any patterns that are called by name by reverse
. The ones I see left in the code are faq
, home
, profile
(privaterelay/views.py line 58), fxa_login
, and relayaddress-detail
. So we need profile
back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sharp eye @jwhitlock! The reverse
for the profile never gets called though, because the view it's in in turn only exists for the URL to the homepage, and never gets rendered. Possibly I could replace the remaining views by empty functions, i.e. removing this reverse
call?
That said, it feels a bit weird to me to keep these views just to be able to call reverse
on them to generate a URL - I think the idea behind reverse
is to ensure links remain up-to-date even if URLs change? Which doesn't get achieved because the views don't represent "real" URLs. (Besides, URLs should remain valid anyway.) How would you feel about replacing all reverse
calls with direct references to the URLs they end up at?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you feel about replacing all reverse calls with direct references to the URLs they end up at?
I think that's a good plan, ship it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
privaterelay/urls.py
Outdated
path('faq', views.faq, name='faq'), | ||
# This route is still referred to in middleware.py, so leave it in | ||
# (even though the homepage is no longer rendered by Django): | ||
path('', views.home, name='home'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 fixes #1858
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is a tiny bit bittersweet 🥲
General Praise: Thanks for circling back on some requests from the Big One. That's some excellent callback!
As requested at:
Note: This will be a two-part review. Having to stop at my EOD.
frontend/src/components/Icons.tsx
Outdated
/** Icon of a question mark, that inherits the text color of its container */ | ||
export const HelpIcon = ({ | ||
alt, | ||
...props | ||
}: SVGProps<SVGSVGElement> & { alt: string }) => { | ||
return ( | ||
<svg | ||
role="img" | ||
aria-label={alt} | ||
aria-hidden={alt === ""} | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 16 15" | ||
width={16} | ||
height={15} | ||
style={{ | ||
fill: "currentcolor", | ||
...props.style, | ||
}} | ||
{...props} | ||
> | ||
<title>{alt}</title> | ||
<path d="M7.625 1.75c3.446 0 6.25 2.804 6.25 6.25s-2.804 6.25-6.25 6.25-6.25-2.804-6.25-6.25 2.804-6.25 6.25-6.25m0-1.25a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15z" /> | ||
<path d="M7.625 9.709A.625.625 0 0 1 7 9.084l0-.767c0-.527.37-.987.879-1.092.577-.12.996-.635.996-1.225a1.252 1.252 0 0 0-2.432-.409.626.626 0 0 1-1.181-.408A2.5 2.5 0 1 1 8.25 8.421l0 .663c0 .345-.28.625-.625.625z" /> | ||
<path d="m8 12-.75 0-.25-.25L7 11l.25-.25.75 0 .25.25 0 .75z" /> | ||
</svg> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once #1883 is merged, this can be replaced by SupportIcon.
frontend/src/components/Icons.tsx
Outdated
/** Icon of a chat bubble, that inherits the text color of its container */ | ||
export const MessageIcon = ({ | ||
alt, | ||
...props | ||
}: SVGProps<SVGSVGElement> & { alt: string }) => { | ||
return ( | ||
<svg | ||
role="img" | ||
aria-label={alt} | ||
aria-hidden={alt === ""} | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 16 15" | ||
width={16} | ||
height={15} | ||
style={{ | ||
fill: "currentcolor", | ||
...props.style, | ||
}} | ||
{...props} | ||
> | ||
<title>{alt}</title> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M2.423 0H13.577C14.9145 0.00165294 15.9983 1.0855 16 2.423V8.577C15.9983 9.9145 14.9145 10.9983 13.577 11H13V14C12.9999 14.4227 12.7341 14.7996 12.3361 14.9417C11.938 15.0837 11.4936 14.9601 11.226 14.633L8.26 11H2.423C1.0855 10.9983 0.00165294 9.9145 0 8.577V2.423C0.00165294 1.0855 1.0855 0.00165294 2.423 0ZM13.8761 8.87611C13.9554 8.79678 14 8.68919 14 8.577V2.423C14 2.18938 13.8106 2 13.577 2H2.423C2.18938 2 2 2.18938 2 2.423V8.577C2 8.68919 2.04457 8.79678 2.12389 8.87611C2.20322 8.95543 2.31081 9 2.423 9H8.734C9.03434 8.99975 9.31889 9.13449 9.509 9.367L11 11.194V10C11 9.44771 11.4477 9 12 9H13.577C13.6892 9 13.7968 8.95543 13.8761 8.87611ZM11.5 4H4.5C4.22386 4 4 4.22386 4 4.5C4 4.77614 4.22386 5 4.5 5H11.5C11.7761 5 12 4.77614 12 4.5C12 4.22386 11.7761 4 11.5 4ZM4.5 6H11.5C11.7761 6 12 6.22386 12 6.5C12 6.77614 11.7761 7 11.5 7H4.5C4.22386 7 4 6.77614 4 6.5C4 6.22386 4.22386 6 4.5 6Z" | ||
/> | ||
</svg> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once #1883 is merged, this can be replaced by ContactIcon.
HelpIcon, | ||
MessageIcon, | ||
NewTabIcon, | ||
SettingsIcon, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with #1883, this should actually use Cogwheel
.
@Vinnl Bleh. I know there's a ton of conflicts because this has been open for two weeks. Could you please catch this up (whenever you think is the best time of week to do this) to review/approve? Thanks! @jwhitlock mentioned this in the retro: If you wanted to break this up into separate, more focused/exploded PRs (not saying this one isn't), I'm happy to review that way too. Whatever works for ya! |
As called out at #1891 (comment)
b4bf17d
to
0018e22
Compare
@maxxcrawford Rebased and resolved conflicts, and I removed the parts that moved images next to where they were used → they're now in #1998. |
As called out at #1891 (comment)
efdc828
to
64c57a3
Compare
64c57a3
to
a35e9a4
Compare
Rebased and resolved conflicts again. |
a35e9a4
to
d4e9ee7
Compare
No more conflicts, but rebased again to be sure. |
This removes most of the views rendered by Django, linters applying only to those files, and the infra to compile Sass. It preserves the package.json file at the root, primarily for our Heroku configuration (to set the Node and npm versions, and the commands to run to build the website - i.e. heroku-postbuild), but also to list the one in `frontend` as an npm workspace, leading to an npm install in the root also running frontend/'s postinstall scripts and thereby set up the Git hooks. I've left the routes to the Django-rendered FAQ and home pages in place (even though those views are now empty), because they're still used to generate links. It might be more sensible to just replace those with direct links, but I'll let people with more Django experience decide on that. I've also left the template tags in place, in case they still come in useful when e.g. rendering the forwarded email.
`reverse` is useful to maintain links even if URLs change (which they shouldn't!), but since we were maintaining views that never get rendered (because they're replaced by static HTML, not rendered by Django), that benefit no longer plays out.
d4e9ee7
to
b53f5af
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shout out to @Vinnl for continuing to keep this monster PR up to date.
I went back into the old texts and looked at my initial "Gulp"'ify'ing PR to see if everything was removed, and it all looks correct.
I did find one file path that was not modified/removed from that PR:
Not sure if its still needed for our React frontend, or if it can also be removed. Lmk!
I'm good with this chapter to be finally closed. 🙏
@@ -48,8 +48,7 @@ | |||
{{ email_wrap_forwarded_from|safe }} | |||
{% if has_attachment %} | |||
{% ftlmsg 'nav-faq' as faq_text %} | |||
{% url 'faq' as faq_url %} | |||
{% with SITE_ORIGIN|add:faq_url as faq_url %} | |||
{% with SITE_ORIGIN|add:"/faq/" as faq_url %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Do we need to do some end-to-end email testing to make sure the FAQ paths are correct with these changes or they already in place? (Reworded: Is this actually making any customer facing link change, or just a refactor with the same end-result?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think http://127.0.0.1:8000/emails/wrapped_email_test is enough to test this template properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a refactor with the same end result, and just verified another time with the wrapped_email_test template that it does indeed render correctly, to be sure.
@@ -1 +0,0 @@ | |||
{% include "newlanding/a/index.html" %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question for @codemist: Is there anything from the previous Django homepage that wasn't ported over to React?
Ooo, AFAIK we only needed the node engine on heroku for django-gulp. Could even streamline heroku builds to remove it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Vinnl! ❤️
The buildpack is still needed I think, as the frontend is still built on Heroku, requiring Node (and of course Python for the back-end). |
As called out at #1891 (comment)
As called out at #1891 (comment)
As called out at #1891 (comment)
This PR removes all code that no longer runs, because it was used to generate the non-React UI:
wrapped_email.html
. That said, there are still empty templates for home and faq, since there is Python code referring to those routes to generate their URLs. My intuition would be that just referring to those URLs directly would be a better solution, but I'll defer to Django authorities on that./frontend/
) and stylelint (at the root, not in/frontend
) are removed.SERVE_REACT
are removed, and React is now served by default.package.json
at the root now refers to the one in/frontend
as a workspace. The file is still used to tell Heroku how to build, and this ensures that you can also just runnpm install
at the root. This does also result in a big update to thepackage-lock.json
at the root, which is the sole reason that this PR has more additions than deletions.Images are now co-located with the code that's using them, as requested in reviews of The Big One.→ extracted to Co-locate images with their usage site #1998.There's also an equivalent PR for the add-on, though it's independent from this one and needn't be merged at the same time.
How to test: basically, nothing should break anywhere!
This also fixes #1858 according to John.
/static/scss/libs/protocol/css/includes/tokens/dist/index.scss
).