-
Notifications
You must be signed in to change notification settings - Fork 0
RecipeMetadata and prefetching optimizations #151
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
Changes from 4 commits
e07c9c6
2decf90
3a02c07
0c886b5
ed152a6
adbd622
df1c6df
fc79530
22a5672
5d3a689
9de4abf
656b14a
faf266d
9fd8319
fb23431
8f5f11a
98e37c5
f6f6dca
d5e6f1c
725b614
fe4a840
2e789a4
f23c4fa
3442ed7
273c4e1
b832ba2
efa33c5
73b06cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,15 +3,12 @@ import { Tabs } from "antd"; | |
|
|
||
| import { | ||
| useSelectedRecipeId, | ||
| useCurrentRecipeString, | ||
| useFieldsToDisplay, | ||
| useInputOptions, | ||
| useIsLoading, | ||
| useLoadInputOptions, | ||
| useSelectRecipe, | ||
| useUpdateRecipeString, | ||
| useStartPacking, | ||
| useLoadAllRecipes, | ||
| useCurrentRecipeObject, | ||
| useInputOptions, | ||
| useLoadInputOptions, | ||
| } from "../../state/store"; | ||
| import Dropdown from "../Dropdown"; | ||
| import JSONViewer from "../JSONViewer"; | ||
|
|
@@ -29,15 +26,12 @@ interface PackingInputProps { | |
| const PackingInput = (props: PackingInputProps): JSX.Element => { | ||
| const { startPacking } = props; | ||
| const selectedRecipeId = useSelectedRecipeId(); | ||
| const recipeString = useCurrentRecipeString(); | ||
| const fieldsToDisplay = useFieldsToDisplay(); | ||
| const recipeObj = useCurrentRecipeObject(); | ||
| const inputOptions = useInputOptions(); | ||
| const isLoading = useIsLoading(); | ||
|
|
||
| const loadInputOptions = useLoadInputOptions(); | ||
| const loadAllRecipes = useLoadAllRecipes(); | ||
| const selectRecipe = useSelectRecipe(); | ||
| const updateRecipeString = useUpdateRecipeString(); | ||
| const storeStartPacking = useStartPacking(); | ||
|
|
||
| const preFetchInputsAndRecipes = useCallback(async () => { | ||
|
|
@@ -54,15 +48,12 @@ const PackingInput = (props: PackingInputProps): JSX.Element => { | |
| await storeStartPacking(startPacking); | ||
| }; | ||
|
|
||
| const handleRecipeStringChange = (newString: string) => { | ||
| if (selectedRecipeId) { | ||
| updateRecipeString(selectedRecipeId, newString); | ||
| } | ||
| }; | ||
| const loadingText = (<div>Loading...</div>) | ||
|
|
||
| if (isLoading) { | ||
| return <div>Loading...</div>; | ||
| } | ||
| // No recipe or dropdown options to load | ||
| if (!recipeObj && !inputOptions[selectedRecipeId]) { | ||
| return loadingText; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
|
|
@@ -75,19 +66,19 @@ const PackingInput = (props: PackingInputProps): JSX.Element => { | |
| onChange={selectRecipe} | ||
| /> | ||
| </div> | ||
| <Tabs defaultActiveKey="1" className="recipe-content"> | ||
| <Tabs.TabPane tab="Edit" key="1"> | ||
| <RecipeForm onStartPacking={handleStartPacking} /> | ||
| </Tabs.TabPane> | ||
| <Tabs.TabPane tab="Full Recipe" key="2"> | ||
| <JSONViewer | ||
| title="Recipe" | ||
| content={recipeString} | ||
| isEditable={fieldsToDisplay === undefined} | ||
| onChange={handleRecipeStringChange} | ||
| /> | ||
| </Tabs.TabPane> | ||
| </Tabs> | ||
| {/* Options menu loaded, but no recipe to load yet */} | ||
| {!recipeObj ? ( | ||
| loadingText | ||
| ) : ( | ||
| <Tabs defaultActiveKey="1" className="recipe-content"> | ||
| <Tabs.TabPane tab="Edit" key="1"> | ||
| <RecipeForm onStartPacking={handleStartPacking} /> | ||
| </Tabs.TabPane> | ||
| <Tabs.TabPane tab="Full Recipe" key="2"> | ||
| <JSONViewer title="Recipe" content={recipeObj} /> | ||
| </Tabs.TabPane> | ||
| </Tabs> | ||
| )} | ||
|
Comment on lines
+70
to
+81
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There isn't a good reason to prevent this panel from loading once the first recipe has been fetched, but I figured showing the loading marker was in line with our overall design pattern, and it should only be visible very briefly if the user selects a recipe right after the dropdown populates. |
||
| </> | ||
| ); | ||
| }; | ||
|
|
||
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.
personally I still like the term manifest but I'm not super attached to it. it's what we use in other apps like CFE for this same type of data
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.
Oh sure I like manifest too, for some reason I thought you said at our 1:1 that you wanted it called metadata.
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.
oh, I think I was just using that as a category term, sorry!