Commit 094529ff authored by Denys Mishunov's avatar Denys Mishunov

Merge branch 'network-policy-management-autodevops' into 'master'

Add alert for autodevops policies to the Policy list

See merge request gitlab-org/gitlab!32717
parents 96fcdbcc e9187e58
<script> <script>
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import { GlTable, GlEmptyState, GlDrawer, GlButton } from '@gitlab/ui'; import { GlTable, GlEmptyState, GlDrawer, GlButton, GlAlert, GlSprintf, GlLink } from '@gitlab/ui';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { getTimeago } from '~/lib/utils/datetime_utility'; import { getTimeago } from '~/lib/utils/datetime_utility';
import { setUrlFragment } from '~/lib/utils/url_utility'; import { setUrlFragment } from '~/lib/utils/url_utility';
...@@ -13,6 +13,9 @@ export default { ...@@ -13,6 +13,9 @@ export default {
GlEmptyState, GlEmptyState,
GlDrawer, GlDrawer,
GlButton, GlButton,
GlAlert,
GlSprintf,
GlLink,
EnvironmentPicker, EnvironmentPicker,
NetworkPolicyEditor, NetworkPolicyEditor,
}, },
...@@ -42,6 +45,9 @@ export default { ...@@ -42,6 +45,9 @@ export default {
hasPolicyChanges() { hasPolicyChanges() {
return this.hasSelectedPolicy && this.selectedPolicy.manifest !== this.initialManifest; return this.hasSelectedPolicy && this.selectedPolicy.manifest !== this.initialManifest;
}, },
hasAutoDevopsPolicy() {
return this.policies.some(policy => policy.isAutodevops);
},
}, },
methods: { methods: {
...mapActions('networkPolicies', ['updatePolicy']), ...mapActions('networkPolicies', ['updatePolicy']),
...@@ -88,7 +94,10 @@ export default { ...@@ -88,7 +94,10 @@ export default {
}, },
], ],
emptyStateDescription: s__( emptyStateDescription: s__(
`NetworkPolicies|Policies are a specification of how groups of pods are allowed to communicate with each other network endpoints.`, `NetworkPolicies|Policies are a specification of how groups of pods are allowed to communicate with each other's network endpoints.`,
),
autodevopsNoticeDescription: s__(
`NetworkPolicies|If you are using Auto DevOps, your %{monospacedStart}auto-deploy-values.yaml%{monospacedEnd} file will not be updated if you change a policy in this section. Auto DevOps users should make changes by following the %{linkStart}Container Network Policy documentation%{linkEnd}.`,
), ),
headerHeight: process.env.NODE_ENV === 'development' ? '75px' : '40px', headerHeight: process.env.NODE_ENV === 'development' ? '75px' : '40px',
}; };
...@@ -96,6 +105,24 @@ export default { ...@@ -96,6 +105,24 @@ export default {
<template> <template>
<div> <div>
<div class="mb-2">
<gl-alert
v-if="hasAutoDevopsPolicy"
data-testid="autodevopsAlert"
variant="info"
:dismissible="false"
>
<gl-sprintf :message="$options.autodevopsNoticeDescription">
<template #monospaced="{ content }">
<span class="monospace">{{ content }}</span>
</template>
<template #link="{ content }">
<gl-link :href="documentationFullPath">{{ content }}</gl-link>
</template>
</gl-sprintf>
</gl-alert>
</div>
<div class="pt-3 px-3 bg-gray-light"> <div class="pt-3 px-3 bg-gray-light">
<div class="row"> <div class="row">
<environment-picker ref="environmentsPicker" /> <environment-picker ref="environmentsPicker" />
......
...@@ -24,7 +24,7 @@ exports[`NetworkPolicyList component given there is a default environment with n ...@@ -24,7 +24,7 @@ exports[`NetworkPolicyList component given there is a default environment with n
<p> <p>
Policies are a specification of how groups of pods are allowed to communicate with each other network endpoints. Policies are a specification of how groups of pods are allowed to communicate with each other's network endpoints.
</p> </p>
......
...@@ -36,6 +36,7 @@ describe('NetworkPolicyList component', () => { ...@@ -36,6 +36,7 @@ describe('NetworkPolicyList component', () => {
const findPolicyEditor = () => wrapper.find({ ref: 'policyEditor' }); const findPolicyEditor = () => wrapper.find({ ref: 'policyEditor' });
const findApplyButton = () => wrapper.find({ ref: 'applyButton' }); const findApplyButton = () => wrapper.find({ ref: 'applyButton' });
const findCancelButton = () => wrapper.find({ ref: 'cancelButton' }); const findCancelButton = () => wrapper.find({ ref: 'cancelButton' });
const findAutodevopsAlert = () => wrapper.find('[data-testid="autodevopsAlert"]');
beforeEach(() => { beforeEach(() => {
factory({}); factory({});
...@@ -72,6 +73,10 @@ describe('NetworkPolicyList component', () => { ...@@ -72,6 +73,10 @@ describe('NetworkPolicyList component', () => {
}); });
}); });
it('does not render autodevops alert', () => {
expect(findAutodevopsAlert().exists()).toBe(false);
});
describe('given there is a selected policy', () => { describe('given there is a selected policy', () => {
beforeEach(() => { beforeEach(() => {
factory({ factory({
...@@ -147,4 +152,19 @@ describe('NetworkPolicyList component', () => { ...@@ -147,4 +152,19 @@ describe('NetworkPolicyList component', () => {
expect(findTableEmptyState().element).toMatchSnapshot(); expect(findTableEmptyState().element).toMatchSnapshot();
}); });
}); });
describe('given autodevops selected policy', () => {
beforeEach(() => {
const policies = mockPoliciesResponse;
policies[0].isAutodevops = true;
factory({
state: { policies },
data: () => ({ selectedPolicyName: 'policy' }),
});
});
it('renders autodevops alert', () => {
expect(findAutodevopsAlert().exists()).toBe(true);
});
});
}); });
...@@ -14300,6 +14300,9 @@ msgstr "" ...@@ -14300,6 +14300,9 @@ msgstr ""
msgid "NetworkPolicies|Environment does not have deployment platform" msgid "NetworkPolicies|Environment does not have deployment platform"
msgstr "" msgstr ""
msgid "NetworkPolicies|If you are using Auto DevOps, your %{monospacedStart}auto-deploy-values.yaml%{monospacedEnd} file will not be updated if you change a policy in this section. Auto DevOps users should make changes by following the %{linkStart}Container Network Policy documentation%{linkEnd}."
msgstr ""
msgid "NetworkPolicies|Invalid or empty policy" msgid "NetworkPolicies|Invalid or empty policy"
msgstr "" msgstr ""
...@@ -14315,7 +14318,7 @@ msgstr "" ...@@ -14315,7 +14318,7 @@ msgstr ""
msgid "NetworkPolicies|No policies detected" msgid "NetworkPolicies|No policies detected"
msgstr "" msgstr ""
msgid "NetworkPolicies|Policies are a specification of how groups of pods are allowed to communicate with each other network endpoints." msgid "NetworkPolicies|Policies are a specification of how groups of pods are allowed to communicate with each other's network endpoints."
msgstr "" msgstr ""
msgid "NetworkPolicies|Policy %{policyName} was successfully changed" msgid "NetworkPolicies|Policy %{policyName} was successfully changed"
......
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