-
Notifications
You must be signed in to change notification settings - Fork 45
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
Fetch SPA bundle #209
Fetch SPA bundle #209
Conversation
try { | ||
response = await axios.get(app.assetsDiscoveryUrl, {responseType: 'json'}); | ||
} catch (error) { | ||
console.log('Caught an error while trying to fetch a manifest file:'); |
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.
add link(app.assetsDiscoveryUrl
) to the end of the console.log
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.
Done
response = await axios.get(app.assetsDiscoveryUrl, {responseType: 'json'}); | ||
} catch (error) { | ||
console.log('Caught an error while trying to fetch a manifest file:'); | ||
console.log(error); |
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.
- why do you use
log
insteaderror
? - you can provide the second argument to the first
console.log
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.
Done
app.cssBundle = processedManifest.cssBundle; | ||
} | ||
|
||
app.spaBundle = processedManifest.spaBundle; |
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.
Here you also need to fetch dependencies from manifest
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.
Done
spaBundle: commonApp.spaBundle.required(), | ||
spaBundle: Joi.when('assetsDiscoveryUrl', { | ||
is: commonApp.assetsDiscoveryUrl.required(), | ||
then: commonApp.spaBundle.optional(), |
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.
then: commonApp.spaBundle.optional(), | |
then: commonApp.spaBundle.forbidden('You ca\'n specify... because ... data from assetsDiscoveryUrl will overwrite this 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.
I decided to leave optional here
It does not need to validate it, I guess
registry/client/src/apps/Edit.js
Outdated
|
||
return 'Trying to fetch the manifest file...'; | ||
}; | ||
|
||
const InputForm = ({mode = 'edit', ...props}) => { |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
registry/client/src/apps/Edit.js
Outdated
<AutocompleteArrayInput /> | ||
</ReferenceArrayInput> | ||
</FormTab> | ||
<FormTab label="Assets"> | ||
<TextInput source="spaBundle" validate={required()} fullWidth /> | ||
<TextInput source="cssBundle" fullWidth /> | ||
<TextInput |
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.
Disable this field when assetsDiscoveryUrl is specified
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.
Done
registry/client/src/apps/Edit.js
Outdated
disabled={isFetchingManifest} | ||
helperText={fetchingManifestHelperText} | ||
/> | ||
<TextInput |
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.
Before this field - add warning when assetsDiscoveryUrl is specified that values specified in these fields may be overwritten from manifest after saving.
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.
Added helper text for it
registry/client/src/apps/Edit.js
Outdated
disabled={isFetchingManifest} | ||
error={error} | ||
helperText={helperText} | ||
onBlur={(event) => { |
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.
If you keep this logic - move it to async validator
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.
Removed
9b6d57e
to
1136cab
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.
This PR contains a lot of unrelated to the main task changes and so it can't be merged
registry/client/src/apps/Edit.js
Outdated
return `Do not need to specify SPA bundle, CSS bundle, dependencies because they would be fetched and set from assets discovery URL if they exist there`; | ||
}; | ||
|
||
const validateAppCreation = (values) => { |
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.
validateApp
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 code below is really complex. I don't really like the approach....
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.
Renamed
Removed unnecessary code but I left necessary validation here for 'assetsDiscoveryUrl', 'spaBundle'
@@ -13,23 +13,23 @@ const isJSON = (str: string): boolean => { | |||
return (/^[\],:{}\s]*$/).test(str); | |||
}; | |||
|
|||
const parse = (value: any): any => { | |||
const parseJSON = (value: any): any => { |
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.
Why do you need to rename all these vars which unnecessarily cause a lot of side changes?
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.
Removed
@@ -1,25 +1,23 @@ | |||
import _ from 'lodash/fp'; |
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.
Why do you need to rename all these vars which unnecessarily cause a lot of side changes?
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.
Removed
res.status(422).send(preProcessErrorResponse(e)); | ||
} catch (error) { | ||
console.error(`Caught an error while validating request data for '${req.url}':`, error); | ||
res.status(422).send(preProcessErrorResponse(new Error(preProcessError(error)))); |
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 line is super hard to understand....
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.
Removed
@@ -0,0 +1,10 @@ | |||
const preProcessErrorResponse = (error: Error, errorInfo = {}) => { |
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 don't see a big value in this function... IMO it causes more issues then it solves
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.
Removed
45bfdf5
to
b092e49
Compare
b092e49
to
dced1c5
Compare
No description provided.