Commit c3eff7a6 authored by Mike Greiling's avatar Mike Greiling

Merge branch 'add_restriction_for_ingress_update' into 'master'

Add restriction for updating nginx-ingress

See merge request gitlab-org/gitlab!27845
parents 2e16f885 aba15718
...@@ -93,7 +93,10 @@ export default { ...@@ -93,7 +93,10 @@ export default {
return [UPDATING].includes(this.ingress.status); return [UPDATING].includes(this.ingress.status);
}, },
saveButtonDisabled() { saveButtonDisabled() {
return [UNINSTALLING, UPDATING, INSTALLING].includes(this.ingress.status); return (
[UNINSTALLING, UPDATING, INSTALLING].includes(this.ingress.status) ||
this.ingress.updateAvailable
);
}, },
saveButtonLabel() { saveButtonLabel() {
return this.saving ? __('Saving') : __('Save changes'); return this.saving ? __('Saving') : __('Save changes');
...@@ -105,13 +108,14 @@ export default { ...@@ -105,13 +108,14 @@ export default {
* neither getting installed nor updated. * neither getting installed nor updated.
*/ */
showButtons() { showButtons() {
return ( return this.saving || this.valuesChangedByUser;
this.saving || (this.hasValueChanged && [INSTALLED, UPDATED].includes(this.ingress.status))
);
}, },
modSecurityModeName() { modSecurityModeName() {
return this.modes[this.ingress.modsecurity_mode].name; return this.modes[this.ingress.modsecurity_mode].name;
}, },
valuesChangedByUser() {
return this.hasValueChanged && [INSTALLED, UPDATED].includes(this.ingress.status);
},
}, },
methods: { methods: {
updateApplication() { updateApplication() {
......
...@@ -59,6 +59,7 @@ export default class ClusterStore { ...@@ -59,6 +59,7 @@ export default class ClusterStore {
isEditingModSecurityEnabled: false, isEditingModSecurityEnabled: false,
isEditingModSecurityMode: false, isEditingModSecurityMode: false,
updateFailed: false, updateFailed: false,
updateAvailable: false,
}, },
cert_manager: { cert_manager: {
...applicationInitialState, ...applicationInitialState,
...@@ -213,6 +214,7 @@ export default class ClusterStore { ...@@ -213,6 +214,7 @@ export default class ClusterStore {
if (appId === INGRESS) { if (appId === INGRESS) {
this.state.applications.ingress.externalIp = serverAppEntry.external_ip; this.state.applications.ingress.externalIp = serverAppEntry.external_ip;
this.state.applications.ingress.externalHostname = serverAppEntry.external_hostname; this.state.applications.ingress.externalHostname = serverAppEntry.external_hostname;
this.state.applications.ingress.updateAvailable = updateAvailable;
if (!this.state.applications.ingress.isEditingModSecurityEnabled) { if (!this.state.applications.ingress.isEditingModSecurityEnabled) {
this.state.applications.ingress.modsecurity_enabled = serverAppEntry.modsecurity_enabled; this.state.applications.ingress.modsecurity_enabled = serverAppEntry.modsecurity_enabled;
} }
......
---
title: WAF settings will be read-only if there is a new version of ingress available
merge_request: 27845
author:
type: changed
...@@ -14,6 +14,7 @@ describe('IngressModsecuritySettings', () => { ...@@ -14,6 +14,7 @@ describe('IngressModsecuritySettings', () => {
status: 'installable', status: 'installable',
installed: false, installed: false,
modsecurity_mode: 'logging', modsecurity_mode: 'logging',
updateAvailable: false,
}; };
const createComponent = (props = defaultProps) => { const createComponent = (props = defaultProps) => {
...@@ -61,6 +62,11 @@ describe('IngressModsecuritySettings', () => { ...@@ -61,6 +62,11 @@ describe('IngressModsecuritySettings', () => {
expect(findCancelButton().exists()).toBe(true); expect(findCancelButton().exists()).toBe(true);
}); });
it('enables related toggle and buttons', () => {
expect(findSaveButton().attributes().disabled).toBeUndefined();
expect(findCancelButton().attributes().disabled).toBeUndefined();
});
describe('with dropdown changed by the user', () => { describe('with dropdown changed by the user', () => {
beforeEach(() => { beforeEach(() => {
findModSecurityDropdown().vm.$children[1].$emit('click'); findModSecurityDropdown().vm.$children[1].$emit('click');
...@@ -105,6 +111,25 @@ describe('IngressModsecuritySettings', () => { ...@@ -105,6 +111,25 @@ describe('IngressModsecuritySettings', () => {
expect(findCancelButton().exists()).toBe(false); expect(findCancelButton().exists()).toBe(false);
}); });
}); });
describe('with a new version available', () => {
beforeEach(() => {
wrapper.setProps({
ingress: {
...defaultProps,
installed: true,
status: 'installed',
modsecurity_enabled: true,
updateAvailable: true,
},
});
});
it('disables related toggle and buttons', () => {
expect(findSaveButton().attributes().disabled).toBe('true');
expect(findCancelButton().attributes().disabled).toBe('true');
});
});
}); });
it('triggers set event to be propagated with the current modsecurity value', () => { it('triggers set event to be propagated with the current modsecurity value', () => {
......
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