-
Notifications
You must be signed in to change notification settings - Fork 53
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
src: Add on prem blueprints import support (HMS-4683) #2519
base: main
Are you sure you want to change the base?
Conversation
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.
What's the status here? should I test it out?
const isToml = filename.endsWith('.toml'); | ||
const isJson = filename.endsWith('.json'); | ||
if (isToml) { | ||
var toml = require('toml'); |
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.
ugh... I'd rather import it globaly... (not sure why, but I think combining require and import is a no-no in JS)
5d1300a
to
f02df31
Compare
@@ -77,7 +77,7 @@ const PackageRecommendations = () => { | |||
}, | |||
}); | |||
|
|||
if (response && response.data && response.data.packages.length > 0) { | |||
if (response && response.data && response.data.packages && response.data.packages.length > 0) { |
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 not related, but I was getting some errors, and I believe that we need to check for this too.
cb0b3ad
to
d4a5800
Compare
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #2519 +/- ##
==========================================
+ Coverage 83.93% 83.96% +0.03%
==========================================
Files 162 163 +1
Lines 17950 18034 +84
Branches 1796 1814 +18
==========================================
+ Hits 15066 15143 +77
- Misses 2862 2869 +7
Partials 22 22
Continue to review full report in Codecov by Sentry.
|
/retest |
1 similar comment
/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.
Just few ideas inline :)
@@ -0,0 +1,155 @@ | |||
import { |
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.
Capital first letter is usually a React component, this is just a helper function, I'd name it with lower case first letter. possibly even place it in helpers/
sub folder.
blueprintFromFile, | ||
[] | ||
); | ||
setImportedBlueprint(importBlueprintState); |
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.
Should we show some warning, that this is a best effort import?
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.
Let me know how you like that one I came up with. We can adjust it. :)
dispatch( | ||
addNotification({ | ||
variant: 'warning', | ||
title: 'No blueprint was build', |
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 know this is just a copy, but the warning is probably incorrect, we should say something like "File is not a valid blueprint"
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 believe this was according to mocks, but I am happy to change it.
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.
Mocks are not always 100% tought through, this case I feel like it could have been copy pasted from other mock.
What I'm interested in is whether my comment makes sense to you, or if I just don't get why this might be actually correct message :)
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.
Well, I feel like the notification might make sense. We already inform in the warning at the bottom of the text field that the format is not compatible with our blueprints. So this one just made sense to me, so that users know that we did not create any blueprint just from the fact that they uploaded the file. We can discuss this with Kelsea, but I think this is a minor thing:)
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.
Yeah, totaly minor, if you feel this is good, lets keep it :)
/retest |
1 similar comment
/retest |
Okay, I addressed all the comments, thanks for the review! |
683af5b
to
4c804ac
Compare
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'm good here, but merging with the current CI state might be difficult xD
FTR: I've tested this with toml and seems fine, just one nit :)
const [importedBlueprint, setImportedBlueprint] = | ||
React.useState<wizardState>(); | ||
const [isInvalidFormat, setIsInvalidFormat] = React.useState(false); | ||
const [filename, setFilename] = React.useState(''); | ||
const [isLoading, setIsLoading] = React.useState(false); | ||
const [isRejected, setIsRejected] = React.useState(false); | ||
const [isOnPrem, setIsOnPrem] = React.useState(false); |
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.
You might want to reset this flag in onClear
handler.
This pull request relates to #4683.
We want to support import on prem blueprints in our import feature. This enables importing toml blueprints that get automatically detected, and parsed.
A lot of fields we need to ignore, a lot of fields from our blueprints are not in the on-prem blueprint structure. This is our first attempt to allow on-prem blueprint, and it will get us more information whether users would use it or not. We also need to add a method to measure the usage of this feature. This is not here yet, and I would like to do it as a follow up, as it can raise discussions, and we do not want to block this feature on it.
We will bring a different solution, so eventually, we will get rid of this mapper. But the other solution that should be more "bulletproof" will take time, in the meantime we can use this one. :)
I know, that on-prem blueprints can also come in json, this will be quite easy to do, we will adjust the UI a bit for that, so that users would be able to import even on-prem json.
Feel free to ask any questions, and find bugs!