Commit 6ec64f96 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'add_namespace_column_for_network_policies_ui' into 'master'

Add namespace column for network policies ui

See merge request gitlab-org/gitlab!42125
parents 196aeb62 efa9f53a
...@@ -47,7 +47,7 @@ export default { ...@@ -47,7 +47,7 @@ export default {
}, },
computed: { computed: {
...mapState('networkPolicies', ['policies', 'isLoadingPolicies', 'isUpdatingPolicy']), ...mapState('networkPolicies', ['policies', 'isLoadingPolicies', 'isUpdatingPolicy']),
...mapState('threatMonitoring', ['currentEnvironmentId']), ...mapState('threatMonitoring', ['currentEnvironmentId', 'allEnvironments']),
...mapGetters('networkPolicies', ['policiesWithDefaults']), ...mapGetters('networkPolicies', ['policiesWithDefaults']),
documentationFullPath() { documentationFullPath() {
return setUrlFragment(this.documentationPath, 'container-network-policy'); return setUrlFragment(this.documentationPath, 'container-network-policy');
...@@ -90,6 +90,34 @@ export default { ...@@ -90,6 +90,34 @@ export default {
) )
: ''; : '';
}, },
fields() {
const namespace = {
key: 'namespace',
label: s__('NetworkPolicies|Namespace'),
thClass: 'font-weight-bold',
};
const fields = [
{
key: 'name',
label: s__('NetworkPolicies|Name'),
thClass: 'w-50 font-weight-bold',
},
{
key: 'status',
label: s__('NetworkPolicies|Status'),
thClass: 'font-weight-bold',
},
{
key: 'creationTimestamp',
label: s__('NetworkPolicies|Last modified'),
thClass: 'font-weight-bold',
},
];
// Adds column 'namespace' only while 'all environments' option is selected
if (this.allEnvironments) fields.splice(1, 0, namespace);
return fields;
},
}, },
watch: { watch: {
currentEnvironmentId(envId) { currentEnvironmentId(envId) {
...@@ -135,23 +163,6 @@ export default { ...@@ -135,23 +163,6 @@ export default {
}); });
}, },
}, },
fields: [
{
key: 'name',
label: s__('NetworkPolicies|Name'),
thClass: 'w-75 font-weight-bold',
},
{
key: 'status',
label: s__('NetworkPolicies|Status'),
thClass: 'font-weight-bold',
},
{
key: 'creationTimestamp',
label: s__('NetworkPolicies|Last modified'),
thClass: 'font-weight-bold',
},
],
emptyStateDescription: s__( emptyStateDescription: s__(
`NetworkPolicies|Policies are a specification of how groups of pods are allowed to communicate with each other's network endpoints.`, `NetworkPolicies|Policies are a specification of how groups of pods are allowed to communicate with each other's network endpoints.`,
), ),
...@@ -201,7 +212,7 @@ export default { ...@@ -201,7 +212,7 @@ export default {
ref="policiesTable" ref="policiesTable"
:busy="isLoadingPolicies" :busy="isLoadingPolicies"
:items="policiesWithDefaults" :items="policiesWithDefaults"
:fields="$options.fields" :fields="fields"
head-variant="white" head-variant="white"
stacked="md" stacked="md"
thead-class="gl-text-gray-900 border-bottom" thead-class="gl-text-gray-900 border-bottom"
......
---
title: Add namespace column into the network policies UI. Only visible when All Environment
option is set.
merge_request: 42125
author:
type: changed
...@@ -25,7 +25,7 @@ exports[`NetworkPolicyList component renders policies table 1`] = ` ...@@ -25,7 +25,7 @@ exports[`NetworkPolicyList component renders policies table 1`] = `
> >
<th <th
aria-colindex="1" aria-colindex="1"
class="w-75 font-weight-bold" class="w-50 font-weight-bold"
role="columnheader" role="columnheader"
scope="col" scope="col"
> >
......
...@@ -123,6 +123,19 @@ spec: ...@@ -123,6 +123,19 @@ spec:
expect(findPoliciesTable().element).toMatchSnapshot(); expect(findPoliciesTable().element).toMatchSnapshot();
}); });
describe('with allEnvironments enabled', () => {
beforeEach(() => {
wrapper.vm.$store.state.threatMonitoring.allEnvironments = true;
});
it('renders policies table', () => {
const namespaceHeader = findPoliciesTable()
.findAll('[role="columnheader"]')
.at(1);
expect(namespaceHeader.text()).toBe('Namespace');
});
});
it('renders closed editor drawer', () => { it('renders closed editor drawer', () => {
const editorDrawer = findEditorDrawer(); const editorDrawer = findEditorDrawer();
expect(editorDrawer.exists()).toBe(true); expect(editorDrawer.exists()).toBe(true);
......
...@@ -16748,6 +16748,9 @@ msgstr "" ...@@ -16748,6 +16748,9 @@ msgstr ""
msgid "NetworkPolicies|Name" msgid "NetworkPolicies|Name"
msgstr "" msgstr ""
msgid "NetworkPolicies|Namespace"
msgstr ""
msgid "NetworkPolicies|Network Policy" msgid "NetworkPolicies|Network Policy"
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment