Skip to content
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

feat(app): validate factory mode slideout input #15025

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

brenthagen
Copy link
Contributor

Overview

add validation and errors to input on factory mode slideout initial step

closes PLAT-281

Test Plan

manually verified error states and validation

Changelog

  • Validates factory mode slideout input

Review requests

check the input field for correct validation and errors

Risk assessment

low

add validation and errors to input on factory mode slideout initial step

closes PLAT-281
@brenthagen brenthagen requested review from vegano1 and a team April 26, 2024 14:09
@brenthagen brenthagen requested a review from a team as a code owner April 26, 2024 14:09
@brenthagen brenthagen requested review from mjhuff and removed request for a team and mjhuff April 26, 2024 14:09
@@ -58,6 +61,10 @@ export function FactoryModeSlideout({
)
const isOEMMode = oemModeSetting?.value ?? null

const robot = useRobot(robotName)
const sn = robot?.status != null ? getRobotSerialNumber(robot) : null
const last = sn?.substring(sn.length - 4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this throw if const sn is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think it's necessary - last will be undefined in that case and never pass validation. i think the better move is to disable the initial "Setup mode" button if sn is null to prevent opening the slideout

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

): Record<string, FieldError> => {
const factoryModeInput = data.factoryModeInput
let errorMessage: string | undefined
if (factoryModeInput.length > 0 && factoryModeInput !== last) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we handle empty input factoryModeInput.length == 0 here? or is this handled elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha, yes we should. good catch

@@ -153,7 +192,11 @@ export function FactoryModeSlideout({
footer={
<>
{currentStep === 1 ? (
<PrimaryButton onClick={handleSubmitFactoryPassword} width="100%">
<PrimaryButton
disabled={errors.factoryModeInput != null}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so this handles empty input, cool

Copy link
Contributor

@vegano1 vegano1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few very minor comments, mostly for clarification on my end.
Otherwise, this looks good to me.

@brenthagen brenthagen merged commit 39eafa2 into edge Apr 26, 2024
20 checks passed
@brenthagen brenthagen deleted the app_factory-mode-input-validation branch April 26, 2024 16:09
Carlos-fernandez pushed a commit that referenced this pull request May 20, 2024
add validation and errors to input on factory mode slideout initial step

closes PLAT-281
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants