fix: add skill show error if manifest url can not be accessed#2935
fix: add skill show error if manifest url can not be accessed#2935a-b-r-o-w-n merged 23 commits intomasterfrom
Conversation
|
@zhixzhan instead of an alert modal can we render something a bit more subtle, like a text notification in the form itself? |
|
@cwhitten updated. the url check result would be sent from server and display as a notification (with some lag) |
a-b-r-o-w-n
left a comment
There was a problem hiding this comment.
I think we should separate the async validation from the sync validation and consolidate the skill validation logic into a utility used by both the skill form and skill modal. I'm also curious if the modal and form can share common components.
For the url validation, here is what I suggest:
useEffect(() => {
httpClient('/projects/:projectId/skill/check', { url })
.then(/* maybe clear error */)
.catch(/* set validation error */)
}, [data.manifestUrl]);Action creators should only be used to dispatch updates to the store (maybe as a result of an api call). They should not be used directly in components either to return a value or for a try/catch. It violates the uni-directional data flow model of the reducer pattern.
@a-b-r-o-w-n I moved two form into a component, and separate remote call to an async validation. but when I run jest ,meet a warning about |
|
@zhixzhan that error is probably due to the api call resolving after the component has unmounted. This may only be a problem with the test, but something to consider is adding some cancellation functionality so that the state update is not triggered. useEffect(() => {
let isCancelled = false;
asyncValidation(formData).then((errors) => {
setFormErrors(errors);
});
return () => {
isCancelled = true;
}
}, [formData.manifestUrl]);I'm not sure if that would work. |
I tried but no difference, ( anyway, it's only a test warning, wouldn't effect the feature. ) |
|
Sorry @zhixzhan my code snippet was wrong. useEffect(() => {
let isCancelled = false;
asyncValidation(formData).then((errors) => {
if (!isCancelled) {
setFormErrors(errors);
}
});
return () => {
isCancelled = true;
}
}, [formData.manifestUrl]); |
|
@zhixzhan I pulled this and tried to fix the jest warning but didn't make any progress. |
…oft#2935) * throw error when skill manifest url can not be accessed * check skill manifest url before commit * update * use createSkillModal component * clean up * separate async/sync validation * clean up * remove dead code * check status code when fetching manifest * extract manifest url validation * clean up Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com> Co-authored-by: Andy Brown <asbrown002@gmail.com>



Description
fix skill-add flow:
Task Item
close #2920
Screenshots