meeting-calendar icon indicating copy to clipboard operation
meeting-calendar copied to clipboard

Add Editor Preview and move data fetching to its own context

Open senadir opened this issue 4 years ago • 2 comments

Hi!

First, thank you for this wonderful project, I always wanted to build one for a side project and to get to use one is wonderful. Following my talk with Kelly in slack, she suggested I can contribute.

So this PR does some things, notably: 1- It introduces an Editor preview by simply rendering the App component in the editor. for this to happen, I needed to create a new Context that fetches the data and pass it to EventProvider, I put it in a separate context to avoid calling the API each time the context updates, but I believe this can be mitigated if we save the fetch value in a ref and only fetch if that ref is null. 2- To keep compatibility, the context also accepts an optional data prop that has the event data, this allows us to hydrate the data from the server to avoid the initial request, using the same logic that was there. 3- This optional data will also allow us to pass a different kind of data to the editor, currently, I'm using real data, this can be swapped by a preview Data that can be passed the same way we pass the hydrated data

const EditView = () => (
	<Disabled>
		<Calendar data={ previewData } />
	</Disabled>
);

4- we move wporg-calendar-style registration to outside admin as well, so that it can render on the editor.

I'm also tagging @nerrad for a confidence check since I discussed some of those points with him.

image

senadir avatar Apr 12 '20 20:04 senadir

I understand why your instinct led you to add a new provider but I agree with @nerrad -- we probably don't need it. You can add it to the current EventProvider. If anything, we should make the team filtering logic more generic and move it downstream.

StevenDufresne avatar Apr 13 '20 04:04 StevenDufresne

Lastly, Thanks for jumping in on this block! Its always great having more contributors. :)

StevenDufresne avatar Apr 13 '20 04:04 StevenDufresne