-
Notifications
You must be signed in to change notification settings - Fork 175
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
[new_profile] Use API for candidate creation and swal for success #7755
Conversation
Blocked by the release. Set it to "Draft" so that it doesn't accidentally get merged beforehand. |
submitDisabled: false, | ||
}); | ||
} | ||
}); | ||
}); | ||
} else { | ||
resp.json().then((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.
This will throw a parse error when an html page is returned by the backend (session expired, forbidden, 500, etc)
In those cases, It might be relevant to fire the swal.
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.
Which part? the resp.json()
or changing message
to message.error
? And why does forbidden return html? (It didn't seem to when I was testing..)
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 would say thta it is because the class is extending \NDB_Form
and not Endpoint
. It's wraped by a UserPage Decorator middleware that only prints html. Regardless of specifics, there are cases where html will be returned and resp.json()
will not be happy. ONe way of handling that is to put the
this.setState({submitDisabled: false});
swal.fire('Error!', message.error, 'error');
parts in the catch; and throw resp.json().message in the else.
Nice! |
looks like that's also true of _pscid and _candID and all the namespaces (which phan was complaining about).. should be fixed in the last commit. |
@xlecours now that the release is out I removed the blocked tag and rebased this, can you re-review 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.
I see a mixte of 2 and 4 spaces indentation in the js files.
The resp.json() potential parse error is still not handled. A swal showing failure would be better than a console.error I think.
It's failing CI
There was 1 error:
- NewProfileTestIntegrationTest::testNewProfileCreateCandidate
Facebook\WebDriver\Exception\NoSuchElementException: Unable to locate element: #lorisworkspace > fieldset > div > div > p:nth-child(1)
Other than that it's great :)
This updates the candidate creation on the new profile page to se the LORIS API instead of duplicating the logic in PHP. The form already collects the exact data that a POST request to the API requires, but submits it to a different endpoint in a form encoding instead of a json encoding. At the same time, the logic for the response is simplified by using a swal instead of a (very empty looking) new page. swals are already used for errors in the module, just not success. This change simplifies both the code and the UX.
27e2019
to
de1a0dd
Compare
@xlecours I've fixed the indentation, added a catch to the code paths that don't have a catch for the |
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 good.
@driusan I haven't tested it because I am in the middle of other things. |
@driusan Tested now. it's working all right. |
This updates the candidate creation on the new profile page to
use the LORIS API instead of duplicating the logic in PHP. The form
already collects the exact data that a POST request to the API
requires, but submits it to a different endpoint in a form encoding
instead of a json encoding.
At the same time, the logic for the response is simplified by using
a swal instead of a (very empty looking) new page. swals are already
used for errors in the module, just not success. This change simplifies
both the code and the UX.