Fixed form disappearing when name is empty and general code improvements
What does this MR do?
Note: This form is currently not shown on any page and is in active development, with the pages this will be used on and the backend aspects behind the :ff_custom_compliance_frameworks
feature flag
During the development of #292696 (closed) I came to realise that the form completely disappears if you remove the name
field value when editing a compliance framework
This MR fixes that bug, as well as the bug whereby input's where not showing a red border when invalid.
I also took the small liberty to improve the code a bit by:
- Moving the form data initialising method to a utils file
Changing the static props to use provide/inject instead
Screenshots (strongly suggested)
Before | After |
---|---|
Screen_Recording_2021-02-04_at_13.42.05 | Screen_Recording_2021-02-04_at_13.43.10 |
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
This form isn't used anywhere yet. If you want to test it locally, an example patch for the compliance framework settings area is below:
Patch:
Index: ee/app/assets/javascripts/pages/groups/edit/index.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/ee/app/assets/javascripts/pages/groups/edit/index.js b/ee/app/assets/javascripts/pages/groups/edit/index.js
--- a/ee/app/assets/javascripts/pages/groups/edit/index.js (revision dca549e80e48d7f4f38c45f15cd58b157e69ce51)
+++ b/ee/app/assets/javascripts/pages/groups/edit/index.js (date 1612192443190)
@@ -1,6 +1,7 @@
import '~/pages/groups/edit';
import validateRestrictedIpAddress from 'ee/groups/settings/access_restriction_field/validate_ip_address';
import initAccessRestrictionField from 'ee/groups/settings/access_restriction_field';
+import { createComplianceFrameworksFormApp } from 'ee/groups/settings/compliance_frameworks/init_form';
import createFlash from '~/flash';
import { __ } from '~/locale';
@@ -19,6 +20,8 @@
const complianceFrameworksList = document.querySelector('#js-compliance-frameworks-list');
+createComplianceFrameworksFormApp(document.querySelector('#js-compliance-frameworks-form'));
+
if (complianceFrameworksList) {
(async () => {
try {
Index: ee/app/helpers/compliance_management/compliance_framework/group_settings_helper.rb
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/ee/app/helpers/compliance_management/compliance_framework/group_settings_helper.rb b/ee/app/helpers/compliance_management/compliance_framework/group_settings_helper.rb
--- a/ee/app/helpers/compliance_management/compliance_framework/group_settings_helper.rb (revision dca549e80e48d7f4f38c45f15cd58b157e69ce51)
+++ b/ee/app/helpers/compliance_management/compliance_framework/group_settings_helper.rb (date 1612192443192)
@@ -13,6 +13,15 @@
group_path: @group.full_path
}
end
+
+ def compliance_frameworks_form_data
+ {
+ framework_id: 1,
+ group_path: @group.full_path,
+ group_edit_path: edit_group_path(@group, anchor: 'js-compliance-frameworks-settings'),
+ graphql_field_name: ComplianceManagement::Framework.name,
+ }
+ end
end
end
end
Index: ee/app/views/groups/_compliance_frameworks.html.haml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/ee/app/views/groups/_compliance_frameworks.html.haml b/ee/app/views/groups/_compliance_frameworks.html.haml
--- a/ee/app/views/groups/_compliance_frameworks.html.haml (revision dca549e80e48d7f4f38c45f15cd58b157e69ce51)
+++ b/ee/app/views/groups/_compliance_frameworks.html.haml (date 1612192443195)
@@ -11,3 +11,4 @@
= s_('GroupSettings|Configure frameworks to apply enforceable rules to projects.')
.settings-content
#js-compliance-frameworks-list{ data: compliance_frameworks_list_data }
+ #js-compliance-frameworks-form{ data: compliance_frameworks_form_data }
-
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