Show correct error message for Create and Update mutations on Snippet
What does this MR do?
When on edit snippet form, we should show show correct error message depending on whether it's Create or Update mutation that failed. At the moment, it's hardcoded to be "update". This MR addresses this.
Screenshots
Before | After | |
---|---|---|
Create new snippet | ||
Update existing snippet |
Click-testing steps
- Enable
:snippets_edit_vue
feature flag in Rails console
New Snippet
- Go to
/snippets/new
- On the edit form for the snippet, type in the illegal File path for the snippet (
invalid://file/path
for example) - Click save
- The error flash should be shown with the correct message for CREATE scenario
Existing Snippet
This scenario has another bug, addressed in !33107 (merged) so isn't trivial to test without either setting a debugger into the code or applying this small patch:
Index: app/assets/javascripts/snippets/components/edit.vue
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- app/assets/javascripts/snippets/components/edit.vue (revision 0e18c7fdb4adf32adfc74767f363a4ea3951bb94)
+++ app/assets/javascripts/snippets/components/edit.vue (date 1590527350478)
@@ -147,8 +147,9 @@
const errors = baseObj?.errors;
if (errors.length) {
this.flashAPIFailure(errors[0]);
- }
- redirectTo(baseObj.snippet.webUrl);
+ } else {
+ redirectTo(baseObj.snippet.webUrl);
+ }
})
.catch(e => {
this.isUpdating = false;
- Go to any existing snippet. Click "Edit"
- On the edit form for the snippet, type in the illegal File path for the snippet (
invalid://file/path
for example) - Click save
- The error flash should be shown with the correct message for UPDATE scenario
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
References #217727 (closed)
Edited by 🤖 GitLab Bot 🤖