-
Notifications
You must be signed in to change notification settings - Fork 257
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
Move WordPress & Gutenberg PR Preview to Playground website #1938
base: trunk
Are you sure you want to change the base?
Conversation
@adamziel Tell me, due to moving this functionality to Playground, should we remove the wordpress.html and gutenberg.html files? FYI, I'm setting this PR as Draft for now, because I'm waiting for the changes to be accepted with other modals. After implementing those changes, I'll add this refactor of all modals -> headers and action buttons. |
Good question! There are existing links to those files out there so adding a redirect to custom-redirects-lib.php seems like the best option. Looping in @brandonpayton.
One of them is now merged 🎉 And the other one has a last bit of pending feedback. I'm happy to merge once it's addressed. Thank you so much for contributing! |
Hi @ajotka! We could add a redirect for https://playground.wordpress.net/?state=github-export If the PR Preview modals were controlled in a similar way, we could add redirects to open them. Here is the code that controls the GitHub Export modal visibility: wordpress-playground/packages/playground/website/src/github/github-export-form/modal.tsx Lines 7 to 32 in 65c4a92
I'm not sure it's great for each modal to control its own visibility, but it should work OK for now. |
Ah, I see how we are controlling other modal visibility via redux state. I think we'll need to have a way to link to certain modals or initialize that redux state if we want to redirect the old |
Oh, good! I see how #1908 should make all modals addressable via query param: At least it looks that way. I haven't tested it. If modals are indeed addressable via query param after #1908, we should have no problem adding redirects after this PR is merged. I added #1969 to track this. |
# Conflicts: # packages/playground/website/src/components/layout/index.tsx
Refactor is ready 🎉 @adamziel @brandonpayton URL params for PR modals: Note: It would be good to merge #1908 to trunk first, because I used logic from there. |
I merged the latest from trunk into this PR, so changes from #1908 are here now. Planning to review shortly. |
This is nice. It makes more sense IMO. |
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.
Hi @ajotka, I reviewed this and left some comments. Overall, it looks like a nice change, but I think some reorganization would be helpful before we merge.
onChange={setUrl} | ||
/> | ||
|
||
<ModalButtons |
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.
@@ -33,6 +33,7 @@ import { | |||
setSiteManagerOpen, | |||
} from '../../lib/state/redux/slice-ui'; | |||
import { ImportFormModal } from '../import-form/modal'; | |||
import { PreviewPRModal } from '../../github/preview-pr/modal'; |
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.
The way the modal modules are laid out is a bit different than usual module layout.
Here, we are importing '../import-form/modal'
which internally imports import-form/index
. This surprised me because index
typically represents the main/root export of a component.
Can we reorganize these modal modules and imports so that /index
is the main representation of a component to other modules?
For import-form
, it might look something like:
import-form-modal/index
exportsImportFormModal
as the default export- The modal imported like
import ImportFormModal from '../import-form-modal';
The current organization works, but it's a bit backwards in the way it uses /index
. I think we can make it more typical so it gives tomorrow's developers (and ourselves) nothing additional to think about when reading this code.
export default function ModalButtons({ submitText = 'Submit', areDisabled = false, areBusy, onCancel, onSubmit }: ModalButtonsProps) { | ||
return ( | ||
<Flex | ||
justify={'end'} |
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.
It's not a big deal, but if we're using a string, we can say just justify="end"
, without the curly braces.
import GitHubExportForm, { GitHubExportFormProps } from './form'; | ||
import { usePlaygroundClient } from '../../lib/use-playground-client'; | ||
import { PlaygroundDispatch } from '../../lib/state/redux/store'; | ||
import { useDispatch } from 'react-redux'; | ||
import { setActiveModal } from '../../lib/state/redux/slice-ui'; | ||
import { useEffect } from 'react'; | ||
import css from '../../components/modal/style.module.css'; |
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.
If we are still using these styles everywhere, maybe we should restore the components/modal/index
module, apply the styles in that one place, and then go back to importing Modal from components/modal
rather than directly from @wordpress/components
.
Seeing this needed for all the modals suggests that maybe we ultimately do have a Playground Modal. And if there are any places where that is too much, it would be OK for those to use @wordpress/components
directly.
Does that sound reasonable?
@@ -430,10 +430,10 @@ export default function GitHubExportForm({ | |||
if (pushResult) { | |||
return ( | |||
<form id="export-playground-form" onSubmit={handleSubmit}> | |||
<h2 tabIndex={0} style={{ marginTop: 0, textAlign: 'center' }}> | |||
<h3> |
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.
Why did these change from <h2>
to <h3>
? It doesn't look like there are any other <h2>
's in the modal. The modal title appears to be an <h1>
.
@@ -10,9 +10,9 @@ import { | |||
Icon, | |||
__experimentalItemGroup as ItemGroup, | |||
__experimentalItem as Item, | |||
Flex, | |||
Flex, DropdownMenu, |
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.
Nit: These should be on separate lines because the rest are line-separated.
{/* Remove Playground logo because branding isn't finalized. */} | ||
{/* <Logo className={css.sidebarLogoButton} /> */} | ||
</div> | ||
{/* Padding 3px is because of focus on dropdown button */} |
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.
Thank you for this "why" comment.
Motivation for the change, related issues
#1655 (comment)
I moved wordpress.html and gutenberg.html to Playground itself.
By the way, I also made a mini appearance refactor for the modal, based on Figma. And I used components from WordPress packages.
Implementation details
Testing Instructions (or ideally a Blueprint)
Homepage buttonfuture Logo placeIt is also possible to open modal via URL params:
/?modal=preview-pr-wordpress or /?modal=preview-pr-gutenberg