-
Notifications
You must be signed in to change notification settings - Fork 8
fix: add error handling to stepper steps #680
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,6 +4,8 @@ import { StepLabel } from "@databiosphere/findable-ui/lib/components/Stepper/com | |||||
import { StepProps } from "../types"; | ||||||
import { Button } from "@mui/material"; | ||||||
import { BUTTON_PROPS } from "@databiosphere/findable-ui/lib/components/common/Button/constants"; | ||||||
import { StepError } from "../components/StepError/stepError"; | ||||||
import { getStepActiveState, getButtonDisabledState } from "../utils/stepUtils"; | ||||||
|
||||||
export const LaunchStep = ({ | ||||||
active, | ||||||
|
@@ -14,12 +16,21 @@ export const LaunchStep = ({ | |||||
status, | ||||||
}: StepProps): JSX.Element => { | ||||||
return ( | ||||||
<Step active={active} completed={completed} index={index}> | ||||||
<Step | ||||||
active={getStepActiveState(active, status.loading)} | ||||||
completed={completed} | ||||||
index={index} | ||||||
> | ||||||
<StepLabel>{entryLabel}</StepLabel> | ||||||
<StepContent> | ||||||
<StepError error={status.error} /> | ||||||
<Button | ||||||
{...BUTTON_PROPS.PRIMARY_CONTAINED} | ||||||
disabled={status.disabled || status.loading} | ||||||
disabled={getButtonDisabledState( | ||||||
status.disabled, | ||||||
status.loading, | ||||||
!!status.error | ||||||
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. The
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
)} | ||||||
onClick={onLaunchGalaxy} | ||||||
> | ||||||
Launch In Galaxy | ||||||
|
16 changes: 16 additions & 0 deletions
16
...uts/components/Main/components/Stepper/components/Step/components/StepError/stepError.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Typography } from "@mui/material"; | ||
import { TYPOGRAPHY_PROPS } from "@databiosphere/findable-ui/lib/styles/common/mui/typography"; | ||
|
||
export interface StepErrorProps { | ||
error: string | null; | ||
} | ||
|
||
export const StepError = ({ error }: StepErrorProps): JSX.Element | null => { | ||
if (!error) return null; | ||
|
||
return ( | ||
<Typography variant={TYPOGRAPHY_PROPS.VARIANT.TEXT_BODY_400} color="error"> | ||
Error: {error} | ||
</Typography> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...igureWorkflowInputs/components/Main/components/Stepper/components/Step/utils/stepUtils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Determines if a step should be active based on loading and error states | ||
* @param active - Whether the step should be active | ||
* @param isLoading - Whether the step is currently loading | ||
* @returns Whether the step should be active | ||
*/ | ||
export const getStepActiveState = ( | ||
active: boolean, | ||
isLoading: boolean | ||
): boolean => { | ||
return active && !isLoading; | ||
}; | ||
|
||
/** | ||
* Determines if a button should be disabled based on various states | ||
* @param baseDisabled - Base disabled state | ||
* @param isLoading - Whether currently loading | ||
* @param hasError - Whether there is an error | ||
* @returns Whether the button should be disabled | ||
*/ | ||
export const getButtonDisabledState = ( | ||
baseDisabled: boolean, | ||
isLoading: boolean, | ||
hasError?: boolean | ||
): boolean => { | ||
return baseDisabled || isLoading || !!hasError; | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
!!error
conversion is redundant sincegetButtonDisabledState
already handles the truthy conversion with!!hasError
internally.Copilot uses AI. Check for mistakes.