mirror of https://github.com/rancher/dashboard.git
Fix alert manager receiver name (#7941)
This commit is contained in:
parent
acb1dc36ce
commit
e07d9ad55f
|
|
@ -3125,6 +3125,7 @@ monitoring:
|
||||||
editYaml: Edit AlertmanagerConfig
|
editYaml: Edit AlertmanagerConfig
|
||||||
detail: Receiver in AlertmanagerConfig
|
detail: Receiver in AlertmanagerConfig
|
||||||
disabledReceiverButton: The receiver form is available after the AlertmanagerConfig is created
|
disabledReceiverButton: The receiver form is available after the AlertmanagerConfig is created
|
||||||
|
error: An error occurred saving the AlertmanagerConfig
|
||||||
email:
|
email:
|
||||||
username: Auth Username
|
username: Auth Username
|
||||||
password: Secret with Auth Password
|
password: Secret with Auth Password
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import CreateEditView from '@shell/mixins/create-edit-view';
|
||||||
import jsyaml from 'js-yaml';
|
import jsyaml from 'js-yaml';
|
||||||
import ButtonDropdown from '@shell/components/ButtonDropdown';
|
import ButtonDropdown from '@shell/components/ButtonDropdown';
|
||||||
import { _CREATE, _VIEW } from '@shell/config/query-params';
|
import { _CREATE, _VIEW } from '@shell/config/query-params';
|
||||||
|
import FormValidation from '@shell/mixins/form-validation';
|
||||||
|
|
||||||
export const RECEIVERS_TYPES = [
|
export const RECEIVERS_TYPES = [
|
||||||
{
|
{
|
||||||
|
|
@ -100,7 +101,7 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [CreateEditView],
|
mixins: [CreateEditView, FormValidation],
|
||||||
|
|
||||||
data(props) {
|
data(props) {
|
||||||
const currentReceiver = {};
|
const currentReceiver = {};
|
||||||
|
|
@ -152,6 +153,10 @@ export default {
|
||||||
suffixYaml,
|
suffixYaml,
|
||||||
view: _VIEW,
|
view: _VIEW,
|
||||||
yamlError: '',
|
yamlError: '',
|
||||||
|
fvFormRuleSets: [
|
||||||
|
{ path: 'name', rules: ['required'] }
|
||||||
|
],
|
||||||
|
fvReportedValidationPaths: ['value']
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -235,6 +240,14 @@ export default {
|
||||||
createAddOptions(receiverType) {
|
createAddOptions(receiverType) {
|
||||||
return receiverType.addOptions.map();
|
return receiverType.addOptions.map();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setError(err) {
|
||||||
|
if (!err) {
|
||||||
|
this.errors = [];
|
||||||
|
} else {
|
||||||
|
this.errors = [err];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -249,8 +262,9 @@ export default {
|
||||||
:can-yaml="true"
|
:can-yaml="true"
|
||||||
:errors="errors"
|
:errors="errors"
|
||||||
:cancel-event="true"
|
:cancel-event="true"
|
||||||
|
:validation-passed="fvFormIsValid"
|
||||||
@error="e=>errors = e"
|
@error="e=>errors = e"
|
||||||
@finish="saveOverride()"
|
@finish="saveOverride"
|
||||||
@cancel="redirectAfterCancel"
|
@cancel="redirectAfterCancel"
|
||||||
>
|
>
|
||||||
<div class="row mb-10">
|
<div class="row mb-10">
|
||||||
|
|
@ -259,7 +273,9 @@ export default {
|
||||||
v-model="value.name"
|
v-model="value.name"
|
||||||
:is-disabled="receiverNameDisabled"
|
:is-disabled="receiverNameDisabled"
|
||||||
:label="t('generic.name')"
|
:label="t('generic.name')"
|
||||||
|
:required="true"
|
||||||
:mode="mode"
|
:mode="mode"
|
||||||
|
:rules="fvGetAndReportPathRules('name')"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ export default {
|
||||||
// being saved. Therefore we take the save from the
|
// being saved. Therefore we take the save from the
|
||||||
// AlertmanagerConfig resource and pass it into the
|
// AlertmanagerConfig resource and pass it into the
|
||||||
// receiver config form.
|
// receiver config form.
|
||||||
saveOverride(buttonDone) {
|
async saveOverride(buttonDone) {
|
||||||
if (this.alertmanagerConfigResource.yamlError) {
|
if (this.alertmanagerConfigResource.yamlError) {
|
||||||
this.alertmanagerConfigResource.errors = this.alertmanagerConfigResource.errors || [];
|
this.alertmanagerConfigResource.errors = this.alertmanagerConfigResource.errors || [];
|
||||||
this.alertmanagerConfigResource.errors.push(this.alertmanagerConfigResource.yamlError);
|
this.alertmanagerConfigResource.errors.push(this.alertmanagerConfigResource.yamlError);
|
||||||
|
|
@ -166,8 +166,18 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.alertmanagerConfigResource.save(...arguments);
|
try {
|
||||||
|
await this.alertmanagerConfigResource.save(...arguments);
|
||||||
|
|
||||||
|
buttonDone(true);
|
||||||
|
|
||||||
this.redirectToAlertmanagerConfigDetail();
|
this.redirectToAlertmanagerConfigDetail();
|
||||||
|
} catch (e) {
|
||||||
|
const msg = e?.message ? e.message : this.t('monitoring.alertmanagerConfig.error');
|
||||||
|
|
||||||
|
this.$refs.config.setError(msg);
|
||||||
|
buttonDone(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleButtonGroupClick(event) {
|
handleButtonGroupClick(event) {
|
||||||
if (event === this.yaml) {
|
if (event === this.yaml) {
|
||||||
|
|
@ -271,6 +281,7 @@ export default {
|
||||||
/>
|
/>
|
||||||
<ReceiverConfig
|
<ReceiverConfig
|
||||||
v-if="(currentView === config || currentView === detail) && alertmanagerConfigResource"
|
v-if="(currentView === config || currentView === detail) && alertmanagerConfigResource"
|
||||||
|
ref="config"
|
||||||
:value="receiverValue"
|
:value="receiverValue"
|
||||||
:mode="mode"
|
:mode="mode"
|
||||||
:alertmanager-config-id="alertmanagerConfigId"
|
:alertmanager-config-id="alertmanagerConfigId"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue