Commit efa9f53a authored by Zamir Martins Filho's avatar Zamir Martins Filho Committed by Kushal Pandya

Add support for multiple environments

Update code to support multiple environments
scoped within a project for NetworkPolicy k8s
resource
parent 2aac325b
...@@ -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;
},
}, },
methods: { methods: {
...mapActions('networkPolicies', ['createPolicy', 'updatePolicy']), ...mapActions('networkPolicies', ['createPolicy', 'updatePolicy']),
...@@ -127,23 +155,6 @@ export default { ...@@ -127,23 +155,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.`,
), ),
...@@ -193,7 +204,7 @@ export default { ...@@ -193,7 +204,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"
> >
......
...@@ -112,6 +112,19 @@ spec: ...@@ -112,6 +112,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