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
d426ce3e
Commit
d426ce3e
authored
Jul 01, 2021
by
Miguel Rincon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '273781-policy-type-column' into 'master'
Add policy type column See merge request gitlab-org/gitlab!65075
parents
0f642b99
ca912bf6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
16 deletions
+49
-16
ee/app/assets/javascripts/threat_monitoring/components/policy_list.vue
.../javascripts/threat_monitoring/components/policy_list.vue
+19
-1
ee/spec/frontend/threat_monitoring/components/policy_list_spec.js
...frontend/threat_monitoring/components/policy_list_spec.js
+24
-15
locale/gitlab.pot
locale/gitlab.pot
+6
-0
No files found.
ee/app/assets/javascripts/threat_monitoring/components/policy_list.vue
View file @
d426ce3e
...
...
@@ -30,6 +30,12 @@ const createPolicyFetchError = ({ gqlError, networkError }) => {
});
};
const
getPoliciesWithType
=
(
policies
,
policyType
)
=>
policies
.
map
((
policy
)
=>
({
...
policy
,
policyType
,
}));
export
default
{
components
:
{
GlTable
,
...
...
@@ -110,7 +116,10 @@ export default {
return
setUrlFragment
(
this
.
documentationPath
,
'
container-network-policy
'
);
},
policies
()
{
return
[...
this
.
networkPolicies
,
...
this
.
scanExecutionPolicies
];
return
[
...
getPoliciesWithType
(
this
.
networkPolicies
,
s__
(
'
SecurityPolicies|Network
'
)),
...
getPoliciesWithType
(
this
.
scanExecutionPolicies
,
s__
(
'
SecurityPolicies|Scan execution
'
)),
];
},
isLoadingPolicies
()
{
return
(
...
...
@@ -156,9 +165,15 @@ export default {
label
:
s__
(
'
NetworkPolicies|Name
'
),
thClass
:
'
gl-w-half
'
,
},
{
key
:
'
policyType
'
,
label
:
s__
(
'
SecurityPolicies|Policy type
'
),
sortable
:
true
,
},
{
key
:
'
updatedAt
'
,
label
:
s__
(
'
NetworkPolicies|Last modified
'
),
sortable
:
true
,
},
];
// Adds column 'namespace' only while 'all environments' option is selected
...
...
@@ -239,6 +254,9 @@ export default {
:busy=
"isLoadingPolicies"
:items=
"policies"
:fields=
"fields"
sort-icon-left
sort-by=
"updatedAt"
sort-desc
head-variant=
"white"
stacked=
"md"
thead-class=
"gl-text-gray-900 border-bottom"
...
...
ee/spec/frontend/threat_monitoring/components/policy_list_spec.js
View file @
d426ce3e
...
...
@@ -146,18 +146,27 @@ describe('PolicyList component', () => {
rows
=
wrapper
.
findAll
(
'
tr
'
);
});
it
.
each
`
rowIndex | expectedPolicyName
${
1
}
|
${
mockNetworkPoliciesResponse
[
0
].
name
}
${
2
}
|
${
'
drop-outbound
'
}
${
3
}
|
${
'
allow-inbound-http
'
}
${
4
}
|
${
mockScanExecutionPoliciesResponse
[
0
].
name
}
`
(
'
renders "$expectedPolicyName" policy in row #$rowIndex
'
,
({
expectedPolicyName
,
rowIndex
})
=>
{
expect
(
rows
.
at
(
rowIndex
).
text
()).
toContain
(
expectedPolicyName
);
},
);
describe
.
each
`
rowIndex | expectedPolicyName | expectedPolicyType
${
1
}
|
${
mockScanExecutionPoliciesResponse
[
0
].
name
}
|
${
'
Scan execution
'
}
${
2
}
|
${
mockNetworkPoliciesResponse
[
0
].
name
}
|
${
'
Network
'
}
${
3
}
|
${
'
drop-outbound
'
}
|
${
'
Network
'
}
${
4
}
|
${
'
allow-inbound-http
'
}
|
${
'
Network
'
}
`
(
'
policy in row #$rowIndex
'
,
({
rowIndex
,
expectedPolicyName
,
expectedPolicyType
})
=>
{
let
row
;
beforeEach
(()
=>
{
row
=
rows
.
at
(
rowIndex
);
});
it
(
`renders
${
expectedPolicyName
}
in the name cell`
,
()
=>
{
expect
(
row
.
findAll
(
'
td
'
).
at
(
1
).
text
()).
toBe
(
expectedPolicyName
);
});
it
(
`renders
${
expectedPolicyType
}
in the policy type cell`
,
()
=>
{
expect
(
row
.
findAll
(
'
td
'
).
at
(
2
).
text
()).
toBe
(
expectedPolicyType
);
});
});
});
describe
(
'
status column
'
,
()
=>
{
...
...
@@ -166,7 +175,7 @@ describe('PolicyList component', () => {
});
it
(
'
renders a checkmark icon for enabled policies
'
,
()
=>
{
const
icon
=
findPolicyStatusCells
().
at
(
0
).
find
(
'
svg
'
);
const
icon
=
findPolicyStatusCells
().
at
(
1
).
find
(
'
svg
'
);
expect
(
icon
.
exists
()).
toBe
(
true
);
expect
(
icon
.
props
(
'
name
'
)).
toBe
(
'
check-circle-filled
'
);
...
...
@@ -174,7 +183,7 @@ describe('PolicyList component', () => {
});
it
(
'
renders a "Disabled" label for screen readers for disabled policies
'
,
()
=>
{
const
span
=
findPolicyStatusCells
().
at
(
1
).
find
(
'
span
'
);
const
span
=
findPolicyStatusCells
().
at
(
2
).
find
(
'
span
'
);
expect
(
span
.
exists
()).
toBe
(
true
);
expect
(
span
.
attributes
(
'
class
'
)).
toBe
(
'
gl-sr-only
'
);
...
...
@@ -190,7 +199,7 @@ describe('PolicyList component', () => {
it
(
'
renders namespace column
'
,
()
=>
{
const
namespaceHeader
=
findPoliciesTable
().
findAll
(
'
[role="columnheader"]
'
).
at
(
2
);
expect
(
namespaceHeader
.
text
()).
to
Be
(
'
Namespace
'
);
expect
(
namespaceHeader
.
text
()).
to
Contain
(
'
Namespace
'
);
});
});
...
...
locale/gitlab.pot
View file @
d426ce3e
...
...
@@ -28838,6 +28838,12 @@ msgstr ""
msgid "SecurityPolicies|Latest scan"
msgstr ""
msgid "SecurityPolicies|Network"
msgstr ""
msgid "SecurityPolicies|Policy type"
msgstr ""
msgid "SecurityPolicies|Scan execution"
msgstr ""
...
...
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