-
Notifications
You must be signed in to change notification settings - Fork 48
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
Blueprints: Add import Wizard (HMS-3690) #1928
Conversation
@@ -96,15 +102,25 @@ export const ImportBlueprintModal: React.FunctionComponent< | |||
<HelperText> | |||
<HelperTextItem variant={isRejected ? 'error' : 'default'}> | |||
{isRejected | |||
? 'Must be a JSON file no larger than 1 KB' | |||
? 'Must be a JSON file no larger than 6 KB' |
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.
In case we want to export even the gpg key and overall everything, 1 KB does not seem to be enough.
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.
with the first boot script it can be larger, I guess we can increase it a bit more.
Should this be working, @avitova? When I tried importing a blueprint, I just got kicked back to the table. |
@lucasgarfield Yeah, you are right, let me correct this:) |
4091f07
to
37a85ab
Compare
85a5ba7
to
916aaf2
Compare
Rebase done. I have also incorporated toast notification for when something goes wrong with the import. :) Thoughts? @lucasgarfield @amirfefer |
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.
Thanks @avitova, this looks and works great! 👍
I have a suggestion regarding the json parsing
@@ -96,15 +102,25 @@ export const ImportBlueprintModal: React.FunctionComponent< | |||
<HelperText> | |||
<HelperTextItem variant={isRejected ? 'error' : 'default'}> | |||
{isRejected | |||
? 'Must be a JSON file no larger than 1 KB' | |||
? 'Must be a JSON file no larger than 6 KB' |
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.
with the first boot script it can be larger, I guess we can increase it a bit more.
const importedBlueprint: BlueprintResponse = JSON.parse(blueprint); | ||
const importBlueprintState = mapRequestToState(importedBlueprint); |
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.
I suggest to parse the json before the router transition and loading the wizard, but after the user uploads the data in the import modal, this allows us to verify whether it complies with the blueprintResponse first. Then we can propagate the blueprint request object in the router's state.
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.
I agree, thank you for this idea. :)
e91f59f
to
94624c7
Compare
I addressed your comments @amirfefer :) Ready for re-review. |
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.
const [importedBlueprint, setImportedBlueprint] = React.useState( | ||
{} as wizardState |
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.
no need to use as
here
const [importedBlueprint, setImportedBlueprint] = React.useState( | |
{} as wizardState | |
const [importedBlueprint, setImportedBlueprint] = React.useState<wizardState>() |
@@ -49,17 +61,27 @@ export const ImportBlueprintModal: React.FunctionComponent< | |||
setJsonContent(value); | |||
}; | |||
const handleDataChange = (_: DropEvent, value: string) => { | |||
setJsonContent(value); | |||
try { | |||
const importedBlueprint = JSON.parse(value) as BlueprintResponse; |
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.
ditto
const importedBlueprint = JSON.parse(value) as BlueprintResponse; | |
const importedBlueprint: BlueprintResponse = JSON.parse(value); |
: 'Upload a JSON file'} | ||
</HelperTextItem> | ||
</HelperText> | ||
</FormHelperText> | ||
</FormGroup> | ||
<ActionGroup> | ||
<Button type="button">Review and finish</Button> | ||
<Button |
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.
can you please add ouid
prop for testing?
); | ||
} | ||
}, [blueprint, dispatch]); | ||
return <CreateImageWizard startStepIndex={1} />; |
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 is the reason why this fails to build, startStepIndex
prop no longer exists, and isn't needed here, the default is 1 anyway.
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.
Thank you for working on this! Added some comments
ouiaId="import-blueprint-finish" | ||
> | ||
Review and finish | ||
</Button> |
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.
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.
Thank you for catching this!
b6341cf
to
998ead3
Compare
So I added a test and rebased. The tests mostly cover which files should be accepted and which should not. It is quite plain, but I think that we can go with this for a while. |
@avitova Looks great! Can you please resolve the conflict and rebase? |
@regexowl rebased:) |
/retest |
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.
Excellent, thank you! Looks and works great 🚀
/retest |
3 similar comments
/retest |
/retest |
/retest |
🥳 Thank you! |
Sooo...I think we are ready for a discussion on what we want to export AND import, since this is ready. :)