Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a145d8bb
Commit
a145d8bb
authored
Aug 11, 2021
by
Zamir Martins
Committed by
Savas Vedova
Aug 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace gl checkbox group by gl dropdown items
parent
363bb59c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
26 deletions
+41
-26
ee/app/assets/javascripts/approvals/components/rule_form.vue
ee/app/assets/javascripts/approvals/components/rule_form.vue
+31
-21
ee/spec/frontend/approvals/components/rule_form_spec.js
ee/spec/frontend/approvals/components/rule_form_spec.js
+10
-5
No files found.
ee/app/assets/javascripts/approvals/components/rule_form.vue
View file @
a145d8bb
<
script
>
import
{
GlFormGroup
,
GlFormInput
,
GlDropdown
,
GlFormCheckbox
,
GlFormCheckboxGroup
,
}
from
'
@gitlab/ui
'
;
import
{
GlFormGroup
,
GlFormInput
,
GlDropdown
,
GlTruncate
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
{
groupBy
,
isEqual
,
isNumber
,
omit
}
from
'
lodash
'
;
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
{
REPORT_TYPES
}
from
'
ee/security_dashboard/store/constants
'
;
...
...
@@ -26,7 +20,7 @@ import ApproversSelect from './approvers_select.vue';
const
DEFAULT_NAME
=
'
Default
'
;
const
EXCLUDED_REPORT_TYPE
=
'
cluster_image_scanning
'
;
export
const
EXCLUDED_REPORT_TYPE
=
'
cluster_image_scanning
'
;
export
const
READONLY_NAMES
=
[
LICENSE_CHECK_NAME
,
VULNERABILITY_CHECK_NAME
,
COVERAGE_CHECK_NAME
];
...
...
@@ -42,8 +36,8 @@ export default {
GlFormInput
,
ProtectedBranchesSelector
,
GlDropdown
,
Gl
FormCheckbox
,
Gl
FormCheckboxGroup
,
Gl
Truncate
,
Gl
DropdownItem
,
},
props
:
{
initRule
:
{
...
...
@@ -362,6 +356,17 @@ export default {
setAllSelectedScanners
()
{
this
.
scanners
=
this
.
areAllScannersSelected
?
[]
:
Object
.
keys
(
this
.
$options
.
REPORT_TYPES
);
},
isScannerSelected
(
scanner
)
{
return
this
.
scanners
.
includes
(
scanner
);
},
setScanner
(
scanner
)
{
const
pos
=
this
.
scanners
.
indexOf
(
scanner
);
if
(
pos
===
-
1
)
{
this
.
scanners
.
push
(
scanner
);
}
else
{
this
.
scanners
.
splice
(
pos
,
1
);
}
},
},
APPROVAL_DIALOG_I18N
,
REPORT_TYPES
:
omit
(
REPORT_TYPES
,
EXCLUDED_REPORT_TYPE
),
...
...
@@ -410,18 +415,23 @@ export default {
data-testid=
"scanners-group"
>
<gl-dropdown
:text=
"scannersText"
>
<gl-form-checkbox
:checked=
"areAllScannersSelected"
class=
"gl-ml-2"
@
change=
"setAllSelectedScanners"
<gl-dropdown-item
key=
"all"
is-check-item
:is-checked=
"areAllScannersSelected"
@
click.native.capture.stop=
"setAllSelectedScanners"
>
{{
$options
.
APPROVAL_DIALOG_I18N
.
form
.
selectAllScannersLabel
}}
</gl-form-checkbox>
<gl-form-checkbox-group
v-model=
"scanners"
:options=
"$options.REPORT_TYPES"
class=
"gl-ml-2"
/>
<gl-truncate
:text=
"$options.APPROVAL_DIALOG_I18N.form.selectAllScannersLabel"
/>
</gl-dropdown-item>
<gl-dropdown-item
v-for=
"(value, key) in $options.REPORT_TYPES"
:key=
"key"
is-check-item
:is-checked=
"isScannerSelected(key)"
@
click.native.capture.stop=
"setScanner(key)"
>
<gl-truncate
:text=
"value"
/>
</gl-dropdown-item>
</gl-dropdown>
</gl-form-group>
<gl-form-group
...
...
ee/spec/frontend/approvals/components/rule_form_spec.js
View file @
a145d8bb
import
{
GlFormGroup
,
GlFormInput
,
Gl
FormCheckboxGroup
}
from
'
@gitlab/ui
'
;
import
{
GlFormGroup
,
GlFormInput
,
Gl
Truncate
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
,
{
nextTick
}
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
ApproversList
from
'
ee/approvals/components/approvers_list.vue
'
;
import
ApproversSelect
from
'
ee/approvals/components/approvers_select.vue
'
;
import
RuleForm
,
{
READONLY_NAMES
}
from
'
ee/approvals/components/rule_form.vue
'
;
import
RuleForm
,
{
READONLY_NAMES
,
EXCLUDED_REPORT_TYPE
,
}
from
'
ee/approvals/components/rule_form.vue
'
;
import
{
TYPE_USER
,
TYPE_GROUP
,
...
...
@@ -13,6 +16,7 @@ import {
}
from
'
ee/approvals/constants
'
;
import
{
createStoreOptions
}
from
'
ee/approvals/stores
'
;
import
projectSettingsModule
from
'
ee/approvals/stores/modules/project_settings
'
;
import
{
REPORT_TYPES
}
from
'
ee/security_dashboard/store/constants
'
;
import
ProtectedBranchesSelector
from
'
ee/vue_shared/components/branches_selector/protected_branches_selector.vue
'
;
import
{
stubComponent
}
from
'
helpers/stub_component
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
...
...
@@ -621,9 +625,10 @@ describe('EE Approvals RuleForm', () => {
);
});
it
(
'
does not contain unsupported report type
'
,
()
=>
{
const
group
=
wrapper
.
find
(
GlFormCheckboxGroup
);
expect
(
Object
.
keys
(
group
.
props
(
'
options
'
))).
not
.
toContain
(
'
cluster_image_scanning
'
);
it
(
'
contains the supported report types and select all option
'
,
()
=>
{
const
supportedReportsPlusAll
=
Object
.
keys
(
REPORT_TYPES
).
length
-
[
EXCLUDED_REPORT_TYPE
].
length
+
1
;
expect
(
wrapper
.
findAllComponents
(
GlTruncate
)).
toHaveLength
(
supportedReportsPlusAll
);
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment