-
Notifications
You must be signed in to change notification settings - Fork 0
disable button if no parameters have been changed #157
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 all commits
e07c9c6
2decf90
3a02c07
ed152a6
9de4abf
656b14a
faf266d
8f5f11a
98e37c5
f6f6dca
814d1f2
9566b3f
34b4a89
88a36ca
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 | ||||
|---|---|---|---|---|---|---|
| @@ -1,10 +1,11 @@ | ||||||
| import { Button } from "antd"; | ||||||
| import { Button, Tooltip } from "antd"; | ||||||
| import InputSwitch from "../InputSwitch"; | ||||||
| import "./style.css"; | ||||||
| import { | ||||||
| useSelectedRecipeId, | ||||||
| useFieldsToDisplay, | ||||||
| useIsPacking, | ||||||
| useIsOriginalRecipe, | ||||||
| } from "../../state/store"; | ||||||
|
|
||||||
| interface RecipeFormProps { | ||||||
|
|
@@ -15,6 +16,7 @@ const RecipeForm = ({ onStartPacking }: RecipeFormProps) => { | |||||
| const recipeId = useSelectedRecipeId(); | ||||||
| const fieldsToDisplay = useFieldsToDisplay(); | ||||||
| const isPacking = useIsPacking(); | ||||||
| const isOriginalRecipe = useIsOriginalRecipe(); | ||||||
|
|
||||||
| return ( | ||||||
| <div className="recipe-form"> | ||||||
|
|
@@ -39,15 +41,21 @@ const RecipeForm = ({ onStartPacking }: RecipeFormProps) => { | |||||
| </div> | ||||||
| )} | ||||||
| {recipeId && ( | ||||||
| <Button | ||||||
| onClick={onStartPacking} | ||||||
| color="primary" | ||||||
| variant="filled" | ||||||
| disabled={isPacking} | ||||||
| style={{ width: "100%" }} | ||||||
| <Tooltip | ||||||
| title={ | ||||||
| isOriginalRecipe ? "Adjust any parameter to re-run" : "" | ||||||
| } | ||||||
| > | ||||||
| Re-run | ||||||
| </Button> | ||||||
| <Button | ||||||
| onClick={onStartPacking} | ||||||
| color="primary" | ||||||
| variant="filled" | ||||||
| disabled={isPacking || isOriginalRecipe} | ||||||
| style={{ width: "100%" }} | ||||||
| > | ||||||
| <strong>Re-run</strong> | ||||||
|
||||||
| <strong>Re-run</strong> | |
| Re-run |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,10 +107,11 @@ export const useRecipeStore = create<RecipeStore>()( | |
| const remainingRecipesToLoad = recipeIds.filter( | ||
| (id) => id !== initialIdToLoad | ||
| ); | ||
| Promise.all(remainingRecipesToLoad.map((id) => loadRecipe(id))) | ||
| .catch((err) => { | ||
| console.error("Error loading remaining recipes:", err); | ||
| }); | ||
| Promise.all( | ||
| remainingRecipesToLoad.map((id) => loadRecipe(id)) | ||
| ).catch((err) => { | ||
| console.error("Error loading remaining recipes:", err); | ||
| }); | ||
| }, | ||
|
|
||
| selectRecipe: async (recipeId) => { | ||
|
|
@@ -340,6 +341,12 @@ export const useResultUrl = () => { | |
| return path; | ||
| }; | ||
|
|
||
| export const useIsOriginalRecipe = () => { | ||
| const recipe = useCurrentRecipeData(); | ||
| if (!recipe) return true; | ||
| return Object.keys(recipe.edits).length === 0; | ||
| }; | ||
|
|
||
|
Comment on lines
+344
to
+349
Contributor
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. FWIW I reintroduced Assuming this merges first I'll bring these changes over and use this selector |
||
| // Action selectors | ||
| export const useLoadInputOptions = () => | ||
| useRecipeStore((s) => s.loadInputOptions); | ||
|
|
||
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 CSS color change is unrelated to the PR's purpose of disabling the button based on parameter changes. This change should be removed or submitted in a separate PR.