Draft: Create new form_error alerts, hidden by feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]
What does this MR do?
Create Vue Form errors and feature flag
- create new form_error method that renders a Vue alert
- create feature flag to iteratively verify the new form_error method
- Ensure truncate works for long errors
Related to #294442 (closed)
How to reproduce
- Enable
:new_form_errors
feature flag viarails c && Feature.enable(:new_form_errors)
-
Single Error: Navigate to create a merge request, do not select a source branch, click
Compare branches and continue
(seems like bad UX to not grey out that button if a selection has not been made, but that is a different problem), verify alert -
Multiple Errors: Navigate to
Admin => Deploy Keys => Click "Add Deploy Key"
, ClickCreate
without filling anything out, verify multiple errors -
Truncated Errors: Apply the patch below, navigate to
Project => Wiki
, clickCreate a new wiki page
, put in a title that is >255chars, clickCreate
, verify error
diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb
index 2ea3a95e2fa..89c2e734292 100644
--- a/app/helpers/form_helper.rb
+++ b/app/helpers/form_helper.rb
@@ -14,6 +14,7 @@ def new_form_errors(model, type, truncate)
errors = model.errors.map do |attribute, message|
{ attribute: attribute, message: model.errors.full_message(attribute, message) }
end
+ errors << {attribute: 'title', message: 'thisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncate'}
content_tag(:div, nil, class: 'js-form-errors-explanation', data: { errors: errors, truncate: truncate, type: type })
end
@@ -41,6 +42,8 @@ def form_errors_legacy(model, type, truncate)
tag.li(message)
end
+ messages << tag.li(tag.span('thisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncatethisIsAFakeErrorToTestTruncate', class: 'str-truncated-100')) if truncate.include?(:title)
+
messages.join.html_safe
end
end
-
Different Type Errors: Apply the patch below, navigate to
Project => Wiki
, clickCreate a new wiki page
, put in a title that is >255chars, clickCreate
, verify error
diff --git a/app/views/shared/wikis/_form.html.haml b/app/views/shared/wikis/_form.html.haml
index e121725b9af..71317a5b510 100644
--- a/app/views/shared/wikis/_form.html.haml
+++ b/app/views/shared/wikis/_form.html.haml
@@ -1,6 +1,6 @@
- page_info = { last_commit_sha: @page.last_commit_sha, persisted: @page.persisted?, title: @page.title, content: @page.content || '', format: @page.format.to_s, uploads_path: uploads_path, path: wiki_page_path(@wiki, @page), wiki_path: wiki_path(@wiki), help_path: help_page_path('user/project/wiki/index'), markdown_help_path: help_page_path('user/markdown'), markdown_preview_path: wiki_page_path(@wiki, @page, action: :preview_markdown), create_path: wiki_path(@wiki, action: :create) }
.gl-mt-3
- = form_errors(@page, truncate: :title)
+ = form_errors(@page, type: 'wiki', truncate: :title)
#js-wiki-form{ data: { page_info: page_info.to_json, format_options: Wiki::MARKUPS.to_json } }
Screenshots (strongly suggested)
Page | Feature Flag Off | Feature Flag On |
---|---|---|
Merge Branch (single error) | ||
Deploy Keys (multiple errors) | ||
Wiki (with truncate) | ||
Wiki (modified to use a different type ) (see below for code) |
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
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Alexander Turinske